diff --git a/starter-kit-defuns.el b/starter-kit-defuns.el index 1a32f6d..38ea365 100644 --- a/starter-kit-defuns.el +++ b/starter-kit-defuns.el @@ -62,18 +62,30 @@ Symbols matching the text at point are put first in the completion list." (position (cdr (assoc selected-symbol name-and-pos)))) (goto-char position)))) -(defun coding-hook () - "Enable things that are convenient across all coding buffers." - (set (make-local-variable 'comment-auto-fill-only-comments) t) +;;; These belong in coding-hook: + +(defun local-column-number-mode () (make-local-variable 'column-number-mode) - (column-number-mode t) - (setq save-place t) - (auto-fill-mode) ;; in comments only - (if window-system (hl-line-mode t)) - (pretty-lambdas) - ;; TODO: this breaks in js2-mode! - ;;(if (functionp 'idle-highlight) (idle-highlight)) - ) + (column-number-mode t)) + +(defun local-comment-auto-fill () + (set (make-local-variable 'comment-auto-fill-only-comments) t) + (auto-fill-mode t)) + +(defun turn-on-hl-line-mode () + (if window-system (hl-line-mode t))) + +(defun turn-on-save-place-mode () + (setq save-place t)) + +(add-hook 'coding-hook 'local-column-number-mode) +(add-hook 'coding-hook 'local-comment-auto-fill) +(add-hook 'coding-hook 'turn-on-hl-line-mode) +(add-hook 'coding-hook 'pretty-lambdas) + +(defun run-coding-hook () + "Enable things that are convenient across all coding buffers." + (run-hooks coding-hook)) (defun untabify-buffer () (interactive) diff --git a/starter-kit-js.el b/starter-kit-js.el index b67f3e5..46ac146 100644 --- a/starter-kit-js.el +++ b/starter-kit-js.el @@ -20,7 +20,7 @@ (defun js-lambda () (interactive) (insert "function () {\n}") (backward-char 5)) - (add-hook 'js2-mode-hook 'coding-hook) + (add-hook 'js2-mode-hook 'run-coding-hook) (define-key js2-mode-map (kbd "C-c l") 'js-lambda) (define-key js2-mode-map "\C-\M-h" 'backward-kill-word) diff --git a/starter-kit-lisp.el b/starter-kit-lisp.el index 8a81bc6..d2b7d35 100644 --- a/starter-kit-lisp.el +++ b/starter-kit-lisp.el @@ -25,9 +25,10 @@ ;;; Emacs Lisp -(add-hook 'emacs-lisp-mode-hook 'eldoc-mode) -(add-hook 'emacs-lisp-mode-hook 'coding-hook) +(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode) +(add-hook 'emacs-lisp-mode-hook 'run-coding-hook) (add-hook 'emacs-lisp-mode-hook 'esk-remove-elc-on-save) +(add-hook 'emacs-lisp-mode-hook 'idle-highlight) (defun esk-remove-elc-on-save () "If you're saving an elisp file, likely the .elc is no longer valid." @@ -42,7 +43,9 @@ ;;; Clojure -(add-hook 'clojure-mode-hook 'coding-hook) +(add-hook 'clojure-mode-hook 'run-coding-hook) +(add-hook 'clojure-mode-hook 'idle-highlight) + (font-lock-add-keywords 'clojure-mode '(("(\\|)" . 'esk-paren-face))) @@ -51,13 +54,15 @@ ;;; Scheme -(add-hook 'scheme-mode-hook 'coding-hook) +(add-hook 'scheme-mode-hook 'run-coding-hook) +(add-hook 'scheme-mode-hook 'idle-highlight) (font-lock-add-keywords 'scheme-mode '(("(\\|)" . 'esk-paren-face))) ;;; Common Lisp -(add-hook 'lisp-mode-hook 'coding-hook) +(add-hook 'lisp-mode-hook 'run-coding-hook) +(add-hook 'lisp-mode-hook 'idle-highlight) (font-lock-add-keywords 'lisp-mode '(("(\\|)" . 'esk-paren-face))) diff --git a/starter-kit-misc.el b/starter-kit-misc.el index 2ccbed9..9bb02b4 100644 --- a/starter-kit-misc.el +++ b/starter-kit-misc.el @@ -71,6 +71,9 @@ (add-hook 'text-mode-hook 'turn-on-auto-fill) (add-hook 'text-mode-hook 'turn-on-flyspell) +(defvar coding-hook nil + "Hook that gets run on activation of any programming mode.") + (defalias 'yes-or-no-p 'y-or-n-p) (random t) ;; Seed the random-number generator diff --git a/starter-kit-ruby.el b/starter-kit-ruby.el index 35531cd..bf16f9a 100644 --- a/starter-kit-ruby.el +++ b/starter-kit-ruby.el @@ -52,7 +52,8 @@ exec-to-string command, but it works and seems fast" (delete-region (point-min) (point-max)))))) (ad-activate 'ruby-do-run-w/compilation))) -(add-hook 'ruby-mode-hook 'coding-hook) +(add-hook 'ruby-mode-hook 'run-coding-hook) +(add-hook 'ruby-mode-hook 'idle-highlight) ;;; Flymake