Skip to content

Commit

Permalink
Removing hook-mode' macro. It's only slightly nicer than calling ad…
Browse files Browse the repository at this point in the history
…d-hook' directly.
  • Loading branch information
chaosemer committed Jan 7, 2025
1 parent 7c8ee4c commit 5753242
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 84 deletions.
28 changes: 0 additions & 28 deletions 00.required-libraries.el

This file was deleted.

37 changes: 19 additions & 18 deletions c.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions dired.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions elisp.el
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 4 additions & 3 deletions emacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 6 additions & 5 deletions hexl.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions lisp.el
Original file line number Diff line number Diff line change
@@ -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-<down-mouse-3>" (lambda () (interactive)
Expand Down
20 changes: 11 additions & 9 deletions text.el
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
9 changes: 5 additions & 4 deletions xml.el
Original file line number Diff line number Diff line change
Expand Up @@ -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-<up>" 'nxml-backward-up-element)
(keymap-local-set "M-<down>" 'nxml-down-element))
(add-hook 'nxml-mode-hook
(defun my-nxml-mode-hook ()
;; key bindings
(keymap-local-set "M-<up>" 'nxml-backward-up-element)
(keymap-local-set "M-<down>" 'nxml-down-element)))

0 comments on commit 5753242

Please sign in to comment.