From 61bfb8f36de5dd552d246efecb8a752c1bc0dc63 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 21 Apr 2012 20:04:48 +0100 Subject: [PATCH] Use functions instead of lambdas for mode customizations --- mode-customizations/coffee-mode.el | 20 ++++--- mode-customizations/conf-mode.el | 12 ++-- mode-customizations/css-mode.el | 20 ++++--- mode-customizations/emacs-lisp-mode.el | 15 ++--- mode-customizations/erlang-mode.el | 18 +++--- mode-customizations/feature-mode.el | 20 ++++--- mode-customizations/js-mode.el | 20 ++++--- mode-customizations/magit-mode.el | 26 +++++---- mode-customizations/makefile-mode.el | 16 ++--- mode-customizations/markdown-mode.el | 18 +++--- mode-customizations/php-mode.el | 16 ++--- mode-customizations/python-mode.el | 18 +++--- mode-customizations/ruby-mode.el | 81 ++++++++++++-------------- mode-customizations/sh-mode.el | 14 +++-- mode-customizations/yaml-mode.el | 20 ++++--- 15 files changed, 178 insertions(+), 156 deletions(-) diff --git a/mode-customizations/coffee-mode.el b/mode-customizations/coffee-mode.el index 06998f2..b0493e7 100644 --- a/mode-customizations/coffee-mode.el +++ b/mode-customizations/coffee-mode.el @@ -1,12 +1,14 @@ (add-to-list 'auto-mode-alist '("\\.coffee$" . coffee-mode)) (add-to-list 'auto-mode-alist '("Cakefile" . coffee-mode)) -(add-hook 'coffee-mode-hook - (lambda () - (flyspell-prog-mode) - (linum-mode t) - (fci-mode) - (setq tab-width 2) - (setq highlight-indentation-offset 2) - (highlight-indentation-mode) - (highlight-indentation-current-column-mode))) +(defun customizations-for-coffee-mode () + (interactive) + (flyspell-prog-mode) + (linum-mode t) + (fci-mode) + (setq tab-width 2) + (setq highlight-indentation-offset 2) + (highlight-indentation-mode) + (highlight-indentation-current-column-mode)) + +(add-hook 'coffee-mode-hook 'customizations-for-coffee-mode) diff --git a/mode-customizations/conf-mode.el b/mode-customizations/conf-mode.el index 3047a8b..d958175 100644 --- a/mode-customizations/conf-mode.el +++ b/mode-customizations/conf-mode.el @@ -1,5 +1,7 @@ -(add-hook 'conf-mode-hook - (lambda () - (flyspell-prog-mode) - (linum-mode t) - (fci-mode))) +(defun customizations-for-conf-mode () + (interactive) + (flyspell-prog-mode) + (linum-mode t) + (fci-mode)) + +(add-hook 'conf-mode-hook 'customizations-for-conf-mode) diff --git a/mode-customizations/css-mode.el b/mode-customizations/css-mode.el index 13cb2d1..b4e4200 100644 --- a/mode-customizations/css-mode.el +++ b/mode-customizations/css-mode.el @@ -1,9 +1,11 @@ -(add-hook 'css-mode-hook - (lambda () - (flyspell-prog-mode) - (linum-mode t) - (fci-mode) - (setq css-indent-offset 2) - (setq highlight-indentation-offset 2) - (highlight-indentation-mode) - (define-key css-mode-map (kbd "RET") 'newline-and-indent))) +(defun customizations-for-css-mode () + (interactive) + (flyspell-prog-mode) + (linum-mode t) + (fci-mode) + (setq css-indent-offset 2) + (setq highlight-indentation-offset 2) + (highlight-indentation-mode) + (define-key css-mode-map (kbd "RET") 'newline-and-indent)) + +(add-hook 'css-mode-hook 'customizations-for-css-mode) diff --git a/mode-customizations/emacs-lisp-mode.el b/mode-customizations/emacs-lisp-mode.el index f44fe7d..61db802 100644 --- a/mode-customizations/emacs-lisp-mode.el +++ b/mode-customizations/emacs-lisp-mode.el @@ -1,7 +1,8 @@ -;; Lisp Hook -(add-hook 'emacs-lisp-mode-hook - (lambda () - (setq whitespace-action (quote (auto-cleanup))) - (flyspell-prog-mode) - (linum-mode t) - (fci-mode))) +(defun customizations-for-emacs-lisp-mode () + (interactive) + (setq whitespace-action (quote (auto-cleanup))) + (flyspell-prog-mode) + (linum-mode t) + (fci-mode)) + +(add-hook 'emacs-lisp-mode-hook 'customizations-for-emacs-lisp-mode) diff --git a/mode-customizations/erlang-mode.el b/mode-customizations/erlang-mode.el index 118ca2d..c08c73d 100644 --- a/mode-customizations/erlang-mode.el +++ b/mode-customizations/erlang-mode.el @@ -8,11 +8,13 @@ (require 'erlang-start) (require 'erlang-flymake) -(add-hook 'erlang-mode-hook - (lambda () - (flyspell-prog-mode) - (linum-mode t) - (fci-mode) - (setq highlight-indentation-offset 2) - (highlight-indentation-mode) - (highlight-indentation-current-column-mode))) +(defun customizations-for-erlang-mode () + (interactive) + (flyspell-prog-mode) + (linum-mode t) + (fci-mode) + (setq highlight-indentation-offset 2) + (highlight-indentation-mode) + (highlight-indentation-current-column-mode)) + +(add-hook 'erlang-mode-hook 'customizations-for-erlang-mode) diff --git a/mode-customizations/feature-mode.el b/mode-customizations/feature-mode.el index e4a911f..86beb86 100644 --- a/mode-customizations/feature-mode.el +++ b/mode-customizations/feature-mode.el @@ -1,11 +1,13 @@ (add-to-list 'auto-mode-alist '("\\.feature" . feature-mode)) -(add-hook 'feature-mode-hook - (lambda () - (setq whitespace-action (quote (auto-cleanup))) - (flyspell-mode) - (linum-mode t) - (fci-mode) - (setq highlight-indentation-offset 2) - (highlight-indentation-mode) - (highlight-indentation-current-column-mode))) +(defun customizations-for-feature-mode () + (interactive) + (setq whitespace-action (quote (auto-cleanup))) + (flyspell-mode) + (linum-mode t) + (fci-mode) + (setq highlight-indentation-offset 2) + (highlight-indentation-mode) + (highlight-indentation-current-column-mode)) + +(add-hook 'feature-mode-hook 'customizations-for-feature-mode) diff --git a/mode-customizations/js-mode.el b/mode-customizations/js-mode.el index 8892bbe..b49df8b 100644 --- a/mode-customizations/js-mode.el +++ b/mode-customizations/js-mode.el @@ -1,9 +1,11 @@ -(add-hook 'js-mode-hook - (lambda () - (setq js-indent-level 2) - (flyspell-prog-mode) - (linum-mode t) - (fci-mode) - (setq tab-width 2) - (setq highlight-indentation-offset 2) - (highlight-indentation-mode))) +(defun customizations-for-js-mode () + (interactive) + (setq js-indent-level 2) + (flyspell-prog-mode) + (linum-mode t) + (fci-mode) + (setq tab-width 2) + (setq highlight-indentation-offset 2) + (highlight-indentation-mode)) + +(add-hook 'js-mode-hook 'customizations-for-js-mode) diff --git a/mode-customizations/magit-mode.el b/mode-customizations/magit-mode.el index b6ede1e..971733f 100644 --- a/mode-customizations/magit-mode.el +++ b/mode-customizations/magit-mode.el @@ -1,13 +1,17 @@ -;; Make Magit it look a bit prettier with my theme -(add-hook 'magit-mode-hook - (lambda () - (linum-mode t))) +;; Make Magit look a bit prettier with my theme +(defun customizations-for-magit-mode () + (interactive) + (linum-mode t)) + +(add-hook 'magit-mode-hook 'customizations-for-magit-mode) ;; Write commit messages in style -(add-hook 'magit-log-edit-mode-hook - (lambda () - (flyspell-mode) - (linum-mode t) - (auto-fill-mode) - (setq fill-column 72) - (fci-mode))) +(defun customizations-for-magit-log-edit-mode () + (interactive) + (flyspell-mode) + (linum-mode t) + (auto-fill-mode) + (setq fill-column 72) + (fci-mode)) + +(add-hook 'magit-log-edit-mode-hook 'customizations-for-magit-log-edit-mode) diff --git a/mode-customizations/makefile-mode.el b/mode-customizations/makefile-mode.el index 5a78611..6f6e445 100644 --- a/mode-customizations/makefile-mode.el +++ b/mode-customizations/makefile-mode.el @@ -1,7 +1,9 @@ -(add-hook 'makefile-mode-hook - (lambda () - (flyspell-prog-mode) - (linum-mode t) - (fci-mode) - (setq tab-width 4) - (highlight-indentation-mode))) +(defun customizations-for-makefile-mode () + (interactive) + (flyspell-prog-mode) + (linum-mode t) + (fci-mode) + (setq tab-width 4) + (highlight-indentation-mode)) + +(add-hook 'makefile-mode-hook 'customizations-for-makefile-mode) diff --git a/mode-customizations/markdown-mode.el b/mode-customizations/markdown-mode.el index d498154..0bd46d6 100644 --- a/mode-customizations/markdown-mode.el +++ b/mode-customizations/markdown-mode.el @@ -4,11 +4,13 @@ (setq auto-mode-alist (cons '("\\.mdown" . markdown-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.markdown" . markdown-mode) auto-mode-alist)) -(add-hook 'markdown-mode-hook - (lambda () - (setq whitespace-action nil) - (fci-mode) - (linum-mode t) - (flyspell-mode) - (auto-fill-mode) - (define-key markdown-mode-map (kbd "C-c p") 'markdown-preview))) +(defun customizations-for-markdown-mode () + (interactive) + (setq whitespace-action nil) + (fci-mode) + (linum-mode t) + (flyspell-mode) + (auto-fill-mode) + (define-key markdown-mode-map (kbd "C-c p") 'markdown-preview)) + +(add-hook 'markdown-mode-hook 'customizations-for-markdown-mode) diff --git a/mode-customizations/php-mode.el b/mode-customizations/php-mode.el index b3635e0..4a22fd9 100644 --- a/mode-customizations/php-mode.el +++ b/mode-customizations/php-mode.el @@ -1,7 +1,9 @@ -(add-hook 'php-mode-hook - (lambda () - (setq whitespace-action (quote (auto-cleanup))) - (flyspell-prog-mode) - (linum-mode t) - (fci-mode) - (highlight-indentation-mode))) +(defun customizations-for-php-mode () + (interactive) + (setq whitespace-action (quote (auto-cleanup))) + (flyspell-prog-mode) + (linum-mode t) + (fci-mode) + (highlight-indentation-mode)) + +(add-hook 'php-mode-hook 'customizations-for-php-mode) diff --git a/mode-customizations/python-mode.el b/mode-customizations/python-mode.el index d68c82e..a6d0322 100644 --- a/mode-customizations/python-mode.el +++ b/mode-customizations/python-mode.el @@ -1,8 +1,10 @@ -(add-hook 'python-mode-hook - (lambda () - (flyspell-prog-mode) - (linum-mode t) - (fci-mode) - (highlight-indentation-mode) - (highlight-indentation-current-column-mode) - (define-key python-mode-map (kbd "RET") 'newline-and-indent))) +(defun customizations-for-python-mode () + (interactive) + (flyspell-prog-mode) + (linum-mode t) + (fci-mode) + (highlight-indentation-mode) + (highlight-indentation-current-column-mode) + (define-key python-mode-map (kbd "RET") 'newline-and-indent)) + +(add-hook 'python-mode-hook 'customizations-for-python-mode) diff --git a/mode-customizations/ruby-mode.el b/mode-customizations/ruby-mode.el index dbff83f..766592c 100644 --- a/mode-customizations/ruby-mode.el +++ b/mode-customizations/ruby-mode.el @@ -1,56 +1,49 @@ (autoload 'ruby-mode "ruby-mode" nil t) -(add-to-list 'auto-mode-alist '("Capfile" . ruby-mode)) -(add-to-list 'auto-mode-alist '("Gemfile" . ruby-mode)) -(add-to-list 'auto-mode-alist '("Rakefile" . ruby-mode)) (add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode)) (add-to-list 'auto-mode-alist '("\\.ru\\'" . ruby-mode)) (add-to-list 'auto-mode-alist '("\\.rake\\'" . ruby-mode)) (add-to-list 'auto-mode-alist '("\\.gemspec\\'" . ruby-mode)) (add-to-list 'auto-mode-alist '("\\.rabl\\'" . ruby-mode)) (add-to-list 'auto-mode-alist '("\\.prawn\\'" . ruby-mode)) +(add-to-list 'auto-mode-alist '("Capfile" . ruby-mode)) +(add-to-list 'auto-mode-alist '("Gemfile" . ruby-mode)) +(add-to-list 'auto-mode-alist '("Rakefile" . ruby-mode)) -(add-hook 'ruby-mode-hook - (lambda () - (flyspell-prog-mode) - (linum-mode t) - (fci-mode) - (require 'inf-ruby) - (require 'ruby-electric) - (require 'ruby-compilation) - (require 'flymake) - (require 'flymake-ruby) - (when (require 'rsense nil 'noerror) - (add-to-list 'ac-sources 'ac-source-rsense-method) - (add-to-list 'ac-sources 'ac-source-rsense-constant)) - (flymake-ruby-load) - (highlight-indentation-mode) - (ruby-electric-mode t) - (setq ruby-deep-arglist t) - (setq ruby-deep-indent-paren nil) - (setq c-tab-always-indent nil) - (setq ruby-use-encoding-map nil) - (setq ruby-electric-expand-delimiters-list (quote (124))) - (hs-minor-mode 1) - (setq whitespace-action (quote (auto-cleanup))) - (define-key ruby-mode-map - (kbd "RET") 'reindent-then-newline-and-indent) - (define-key ruby-mode-map - (kbd "C-c C-j") 'hs-toggle-hiding) - (define-key ruby-mode-map - (kbd "s-r") 'ruby-compilation-this-buffer) - (define-key ruby-mode-map - (kbd "C-c C-r") 'ruby-compilation-this-buffer) - (define-key ruby-mode-map - (kbd "C-c C-.") 'ac-complete-rsense) - (define-key ruby-mode-map - (kbd "C-x t") 'textmate-goto-file) - (define-key ruby-mode-map - (kbd "C-x C-t") 'textmate-goto-file) - (define-key ruby-mode-map - (kbd "C-c C-l") 'goto-line) - (define-key ruby-mode-map - (kbd "C-c C-b") 'eproject-ibuffer))) +(defun customizations-for-ruby-mode () + (interactive) + (flyspell-prog-mode) + (linum-mode t) + (fci-mode) + (require 'inf-ruby) + (require 'ruby-electric) + (require 'ruby-compilation) + (require 'flymake) + (require 'flymake-ruby) + (when (require 'rsense nil 'noerror) + (add-to-list 'ac-sources 'ac-source-rsense-method) + (add-to-list 'ac-sources 'ac-source-rsense-constant)) + (flymake-ruby-load) + (highlight-indentation-mode) + (ruby-electric-mode t) + (setq ruby-deep-arglist t) + (setq ruby-deep-indent-paren nil) + (setq c-tab-always-indent nil) + (setq ruby-use-encoding-map nil) + (setq ruby-electric-expand-delimiters-list (quote (124))) + (hs-minor-mode 1) + (setq whitespace-action (quote (auto-cleanup))) + (define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent) + (define-key ruby-mode-map (kbd "C-c C-j") 'hs-toggle-hiding) + (define-key ruby-mode-map (kbd "s-r") 'ruby-compilation-this-buffer) + (define-key ruby-mode-map (kbd "C-c C-r") 'ruby-compilation-this-buffer) + (define-key ruby-mode-map (kbd "C-c C-.") 'ac-complete-rsense) + (define-key ruby-mode-map (kbd "C-x t") 'textmate-goto-file) + (define-key ruby-mode-map (kbd "C-x C-t") 'textmate-goto-file) + (define-key ruby-mode-map (kbd "C-c C-l") 'goto-line) + (define-key ruby-mode-map (kbd "C-c C-b") 'eproject-ibuffer)) + +(add-hook 'ruby-mode-hook 'customizations-for-ruby-mode) ;; Set up hs-mode (HideShow) for Ruby (add-to-list 'hs-special-modes-alist diff --git a/mode-customizations/sh-mode.el b/mode-customizations/sh-mode.el index 9a771c2..b70121f 100644 --- a/mode-customizations/sh-mode.el +++ b/mode-customizations/sh-mode.el @@ -1,6 +1,8 @@ -(add-hook 'sh-mode-hook - (lambda () - (flyspell-prog-mode) - (linum-mode t) - (fci-mode) - (highlight-indentation-mode))) +(defun customizations-for-sh-mode () + (interactive) + (flyspell-prog-mode) + (linum-mode t) + (fci-mode) + (highlight-indentation-mode)) + +(add-hook 'sh-mode-hook 'customizations-for-sh-mode) diff --git a/mode-customizations/yaml-mode.el b/mode-customizations/yaml-mode.el index bfffce1..de7e1e7 100644 --- a/mode-customizations/yaml-mode.el +++ b/mode-customizations/yaml-mode.el @@ -2,12 +2,14 @@ (add-to-list 'auto-mode-alist '("\\.yaml$" . yaml-mode)) (add-to-list 'auto-mode-alist '("\\.yml\\.example$" . yaml-mode)) -(add-hook 'yaml-mode-hook - '(lambda () - (flyspell-prog-mode) - (linum-mode t) - (fci-mode) - (setq highlight-indentation-offset 2) - (highlight-indentation-mode) - (highlight-indentation-current-column-mode) - (define-key yaml-mode-map (kbd "RET") 'newline-and-indent))) +(defun customizations-for-yaml-mode () + (interactive) + (flyspell-prog-mode) + (linum-mode t) + (fci-mode) + (setq highlight-indentation-offset 2) + (highlight-indentation-mode) + (highlight-indentation-current-column-mode) + (define-key yaml-mode-map (kbd "RET") 'newline-and-indent)) + +(add-hook 'yaml-mode-hook 'customizations-for-yaml-mode)