Add `defun-with-hooks'
This commit is contained in:
parent
437f89ef31
commit
b649a25755
17
init.el
17
init.el
|
@ -101,10 +101,15 @@
|
|||
word-wrap t
|
||||
truncate-lines nil)
|
||||
(add-hook 'text-mode-hook #'turn-on-auto-fill)
|
||||
(add-hook 'prog-mode-hook #'turn-on-auto-fill)
|
||||
(global-display-fill-column-indicator-mode +1)
|
||||
(global-so-long-mode +1)
|
||||
|
||||
;; Only fill comments in prog-mode.
|
||||
(defun-with-hooks '(prog-mode)
|
||||
(defun hook--auto-fill-prog-mode ()
|
||||
(setq-local comment-auto-fill-only-comments t)
|
||||
(turn-on-auto-fill)))
|
||||
|
||||
;;;; Whitespace
|
||||
(setc whitespace-style
|
||||
'(empty indentation space-before-tab space-after-tab)
|
||||
|
@ -118,7 +123,6 @@
|
|||
show-paren-style 'mixed
|
||||
show-paren-when-point-inside-paren t
|
||||
show-paren-when-point-in-periphery t)
|
||||
(show-paren-mode +1)
|
||||
(add-hook 'prog-mode-hook #'electric-pair-local-mode)
|
||||
|
||||
;;;; Killing and yanking
|
||||
|
@ -371,6 +375,15 @@
|
|||
w32-pass-apps-to-system nil
|
||||
w32-apps-modifier 'hyper))
|
||||
|
||||
;;;; Set up non-special modes
|
||||
;; Great idea from brause.cc
|
||||
(defun-with-hooks '(text-mode-hook prog-mode-hook diff-mode-hook)
|
||||
(defun hook--setup-regular-modes ()
|
||||
(setq indicate-empty-lines t
|
||||
indicate-buffer-boundaries '((top . right) (bottom . right)))
|
||||
(goto-address-mode +1)
|
||||
(show-paren-mode +1)))
|
||||
|
||||
;;;; Etc. good defaults
|
||||
(setc custom-file (acdw/in-dir "custom.el")
|
||||
inhibit-startup-screen t
|
||||
|
|
10
lisp/acdw.el
10
lisp/acdw.el
|
@ -58,6 +58,16 @@ Ready for use with `after-focus-change-function'."
|
|||
(run-at-time sunset-time (* 60 60 24) sunset-command)
|
||||
(run-at-time "12:00am" (* 60 60 24) sunset-command)))
|
||||
|
||||
;;;; Define a function and add it to hooks
|
||||
(defun defun-with-hooks (hooks function-def)
|
||||
"Add FUNCTION-DEF to HOOKS.
|
||||
|
||||
FUNCTION-DEF should be a `defun' form. This function is just to
|
||||
put functions that only exist for hooks closer to the hooks
|
||||
they bind to."
|
||||
(let ((func function-def))
|
||||
(dolist (hook hooks)
|
||||
(add-hook hook func))))
|
||||
;;; Garbage collection hacks
|
||||
|
||||
(defconst acdw/gc-cons-threshold-basis (* 800 1024)
|
||||
|
|
Loading…
Reference in New Issue