From b649a257550f37ff7b0f96d417d4b80613141977 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 2 Apr 2021 13:07:24 -0500 Subject: Add `defun-with-hooks' --- init.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'init.el') diff --git a/init.el b/init.el index 3756690..5d900ce 100644 --- a/init.el +++ b/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 -- cgit 1.4.1-21-gabe81