Sample Emacs Config

Ingo Koch has a collection of publicly available .emacs files at his website, http://www.dotemacs.de/. Of these, the most frightening is that of Will Mengarini, which comes in at 305594 bytes, available at http://www.eskimo.com/~seldon/dotemacs.el. --EricJablow


That is frightening. How about this bit, where the author maps a bunch of descriptive names to a bunch of cryptic symbols with obscure mnemonics. Yes, he's written some code that actively helps reduce the readability and self-documentation of the rest of his code, just to save a few keystrokes. His reason? 'The length of words tends to be approximately inversely proportional to their frequency of use.'

That may well be true in natural languages. But when you're programming, you usually choose the function that does the thing you want, regardless of whether or not you like its name. I suppose some people just don't feel comfortable unless they're neck-deep in sigils. Crazy. Completely crazy. </rant>

Um, read the comments: it's for scratch code, and in general code that only he would ever read. This is no worse than using keyboard shortcuts in general.

 ;;;; ------------------------- ZIPFEAN ALIASES ------------------------- ;;;;

;; Zipf was a linguist who formulated a law that the length of words tends to ;; be approximately inversely proportional to their frequency of use.

(loop for (alias full-name) in '(

;; Intended for use in dotemacs or *scratch* code:

(!setq);mnemonic is Scheme `set!'; "!" = "modify"; setf is too slow (@apply);mnemonic is ,@ for splicing (^lambda) ;mnemonic is Greek capital lambda, like "^" but bigger (&funcall) ;mnemonic is Perl "&" prefix (&! callf);combines funcall and setq (&!2 callf2)

......


my .emacs. No bells nor whistles, just some keymappings I do need very often.

 (set-language-environment "Latin-1")  ;; I live in Finland
 (setq kill-whole-line t)

(defun set-sane-c-mode () "Good, traditional C mode" (interactive) (c-set-style "K&R") (setq c-basic-offset 8))

(add-hook 'c-mode-hook 'set-sane-c-mode) (add-hook 'c++-mode-hook 'set-sane-c-mode)

(setq auto-mode-alist (append '(("\\.php" . c++-mode) ("\\.phtml" . c++-mode) ("\\.inc" . c++-mode) ("\\.ml.?" . tuareg-mode)) auto-mode-alist))

(autoload 'tuareg-mode "tuareg" "Major mode for editing Caml code" t) (autoload 'camldebug "camldebug" "Run the Caml debugger" t)

(defun switch-to-other-buffer () "Switch to topmost non-visible buffer. On default bindings, same as C-x b RET. The buffer selected is the one returned by (other-buffer)." (interactive) (switch-to-buffer (other-buffer)))

(defun set-mark-and-goto-line (line) "Set mark and prompt for a line to go to." (interactive "NLine #: ") (push-mark nil t nil) (goto-line line) (message "Mark set where you came from."))

(global-set-key "\C-x\C-o" 'switch-to-other-buffer) (global-set-key "\C-x\C-n" 'bury-buffer) (global-set-key "\M-g" 'set-mark-and-goto-line)


EmacsWiki is probably the best place to post emacs configs. I have a number of strange and hairy items in my init.el (I'm an XEmacs user), but the most sanity-saving one I have is simplicity itself:

 (defun yes-or-no-p (prompt)
"I hate typing out y-e-s to satisfy some anal retentive programmer..."
(interactive)
(y-or-n-p prompt))

or use:

  (defalias 'yes-or-no-p 'y-or-n-p)


In 2014, searching GitHub for 'emacs config' a la http://github.com/search?utf8=%E2%9C%93&q=emacs+config is an effective way of finding emacs configurations to crib from.


CategoryEmacs


EditText of this page (last edited August 26, 2014) or FindPage with title or text search