summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2021-04-02 13:07:24 -0500
committerCase Duckworth2021-04-02 13:28:22 -0500
commitb649a257550f37ff7b0f96d417d4b80613141977 (patch)
tree04f09f59ba9751f788323223c7e4faa9e381faee
parentTweak elisp-mode settings (diff)
downloademacs-b649a257550f37ff7b0f96d417d4b80613141977.tar.gz
emacs-b649a257550f37ff7b0f96d417d4b80613141977.zip
Add `defun-with-hooks'
-rw-r--r--init.el17
-rw-r--r--lisp/acdw.el10
2 files changed, 25 insertions, 2 deletions
diff --git a/init.el b/init.el index 3756690..5d900ce 100644 --- a/init.el +++ b/init.el
@@ -101,10 +101,15 @@
101 word-wrap t 101 word-wrap t
102 truncate-lines nil) 102 truncate-lines nil)
103(add-hook 'text-mode-hook #'turn-on-auto-fill) 103(add-hook 'text-mode-hook #'turn-on-auto-fill)
104(add-hook 'prog-mode-hook #'turn-on-auto-fill)
105(global-display-fill-column-indicator-mode +1) 104(global-display-fill-column-indicator-mode +1)
106(global-so-long-mode +1) 105(global-so-long-mode +1)
107 106
107;; Only fill comments in prog-mode.
108(defun-with-hooks '(prog-mode)
109 (defun hook--auto-fill-prog-mode ()
110 (setq-local comment-auto-fill-only-comments t)
111 (turn-on-auto-fill)))
112
108;;;; Whitespace 113;;;; Whitespace
109(setc whitespace-style 114(setc whitespace-style
110 '(empty indentation space-before-tab space-after-tab) 115 '(empty indentation space-before-tab space-after-tab)
@@ -118,7 +123,6 @@
118 show-paren-style 'mixed 123 show-paren-style 'mixed
119 show-paren-when-point-inside-paren t 124 show-paren-when-point-inside-paren t
120 show-paren-when-point-in-periphery t) 125 show-paren-when-point-in-periphery t)
121(show-paren-mode +1)
122(add-hook 'prog-mode-hook #'electric-pair-local-mode) 126(add-hook 'prog-mode-hook #'electric-pair-local-mode)
123 127
124;;;; Killing and yanking 128;;;; Killing and yanking
@@ -371,6 +375,15 @@
371 w32-pass-apps-to-system nil 375 w32-pass-apps-to-system nil
372 w32-apps-modifier 'hyper)) 376 w32-apps-modifier 'hyper))
373 377
378;;;; Set up non-special modes
379;; Great idea from brause.cc
380(defun-with-hooks '(text-mode-hook prog-mode-hook diff-mode-hook)
381 (defun hook--setup-regular-modes ()
382 (setq indicate-empty-lines t
383 indicate-buffer-boundaries '((top . right) (bottom . right)))
384 (goto-address-mode +1)
385 (show-paren-mode +1)))
386
374;;;; Etc. good defaults 387;;;; Etc. good defaults
375(setc custom-file (acdw/in-dir "custom.el") 388(setc custom-file (acdw/in-dir "custom.el")
376 inhibit-startup-screen t 389 inhibit-startup-screen t
diff --git a/lisp/acdw.el b/lisp/acdw.el index 0203f3b..b127827 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -58,6 +58,16 @@ Ready for use with `after-focus-change-function'."
58 (run-at-time sunset-time (* 60 60 24) sunset-command) 58 (run-at-time sunset-time (* 60 60 24) sunset-command)
59 (run-at-time "12:00am" (* 60 60 24) sunset-command))) 59 (run-at-time "12:00am" (* 60 60 24) sunset-command)))
60 60
61;;;; Define a function and add it to hooks
62(defun defun-with-hooks (hooks function-def)
63 "Add FUNCTION-DEF to HOOKS.
64
65FUNCTION-DEF should be a `defun' form. This function is just to
66 put functions that only exist for hooks closer to the hooks
67 they bind to."
68 (let ((func function-def))
69 (dolist (hook hooks)
70 (add-hook hook func))))
61;;; Garbage collection hacks 71;;; Garbage collection hacks
62 72
63(defconst acdw/gc-cons-threshold-basis (* 800 1024) 73(defconst acdw/gc-cons-threshold-basis (* 800 1024)