making org-mode the standard mode for a new buffer/file. a custom word-count util, another one for switching frame-dimensions. color-themes, session management, a few custom key-bindings.
I use emacs mostly for LaTeX editing, so most of my .emacs sets up macros to make it easy to insert greek letters with a keystroke. (For some reason, I really hate using LaTeX macros to write shortcuts for these.)
Funny, about an hour ago I finally broke down and remapped Ctrl+w to backward-kill-word[1] after re-reading Yegge's Effective Emacs, and you've just reminded me to push the commit to my fork of emacs-starter-kit, which is a great way to get a core set of functionality. Works best if you're tyrannical about keeping it up to date, which I mostly am.
Favorite two most recent additions: pyflakes/pylint for Python, and rainbow-mode for CSS.
[1] Having backward-kill-word a two-finger-stroke, instead of the two-handed alt+Backspace, is great! On the other hand, it turns out I kill-region a lot more than I thought I did, so that's a little weird.
I try to keep it simple. I set my color theme, switch the font to Consolas, register some major modes (CMake, SLIME, haskell, org, etc), enable some of the disabled-by-default commands, and have some useful key bindings:
; I type this by mistake 80% of the time
(global-unset-key (kbd "C-x C-c"))
; One of my favorite commands
(global-set-key "\C-x\C-j" 'join-line)
; I haven't seen a keyboard with "copy" and "paste" buttons since 2008
; Honestly, Emacs' defaults, WTF
(global-set-key (kbd "<f2>") 'clipboard-kill-ring-save)
(global-set-key (kbd "<f3>") 'clipboard-yank)
And most importantly, I setup my font to monaco, tango color scheme and I prefer full screen emacs, so i have a bit of an involved process where I have basically this:
I'm trying for years to force myself not to move my right hand to arrows and instead use C-p C-n and C-b C-f, but I can't (well sometimes I do, but not all the time).
And various tweaks here and there, I might have forgotten something though.
It's a ~1200 line file (and expanding) this is how I navigate it:
(defun show-dot-emacs-structure ()
"Show the outline-mode structure of ~/.emacs"
(interactive)
(occur "^;;;;+"))
Which shows the outline of the file, e.g.:
74 matches for "^;;;;+" in buffer: .emacs
57:;;;; Debugging
67:;;;; Load paths
112:;;;; Emacs' interface
229:;;;; User info
236:;;;; Encoding
253:;;;; Indenting
273:;;;;; Per-project indentation settings
275:;;;;;; Git
A quiet startup:
;; Don't display the 'Welcome to GNU Emacs' buffer on startup
(setq inhibit-startup-message t)
;; Display this instead of "For information about GNU Emacs and the
;; GNU system, type C-h C-a.". This has been made intentionally hard
;; to customize in GNU Emacs so I have to resort to hackery.
(defun display-startup-echo-area-message ()
"If it wasn't for this you'd be GNU/Spammed by now"
(message ""))
;; Don't insert instructions in the *scratch* buffer
(setq initial-scratch-message nil)
Core UI settings:
;; Display the line and column number in the modeline
(setq line-number-mode t)
(setq column-number-mode t)
(line-number-mode t)
(column-number-mode t)
;; syntax highlight everywhere
(global-font-lock-mode t)
;; Show matching parens (mixed style)
(show-paren-mode t)
(setq show-paren-delay 0.0)
;; 'mixed highligts the whole sexp making it unreadable, maybe tweak
;; color display?
(setq show-paren-style 'parenthesis)
;; Highlight selection
(transient-mark-mode t)
;; make all "yes or no" prompts show "y or n" instead
(fset 'yes-or-no-p 'y-or-n-p)
Changing the switching is worth it, but I really need to find
something that allows me to <TAB> between different possibilities once
completion is exhausted, e.g. if I say "foo.c" and have both "foo.c"
and "foo.c.txt":
;; Switching
(iswitchb-mode 1)
(icomplete-mode 1)
I wish I could also turn off the annoying #-files, but they're
hardcoded in Emacs's C code:
;; I use version control, don't annoy me with backup files everywhere
(setq make-backup-files nil)
(setq auto-save-default nil)
Better file selection:
;;; Electric minibuffer!
;;; When selecting a file to visit, // will mean / and
;;; ~ will mean $HOME regardless of preceding text.
(setq file-name-shadow-tty-properties '(invisible t))
(file-name-shadow-mode 1)
I didn't write this, but it's very useful. It emulates vim's sofftab feature. So indenting with spaces doesn't suck anymore.
(defun backward-delete-whitespace-to-column ()
"delete back to the previous column of whitespace, or just one
char if that's not possible. This emulates vim's softtabs
feature."
(interactive)
(if indent-tabs-mode
(call-interactively 'backward-delete-char-untabify)
;; let's get to work
(let ((movement (% (current-column) tab-width))
(p (point)))
;; brain freeze, should be easier to calculate goal
(when (= movement 0) (setq movement tab-width))
(if (save-excursion
(backward-char movement)
(string-match "^\\s-+$" (buffer-substring-no-properties (point) p)))
(delete-region (- p movement) p)
(call-interactively 'backward-delete-char-untabify)))))
(global-set-key (kbd "<DEL>") 'backward-delete-whitespace-to-column)
> I really wish I could find something for Emacs which automatically detects the style of the code I'm editing and switches the coding style to that.
If it makes you feel any better, back when I was managing a team in Visual Studio, we called this the "When in Rome" feature. And yes, the versions of this we tried to put together worked as you'd expect... mostly. Determining peoples' whitespace decisions are not trivial. How many lines does the THEN clause of an IF need to have before you surround it with curlies? Do you only put a space before the parens around a function's arguments if there is more than one argument? And my personal favorite, how do you "funge" your indentation style if the nesting level gets high enough that you're at frequent risk of line wrap (soft or hard doesn't matter here)?
People have wacky rules, and as soon as you say you're going to auto-detect them, you're in for a world of pain. Of course, you might have a user base that isn't as persnickety, in which case it's really not that bad.
66 comments
[ 1.7 ms ] story [ 525 ms ] threadSpecifically, my favorite things are show-paren-mode, ido-mode, and rebinding C-, and C-. to move back and forward between windows.
gist.el, powershell-mode, yaml-mode, org-mode are a few I've taken out for brevity.
Otherwise, a few of these are emacs23 specific:
plus
http://lisp.pastebin.com/raw.php?i=MRbccMG4
http://github.com/daemianmack/emacs-starter-kit/
Favorite two most recent additions: pyflakes/pylint for Python, and rainbow-mode for CSS.
[1] Having backward-kill-word a two-finger-stroke, instead of the two-handed alt+Backspace, is great! On the other hand, it turns out I kill-region a lot more than I thought I did, so that's a little weird.
My entire .emacs is here: http://bitbucket.org/[redacted]/dotfiles/src/tip/.emacs
To mimic some of TextMate's functionality, I use:
1. autopair.el: http://www.emacswiki.org/emacs/AutoPairs.
2. yasnippet.el: http://code.google.com/p/yasnippet/
The latest version of Emacs for the MacOSX has an awesome fullscreen capability. I followed the instructions here: http://www.sanityinc.com/full-screen-support-for-cocoa-emacs...
iswitchb-mode has awesome minibuffer completion capabilities. http://www.emacswiki.org/emacs/IswitchBuffers
* Undo-tree. (http://www.emacswiki.org/emacs/UndoTree) Makes emacs undo useful.
This has been one of the most useful functions I've added to my .emacs:
From: http://www.xsteve.at/prg/emacs/power-user-tips.html, which has a bunch of good tips/key bindingsThis is super useful to me:
I also have yasnippet, but I don't really use it at all (I should). Also, recentf http://www.emacswiki.org/cgi-bin/wiki/recentf-buffer.el for a recently opened stuff (like dired, but for recent stuff).And most importantly, I setup my font to monaco, tango color scheme and I prefer full screen emacs, so i have a bit of an involved process where I have basically this:
where F11 puts me in and out of full screen mode and f12 toggles menu bar. F11 uses a small utility written in C# for windows to make this happen.clean darkroom - http://i.imgur.com/LloOY.png
with menu - http://i.imgur.com/yTeUz.png
I'm trying for years to force myself not to move my right hand to arrows and instead use C-p C-n and C-b C-f, but I can't (well sometimes I do, but not all the time).
And various tweaks here and there, I might have forgotten something though.
textmate.el is pretty awesome, as is ide-skel.
Some noteworthy things:
It's a ~1200 line file (and expanding) this is how I navigate it:
Which shows the outline of the file, e.g.: A quiet startup: Core UI settings: Changing the switching is worth it, but I really need to find something that allows me to <TAB> between different possibilities once completion is exhausted, e.g. if I say "foo.c" and have both "foo.c" and "foo.c.txt": I wish I could also turn off the annoying #-files, but they're hardcoded in Emacs's C code: Better file selection: I didn't write this, but it's very useful. It emulates vim's sofftab feature. So indenting with spaces doesn't suck anymore. I really wish I could find something for Emacs...Shameless plug for my dtrt-indent - it doesn't switch coding style but it does adapt transparently to foreign indentation offsets.
http://git.savannah.gnu.org/gitweb/?p=dtrt-indent.git;a=blob...
If it makes you feel any better, back when I was managing a team in Visual Studio, we called this the "When in Rome" feature. And yes, the versions of this we tried to put together worked as you'd expect... mostly. Determining peoples' whitespace decisions are not trivial. How many lines does the THEN clause of an IF need to have before you surround it with curlies? Do you only put a space before the parens around a function's arguments if there is more than one argument? And my personal favorite, how do you "funge" your indentation style if the nesting level gets high enough that you're at frequent risk of line wrap (soft or hard doesn't matter here)?
People have wacky rules, and as soon as you say you're going to auto-detect them, you're in for a world of pain. Of course, you might have a user base that isn't as persnickety, in which case it's really not that bad.
If I'm your manager, 0.
http://nschum.de/src/emacs/guess-style/
I don't like tabs!
Emacsclient is a real must. All my shells run inside of Emacs. So they're named, I get completions, and so on. That includes remote shells, using tramp and ssh-mode. Here's what I use for session.(setq slime-lisp-implementations '((ccl ("/usr/local/ccl/dx86cl64")) (sbcl ("/usr/local/bin/sbcl")))) (add-to-list 'load-path "/usr/local/slime/") (require 'slime) (slime-setup '(slime-repl slime-banner))