Skip to content

Commit

Permalink
Make coding-hook a real hook instead of a defun.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Mar 11, 2009
1 parent cd73bce commit b2ffdf1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 18 deletions.
34 changes: 23 additions & 11 deletions starter-kit-defuns.el
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion starter-kit-js.el
Expand Up @@ -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)
Expand Down
15 changes: 10 additions & 5 deletions starter-kit-lisp.el
Expand Up @@ -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."
Expand All @@ -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)))

Expand All @@ -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)))

Expand Down
3 changes: 3 additions & 0 deletions starter-kit-misc.el
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion starter-kit-ruby.el
Expand Up @@ -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

Expand Down

0 comments on commit b2ffdf1

Please sign in to comment.