Skip to content

Instantly share code, notes, and snippets.

@dbrady
Created October 31, 2012 17:40
Show Gist options
  • Save dbrady/3988571 to your computer and use it in GitHub Desktop.
Save dbrady/3988571 to your computer and use it in GitHub Desktop.
Autoenable linum-mode in emacs
;; Don't turn on linum-mode by default, it crashes org-mode. Ok to
;; turn it on for various modes, however.
(require 'linum)
(global-set-key "\C-c l" 'linum-mode)
(defun enable-linum-mode ()
(linum-mode t))
; ----------------------------------------------------------------------
; Automatically enable linum mode for various modes
(setq modes-to-hook-with-linum '(c-mode-hook
csv-mode-hook
emacs-lisp-mode-hook
coffee-mode-hook
feature-mode-hook
java-mode-hook
js-mode-hook
javascript-mode-hook
espresso-mode-hook
haml-mode-hook
lisp-mode-hook
nxml-mode-hook
php-mode-hook
ruby-mode-hook
sass-mode-hook
scss-mode-hook
sh-mode-hook
text-mode-hook
textile-mode-hook
xml-mode-hook
yaml-mode-hook))
(defun hook-linum-mode (mode)
(add-hook mode 'enable-linum-mode))
(while modes-to-hook-with-linum
(hook-linum-mode (car modes-to-hook-with-linum))
(setq modes-to-hook-with-linum (cdr modes-to-hook-with-linum)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment