Git commits from Emacs
I've always hated switching to vim every time I want to write a commit message. And Emacs (the obviously superior editor) always takes too damned long to load with my crazy .emacs file. So I did a little digging and came up with this.
First add a minimal .emacs file (call it .emacs.minimal and put it in your home directory):
;; taken from http://snarfed.org/minimal_emacs_for_fast_startup
; cutoff for word wrap
(setq-default fill-column 79)
; F12 toggles auto-fill mode
(global-set-key [f12] 'auto-fill-mode)
; C-- keybinding for undo (removes the shift)
(global-set-key [(control -)] 'undo)
; turn on pending delete (when a region
; is selected, typing replaces it)
(delete-selection-mode t)
; when on a tab, make the cursor the tab length
(setq-default x-stretch-cursor t)
; avoid garbage collection (default is only 400k)
(setq-default gc-cons-threshold 4000000)
; turn on random customization options
(custom-set-variables
'(sentence-end-double-space nil)
'(truncate-partial-width-windows nil)
'(line-number-mode t)
'(column-number-mode t)
'(query-user-mail-address nil)
'(visible-bell t))
Then add in your ~/.gitconfig file add these lines:
[core]
editor = emacs -nw --no-init-file --no-site-file --load ~/.emacs.minimal
And now you should be able to edit config files with the best damned editor and minimal startup time. You're welcome.
Written by Pierre Larochelle
Related protips
1 Response
An alternative is to let Emacs started up all the time (for me it's not a constraint as I do almost all my work inside anyway) and map the emacs command to "emacsclient" , as Emacs supports a server/client operation mode (EDITOR=emacsclient in your .bashrc, for example).