diff --git a/00.required-libraries.el b/00.required-libraries.el deleted file mode 100644 index 550e847..0000000 --- a/00.required-libraries.el +++ /dev/null @@ -1,28 +0,0 @@ -;;; init/00.required-libraries.el --- Misc utilities useful for init files -*- lexical-binding: t; -*- - -;;; Code: - -;; Allow me to declaratively hook things, automatically removing the hook when redefined. -(defmacro hook-mode (hook &rest modes) - "Hook each member of MODES on HOOK. -If the member is a symbol, call (member 1); if it is a list, just -execute it directly. This allows you to declaratively hook in -minor modes on a major mode." - (declare (indent 1)) - (let ((body (cl-loop for expr in modes - if (listp expr) - collect expr - else do (error "%s does not appear to name a minor mode" expr)))) - `(progn - ;; Prevent byte-compile errors when running elisp-check. - (defvar ,hook) - (hook-mode-attach ',hook (lambda () "Auto-generated by `hook-mode'" - ,@body))))) - -(defvar hook-mode-*hooks* (make-hash-table :test #'eq)) -(defun hook-mode-attach (hook function) - "Attach FUNCTION to HOOK." - (when (gethash hook hook-mode-*hooks*) - (remove-hook hook (gethash hook hook-mode-*hooks*))) - (add-hook hook function) - (setf (gethash hook hook-mode-*hooks*) function)) diff --git a/c.el b/c.el index b81b756..9f85e5c 100644 --- a/c.el +++ b/c.el @@ -2,26 +2,27 @@ ;;; Code: (defvar c-mode-common-hook) -(hook-mode c-mode-common-hook - (visual-line-mode) - (c-set-offset 'case-label '+) - (c-set-offset 'innamespace 0) - (c-set-offset 'arglist-intro '++) - (c-set-offset 'member-init-intro '++) - (c-set-offset 'cpp-macro 0) - (c-set-offset 'statement-case-open '+) - (when (fboundp 'cscope-bind-keys-3deep) (cscope-bind-keys-3deep)) +(add-hook 'c-mode-common-hook + (defun my-c-mode-common-hook () + (visual-line-mode) + (c-set-offset 'case-label '+) + (c-set-offset 'innamespace 0) + (c-set-offset 'arglist-intro '++) + (c-set-offset 'member-init-intro '++) + (c-set-offset 'cpp-macro 0) + (c-set-offset 'statement-case-open '+) + (when (fboundp 'cscope-bind-keys-3deep) (cscope-bind-keys-3deep)) - ;; Special comment syntax - (font-lock-add-keywords nil '(("^\\s *\\(///.*\n?\\)" 1 'section-comment-face t) - ("^////.*\n?" 0 'file-comment-face t) - ("^//.*\\(\\s_\\|\\s.\\)\\1\\1\\1.*\n?\\(?://.*\n\\)+" 0 'section-comment-face t) - ("^/\\*.*\\(\\s_\\|\\s.\\)\\1\\1\\1.*\n?\\(?:.\\|\n\\)*?\\*/\n?" 0 'section-comment-face t))) - (setf font-lock-multiline t) - - (setf beginning-of-defun-function 'my-c-beginning-of-defun) + ;; Special comment syntax + (font-lock-add-keywords nil '(("^\\s *\\(///.*\n?\\)" 1 'section-comment-face t) + ("^////.*\n?" 0 'file-comment-face t) + ("^//.*\\(\\s_\\|\\s.\\)\\1\\1\\1.*\n?\\(?://.*\n\\)+" 0 'section-comment-face t) + ("^/\\*.*\\(\\s_\\|\\s.\\)\\1\\1\\1.*\n?\\(?:.\\|\n\\)*?\\*/\n?" 0 'section-comment-face t))) + (setf font-lock-multiline t) + + (setf beginning-of-defun-function 'my-c-beginning-of-defun) - (require 'ebrowse)) + (require 'ebrowse))) (setf (default-value 'c-recognize-knr-p) nil (default-value 'c-recognize-paren-inits) t diff --git a/dired.el b/dired.el index 4515fd6..38eec16 100644 --- a/dired.el +++ b/dired.el @@ -2,10 +2,11 @@ ;;; Code: (declare-function dired-icon-mode "dired-icon") -(hook-mode dired-mode-hook - (when window-system - (dired-icon-mode 1)) - (setq-local truncate-lines t)) +(add-hook 'dired-mode-hook + (defun my-dired-mode-hook () + (when window-system + (dired-icon-mode 1)) + (setq-local truncate-lines t))) ;; Force use of LS emulation as it enables all my other customizations (require 'ls-lisp) diff --git a/elisp.el b/elisp.el index 3ace0b9..b6d31de 100644 --- a/elisp.el +++ b/elisp.el @@ -1,11 +1,13 @@ ;;; init/elisp.el --- Emacs Lisp customizations -*- lexical-binding: t; -*- ;;; Code: -(hook-mode emacs-lisp-mode-hook - (eldoc-mode)) +(add-hook 'emacs-lisp-mode-hook + (defun my-emacs-lisp-mode-hook () + (eldoc-mode))) (defvar ielm-mode-hook) -(hook-mode ielm-mode-hook - (eldoc-mode)) +(add-hook 'ielm-mode-hook + (defun my-ielm-mode-hook () + (eldoc-mode))) ;;; Faces: (font-lock-add-keywords 'emacs-lisp-mode diff --git a/emacs.el b/emacs.el index d35607e..1696003 100644 --- a/emacs.el +++ b/emacs.el @@ -117,9 +117,10 @@ (add-to-list 'completion-ignored-extensions ".meta") ;; Customize the *scratch* buffer -(hook-mode emacs-startup-hook - (with-current-buffer (get-buffer "*scratch*") - (setf buffer-offer-save t))) +(add-hook 'emacs-startup-hook + (defun my-emacs-startup-hook () + (with-current-buffer (get-buffer "*scratch*") + (setf buffer-offer-save t)))) (setf initial-major-mode 'gfm-mode initial-scratch-message (concat "Scratch buffer for notes\n" "========================\n" diff --git a/hexl.el b/hexl.el index 70caeb5..d5477ca 100644 --- a/hexl.el +++ b/hexl.el @@ -2,11 +2,12 @@ ;;; Code: (with-eval-after-load 'hexl - (hook-mode hexl-mode-hook - (hexl-follow-line) - (hexl-activate-ruler) - (turn-on-eldoc-mode) - (setf truncate-lines t))) + (add-hook 'hexl-mode-hook + (defun my-hexl-mode-hook () + (hexl-follow-line) + (hexl-activate-ruler) + (turn-on-eldoc-mode) + (setf truncate-lines t)))) ;;; Custom commands: (with-eval-after-load 'hexl diff --git a/lisp.el b/lisp.el index ecfbbee..6745c74 100644 --- a/lisp.el +++ b/lisp.el @@ -1,16 +1,16 @@ ;;; init/lisp.el --- (Common) Lisp customizations -*- lexical-binding: t; -*- ;;; Code: -(hook-mode lisp-mode-hook - (make-variable-buffer-local 'browse-url-browser-function) - (setf browse-url-browser-function 'w3m) - (font-lock-add-keywords nil '(("^\\s *;;;.*\n?" (0 'section-comment-face t)) - ("^;;;;.*\n?" (0 'file-comment-face t)))) +(add-hook 'lisp-mode-hook + (defun my-lisp-mode-hook () + (make-variable-buffer-local 'browse-url-browser-function) + (setf browse-url-browser-function 'w3m) + (font-lock-add-keywords nil '(("^\\s *;;;.*\n?" (0 'section-comment-face t)) + ("^;;;;.*\n?" (0 'file-comment-face t)))) - (require 'slime) - (setf inferior-lisp-program "sbcl") - (slime-setup)) -(cl-pushnew '("\\.asd\\'" . lisp-mode) auto-mode-alist :test #'equal) + (require 'slime) + (setf inferior-lisp-program "sbcl") + (slime-setup))) ;;; Keymaps: (keymap-set lisp-mode-map "C-" (lambda () (interactive) diff --git a/text.el b/text.el index 48d3605..328ea99 100644 --- a/text.el +++ b/text.el @@ -1,16 +1,18 @@ ;;; init/text.el --- Text mode customizations -*- lexical-binding: t; -*- ;;; Code: -(hook-mode text-mode-hook - (unless (member major-mode '(mail-mode org-mode)) - visual-line-mode)) +(add-hook 'text-mode-hook + (defun my-text-mode-hook () + (unless (member major-mode '(mail-mode org-mode)) + visual-line-mode))) -(hook-mode markdown-mode-hook - ;; Normally, electric pair mode is on and helpful, but in Markdown - ;; mode it makes URLs be automatically hidden before they're typed - ;; in. - (electric-pair-local-mode -1) - (markdown-toggle-markup-hiding 1)) +(add-hook 'markdown-mode-hook + (defun my-markdown-mode-hook () + ;; Normally, electric pair mode is on and helpful, but in + ;; Markdown mode it makes URLs be automatically hidden + ;; before they're typed in. + (electric-pair-local-mode -1) + (markdown-toggle-markup-hiding 1))) ;; Actually, I prefer GitHub flavored markdown (add-to-list 'major-mode-remap-alist '(markdown-mode . gfm-mode)) diff --git a/xml.el b/xml.el index 13023d1..7976d93 100644 --- a/xml.el +++ b/xml.el @@ -4,7 +4,8 @@ (add-to-list 'major-mode-remap-alist '(xml-mode . nxml-mode)) (add-to-list 'major-mode-remap-alist '(mhtml-mode . nxml-mode)) -(hook-mode nxml-mode-hook - ;; key bindings - (keymap-local-set "M-" 'nxml-backward-up-element) - (keymap-local-set "M-" 'nxml-down-element)) +(add-hook 'nxml-mode-hook + (defun my-nxml-mode-hook () + ;; key bindings + (keymap-local-set "M-" 'nxml-backward-up-element) + (keymap-local-set "M-" 'nxml-down-element)))