Sunday, December 14, 2008

emacsclient




I just upgraded my OS and for some reason my emacsclient stopped working. It would just sit there and give me the message


Waiting for Emacs...


It turned out that the problem was that I now need to add the "-t" flag when starting emacsclient:

To just connect to "server"

emacsclient -t


To connect to a server called "sness"

emacsclient -t -s sness



Saturday, December 6, 2008

anything




I love my anything.el mode, it just totally rocks life in Emacs. I've been using it in it's most simple form, just looking for filenames, but over Christmas I'm going to expand it more and get things like descbinds-anything.el and things from this blog post working.

I would really like to get anything-gtags.el and gtags going in Emacs. I love tags mode, but I'm feeling a bit limited by it recently.

This is why I love Emacs so much, I can just take my time learning it, when I have some free time, I can expand my knowledge and get even more productive. I'll be using Emacs when I'm 90.



starter




An Emacs Starter Kit, some good defaults for your .emacs file.

For your fun and amusement, here is my .emacs file:


;;
;; sness's emacs 22 config
;;
;;
;; Om medhayai namah
;;
;; Om. I bow to Her who is the Power in intelligence.
;;

;;
;; sness load paths
;;
(setq load-path (cons "~/emacs-extras" load-path))
(setq load-path (cons "~/emacs-extras/g-client" load-path))
(add-to-list 'load-path "~/emacs-extras/muse/lisp")
(add-to-list 'load-path "~/emacs-extras/planner")
(add-to-list 'load-path "~/emacs-extras/remember")
(add-to-list 'load-path "~/emacs-extras/rinari")
(add-to-list 'load-path "~/emacs-extras/rinari/rhtml")
(add-to-list 'load-path "~/emacs-extras/emacs-w3m")
(add-to-list 'load-path "~/emacs-extras/nxml-mode")
(add-to-list 'load-path "~/emacs-extras/org/lisp")

;;
;; ri load paths
;;
(setq ri-ruby-script "/home/sness/emacs-extras/ri-emacs.rb")
(autoload 'ri "/home/sness/emacs-extras/ri-ruby.el" nil t)

;;
;; required lisp files
;;
(require 'planner)
(require 'planner-w3m)
(require 'muse-wiki)
(require 'w3m-load)
(require 'cc-mode)
(require 'inf-ruby)
(require 'sgml-mode)
(require 'rinari)
(require 'shell)
(require 'psvn)
(require 'ruby-mode)
(require 'anything-config)
(require 'anything-sness)
(require 'anything-adaptive)
(require 'org)

;;
;; global keymappings
;;
(global-set-key "\C-h" 'delete-backward-char)
(global-set-key "\C-d" 'delete-backward-char)
(global-set-key "\C-z" 'undo)
(global-set-key "\C-x\C-z" 'undo)
(global-set-key "\C-j" 'indent-region)
(global-set-key "\M-g" 'goto-line)
(global-set-key "\C-x\C-o" 'other-window)
(global-set-key "\C-x\k" 'kill-buffer)
(global-set-key "\C-x\C-k" 'kill-buffer)
(global-set-key "\C-x\d" 'mark-whole-buffer)
(global-set-key [S-right] 'forward-word)
(global-set-key [S-left] 'backward-word)
(global-set-key [?\e right] 'forward-sentence)
(global-set-key [?\e left] 'backward-sentence)
(global-set-key [?\e down] 'scroll-up)
(global-set-key [?\e up] 'scroll-down)
(global-set-key "\M-5" 'query-replace)
(global-set-key "\C-f" 'anything)
(global-set-key "\C-x\C-h" 'mark-whole-buffer)

;;
;; start some shells
;;
(shell "command-shell")
(shell "svn-shell")
(shell "mongrel-shell")
(shell "console-shell")
(shell "migrate-shell")
(shell "deploy-shell")
(shell "test-shell")
(shell "tail-log-shell")

;;
;; keymappings
;;
(define-key isearch-mode-map "\C-d" 'isearch-delete-char)
(define-key c++-mode-map "\C-d" 'delete-backward-char)
(define-key anything-map "\C-b" 'anything-previous-page)
(define-key anything-map [S-down] 'anything-next-page)
(define-key anything-map [S-up] 'anything-previous-page)

;;
;; matlab mode
;;
(autoload 'matlab-mode "matlab" "Enter MATLAB mode." t)
(setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist))
(autoload 'matlab-shell "matlab" "Interactive MATLAB mode." t)

;;
;; cmake mode
;;
(require 'cmake-mode)
(setq auto-mode-alist
(append '(("CMakeLists\\.txt\\'" . cmake-mode)
("\\.cmake\\'" . cmake-mode))
auto-mode-alist))

;;
;; org-mode
;;
(require 'org)
(require 'org-export-latex)
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(global-font-lock-mode 1)
(setq org-hide-leading-stars t)
(define-key org-mode-map [backtab] 'org-global-cycle)
(define-key org-mode-map [S-right] 'forward-word)
(define-key org-mode-map [S-left] 'backward-word)
(define-key org-mode-map [S-down] 'scroll-one-line-up)
(define-key org-mode-map [S-up] 'scroll-one-line-down)

;;
;; anything
;;
(setq anything-samewindow t)
(setq anything-sources
(list anything-c-source-buffers))

;; Some commonly used registers
(set-register ?a '("<a href=\"\"></a>"))
(set-register ?i '("<img src=\"http://assets.sness.net/\" />"))
(set-register ?p '("<pre>
</pre>"))

;; Make a new blog entry for the sness blog
(defun gblogger-new-entry-sness ()
(interactive)
(gblogger-new-entry "http://www.blogger.com/feeds/175252/posts/default")
)

(defun gblogger-new-entry-emacslife ()
(interactive)
(gblogger-new-entry "http://www.blogger.com/feeds/5967671474525843053/posts/default")
)

(defun gblogger-new-entry-codermonk ()
(interactive)
(gblogger-new-entry "http://www.blogger.com/feeds/20401470/posts/default")
)

;;
;; Function keys
;;
(global-set-key [f1] 'help)
(global-set-key [f2] 'auto-fill-mode)
(global-set-key [f3] 'kmacro-start-macro-or-insert-counter)
(global-set-key [f4] 'kmacro-end-or-call-macro)
(global-set-key [f5] 'gblogger-new-entry-sness)
(global-set-key [C-f5] 'gblogger-new-entry-codermonk)
(global-set-key [?\e f5] 'gblogger-new-entry-emacslife)
(global-set-key [f6] 'planner-create-task-from-buffer)
(global-set-key [f7] 'planner-task-in-progress)
(global-set-key [f8] 'planner-task-done)
(global-set-key [f11] 'compile)
(global-set-key [f12] 'recompile)
; sness - for some reason my Microsoft Natural 4000 maps f11 to S-f1
(global-set-key [S-f1] 'compile)
(global-set-key [S-f2] 'recompile)


;; marsyas
(setq auto-mode-alist (cons '("\\.mf\\'" . text-mode) auto-mode-alist))

;;
;; haxe-mode
;;
(require 'haxe-mode)
(define-key haxe-mode-map "\C-d" 'delete-backward-char)
(setq auto-mode-alist (cons '("\\.as\\'" . haxe-mode) auto-mode-alist))
(defconst my-haxe-style
'("java" (c-offsets-alist . ((case-label . +)
(arglist-intro . +)
(arglist-close . 0)
(cpp-macro . 0))))
"My haXe Programming Style")
(add-hook 'haxe-mode-hook
(function (lambda () (c-add-style "haxe" my-haxe-style t))))
(add-hook 'haxe-mode-hook
(function
(lambda ()
(setq tab-width 4)
(setq indent-tabs-mode t)
(setq fill-column 80)
(local-set-key [(return)] 'newline-and-indent))))


;;
;; yaml-mode
;;

(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
(add-hook 'yaml-mode-hook
'(lambda ()
(define-key yaml-mode-map "\C-m" 'newline-and-indent)))
(indent-according-to-mode)

;;
;; nxml-mode
;;
(load "~/emacs-extras/nxml-mode/rng-auto.el")
(setq auto-mode-alist
(cons '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
auto-mode-alist))
;;
;; g-client
;;
(load-library "g")
(setq g-user-email "snessnet@gmail.com")
(setq g-html-handler 'w3m-buffer)

;;
;; planner-mode
;;
(setq planner-project "WikiPlanner")
(setq muse-project-alist
'(("WikiPlanner"
("~/mDEV/info/work-plans"
:default "index"
:major-mode planner-mode
:visit-link planner-visit-link))))
(setq muse-wiki-allow-nonexistent-wikiword t)
(setq mark-diary-entries-in-calendar t)
;(define-key mode-specific-map [?n] 'planner-goto-today)
;; carry tasks forward from all previous days
(setq planner-carry-tasks-forward 0)
;; Allow creation of tasks from any mode
(global-set-key "\C-c\C-t" 'planner-create-task-from-buffer)

;;
;; w3m web browser
;;
;; Use w3m as the default browse-url web browser
(setq browse-url-browser-function 'w3m-browse-url)
(global-set-key "\C-xm" 'browse-url-at-point)
(define-key w3m-mode-map "\M-n" 'w3m-next-buffer)
(define-key w3m-mode-map "\M-p" 'w3m-previous-buffer)
(define-key w3m-mode-map [S-right] 'w3m-next-buffer)
(define-key w3m-mode-map [S-left] 'w3m-previous-buffer)
(define-key w3m-mode-map "\C-r" 'w3m-reload-this-page)
(define-key w3m-mode-map "\M-RET" 'w3m-view-this-url-new-session)

;;
;; c-mode
;;
(define-key c-mode-map "\C-d" 'delete-backward-char)

;;
;; c++-mode
;;
(setq auto-mode-alist
(cons '("\\.h\\'" . c++-mode) auto-mode-alist))

;;
;; don't make backup files
;;
(setq make-backup-files nil)

;; inferior-ruby
(define-key inferior-ruby-mode-map "\C-d" 'delete-backward-char)

;; css-mode
(autoload 'css-mode "css-mode")
(setq auto-mode-alist
(cons '("\\.css\\'" . css-mode) auto-mode-alist))
(setq cssm-indent-function #'cssm-c-style-indenter)

;; html-mode
(define-key html-mode-map "\t" 'sgml-indent-line)

;; rinari mode
(setq auto-mode-alist (cons '("\\.rhtml\\'" . rhtml-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.erb\\'" . rhtml-mode) auto-mode-alist))

;; show matching parentheses
(show-paren-mode t)

;; customize text-mode
(define-key text-mode-map "\t" 'self-insert-command)

;; customize shell-mode
(define-key shell-mode-map "\C-d" 'delete-backward-char)

;; customize comint-mode (for SQL)
(define-key comint-mode-map "\C-d" 'delete-backward-char)
;; this next one is close, but I want the great zsh way
;; Hmmm, this will be tough, as C-r searches backward, and that's really important
;; (define-key comint-mode-map "\C-r" 'comint-previous-matching-input-from-input)

;; highlight text when it's selected
(transient-mark-mode t)

;; don't make backups
(defun make-backup-file-name-function ())

;; iswitchb
;(iswitchb-mode 1)

;; subversion

;; ruby
(require 'ruby-mode)
(setq auto-mode-alist (cons '("\\.rb$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.rake$" . ruby-mode) auto-mode-alist))
(define-key ruby-mode-map "\C-c\C-c" 'comment-region)

;; scroll one line at a time
(defun scroll-one-line-up (&optional arg)
"Scroll the selected window up (forward in the text) one line (or N lines)."
(interactive "p")
(scroll-up (or arg 1)))
(defun scroll-one-line-down (&optional arg)
"Scroll the selected window down (backward in the text) one line (or N)."
(interactive "p")
(scroll-down (or arg 1)))
;; Bind these functions (substitute your favorite keys for mine)
(global-set-key "\M-v" 'scroll-one-line-up)
(global-set-key "\C-b" 'scroll-one-line-up)
(global-set-key "\C-v" 'scroll-one-line-down)
(global-set-key [S-down] 'scroll-one-line-up)
(global-set-key [S-up] 'scroll-one-line-down)
(global-set-key [(kp-subtract)] 'scroll-one-line-down)
(global-set-key [(kp-add)] 'scroll-one-line-up)

;; insert the current date into the buffer
(defun insert-date ()
"Insert date at the current cursor position in the current buffer."
(interactive)
(insert
(format-time-string "** %a %b %d %Y - %H:%M:%S %p")
"\n"
" -----------------------------"
"\n"))
(global-set-key "\M-i" 'insert-date)

;;;; goto buffer start and end
(defun goto-buffer-start (&optional arg)
"Goto the start of the buffer" (interactive "p")
(goto-char (point-min)))(defun goto-buffer-end (&optional arg)
"Goto the start of the buffer" (interactive "p")
(goto-char (point-max)))
(global-set-key '[(find)] 'goto-buffer-start)
(global-set-key '[(select)] 'goto-buffer-end)
(global-set-key '[(home)] 'goto-buffer-start)
(global-set-key '[(end)] 'goto-buffer-end)

;;
;; nethack inside emacs!
;;
;;(setq load-path (cons "~/emacs-extras/nethack_el" load-path))
;; (autoload 'nethack "nethack" "Play Nethack." t)
;; (setq nethack-program "/usr/sness/slashem/local/bin/slashem")

;;
;; Automatically set by M-x customize
;;
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(display-time-mail-file (quote none))
'(display-time-mode t)
'(g-html-handler (quote browse-url-at-point))
'(g-url-under-point (quote w3-view-this-url))
'(g-user-email "snessnet@gmail.com")
'(gblogger-user-password nil)
'(gdb-find-source-frame t)
'(gdb-many-windows t)
'(gdb-same-frame nil)
'(gdb-show-main t)
'(inhibit-splash-screen t)
'(iswitchb-default-method (quote samewindow))
'(iswitchb-max-to-show nil)
'(menu-bar-mode nil)
'(muse-project-alist (quote (("WikiPlanner" ("~/plans" "index")))))
'(nethack-message-window-height 10)
'(org-agenda-files (quote ("~/mDEV/info/work-org/OrcaMultiRes.org" "~/mDEV/info/work-org/TorahChant.org" "~/mDEV/info/work-org/TaskPool.org" "~/mDEV/info/work-org/SVM.org" "~/mDEV/info/work-org/Radiodrum.org" "~/mDEV/info/work-org/Orchive.org" "~/mDEV/info/work-org/Marsyas.org" "~/mDEV/info/work-org/MNV.org" "~/mDEV/info/work-org/MISTIC.org" "~/mDEV/info/work-org/IEEE_AICultureHeritagePaper.org" "~/mDEV/info/work-org/FFTPng.org" "~/mDEV/info/work-org/FFTPlayer.org")))
'(planner-day-page-template "* Tasks


* Notes


")
'(planner-use-other-window nil)
'(safe-local-variable-values (quote ((allout-widgets-mode-inhibit . t) (folded-file . t))))
'(server-mode t)
'(size-indication-mode nil)
'(tab-stop-list (quote (4 8 12 16 20 24 28 32 26 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120)))
'(tab-width 4))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(compilation-info ((((class color)) (:foreground "green"))))
'(ediff-current-diff-A ((((class color)) (:background "white"))))
'(ediff-current-diff-B ((((class color)) (:background "white"))))
'(ediff-even-diff-A ((((class color)) nil)))
'(ediff-even-diff-B ((((class color)) nil)))
'(ediff-fine-diff-A ((((class color)) (:background "cyan"))))
'(ediff-fine-diff-B ((((class color)) (:background "cyan"))))
'(ediff-odd-diff-A ((((class color)) nil)))
'(ediff-odd-diff-B ((((class color)) nil)))
'(erb-exec-delim-face ((t (:foreground "purple"))))
'(erb-face ((t (:foreground "black"))))
'(erb-out-delim-face ((t (:foreground "magenta"))))
'(font-lock-builtin-face ((((class color) (min-colors 8)) (:foreground "blue"))))
'(font-lock-comment-face ((t (:foreground "red"))))
'(font-lock-comment-face-erb ((t (:foreground "red"))) t)
'(font-lock-constant-face ((((class color) (min-colors 8)) (:foreground "blue"))))
'(font-lock-constant-face-erb ((t (:foreground "purple"))) t)
'(font-lock-function-name-face ((((class color) (min-colors 8)) (:foreground "blue"))))
'(font-lock-keyword-face ((((class color) (min-colors 8)) (:foreground "blue"))))
'(font-lock-keyword-face-erb ((t (:foreground "blue"))) t)
'(font-lock-string-face ((((class color) (min-colors 8)) (:foreground "red"))))
'(font-lock-string-face-erb ((t (:foreground "red"))) t)
'(font-lock-type-face ((((class color) (min-colors 8)) (:foreground "purple"))))
'(font-lock-type-face-erb ((t (:foreground "purple"))) t)
'(font-lock-variable-name-face ((((class color) (min-colors 8)) (:foreground "blue" :weight light))))
'(font-lock-variable-name-face-erb ((t (:foreground "blue"))) t)
'(info-menu-header ((((type tty pc)) (:weight bold))))
'(info-title-1 ((((type tty pc) (class color) (background light)) (:foreground "green"))))
'(info-title-2 ((((type tty pc) (class color)) (:foreground "blue"))))
'(isearch ((((class color) (min-colors 8)) (:background "red" :foreground "black"))))
'(lazy-highlight ((((class color) (min-colors 8)) nil)))
'(mode-line ((t (:foreground "red"))))
'(mode-line-buffer-id ((t (:foreground "blue"))))
'(mode-line-inactive ((default (:inherit mode-line)) (((class color) (min-colors 88) (background light)) nil)))
'(nethack-brown-face ((((type tty) (class color)) (:foreground "black" :weight bold))))
'(nethack-dark-gray-face ((t (:foreground "black" :weight bold))))
'(nethack-gray-face ((((type tty) (class color)) (:foreground "color-36"))))
'(nethack-message-highlight-face ((t nil)))
'(nethack-pet-face ((t (:inverse-video t))))
'(nethack-status-good-face ((((type tty) (class color)) (:weight bold))))
'(nethack-white-face ((t (:foreground "color-23"))))
'(nethack-yellow-face ((t (:foreground "yellow"))))
'(org-level-1 ((t (:foreground "blue"))))
'(org-level-2 ((t (:foreground "DarkGoldenrod"))))
'(w3m-tab-selected-face ((((class color)) (:background "color-41" :foreground "black"))))
'(w3m-tab-unselected-face ((((class color)) (:background "color-43" :foreground "black")))))

;
; Om sadhanayai namah
;
; Om. I bow to Her who is the essence of spiritual discipline.
;

(put 'downcase-region 'disabled nil)


(setq muse-project-alist
'(("WikiPlanner"
("~/mDEV/info/work-plans"
:default "index"
:major-mode planner-mode
:visit-link planner-visit-link))))
(setq muse-wiki-allow-nonexistent-wikiword t)
(put 'upcase-region 'disabled nil)





Tuesday, December 2, 2008

eproject




Interesting ideas in eproject.el for managing large software projects with Emacs.

I personally use anything.el, I should look into setting up some of these ideas with anything mode. If you don't use anything.el yet, totally check it out, it has made me 10x more productive in Emacs. I used iswitchb for years, and it's great, but anything.el is so smart, it's scary. Often it knows which buffer I want to switch to before I do.