summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2021-05-19 12:37:57 -0500
committerCase Duckworth2021-05-19 12:37:57 -0500
commit32959ca977b7b05bcbeef14c559de85ba7838243 (patch)
tree8ce2b32232a1aab6001b1f619cc44172d14e7872
parentChange `browse-url-browser-function' to alist (diff)
downloademacs-32959ca977b7b05bcbeef14c559de85ba7838243.tar.gz
emacs-32959ca977b7b05bcbeef14c559de85ba7838243.zip
Add variable-pitch-mode in Org and Info
-rw-r--r--init.el12
-rw-r--r--lisp/acdw-fonts.el45
2 files changed, 56 insertions, 1 deletions
diff --git a/init.el b/init.el index d20e1ac..a6e29a4 100644 --- a/init.el +++ b/init.el
@@ -365,6 +365,9 @@
365(setup imenu 365(setup imenu
366 (:option imenu-auto-rescan t)) 366 (:option imenu-auto-rescan t))
367 367
368(setup Info
369 (:hook variable-pitch-mode))
370
368(setup isearch 371(setup isearch
369 (:option search-default-mode t)) 372 (:option search-default-mode t))
370 373
@@ -578,6 +581,9 @@
578 uniquify-after-kill-buffer-p t 581 uniquify-after-kill-buffer-p t
579 uniquify-ignore-buffers-re "^\\*")) 582 uniquify-ignore-buffers-re "^\\*"))
580 583
584(setup variable-pitch-mode
585 (:hook acdw-fonts/adapt-variable-pitch))
586
581(setup view 587(setup view
582 (:option view-read-only t) 588 (:option view-read-only t)
583 589
@@ -936,7 +942,11 @@ if ripgrep is installed, otherwise `consult-grep'."
936 (:bind "RET" acdw-org/return-dwim 942 (:bind "RET" acdw-org/return-dwim
937 "<S-return>" acdw-org/org-table-copy-down) 943 "<S-return>" acdw-org/org-table-copy-down)
938 944
939 (add-hook 'before-save-hook #'acdw-org/fix-blank-lines-in-buffer) 945 (defun acdw/org-fix-lines-before-save ()
946 (add-hook 'before-save-hook #'acdw-org/fix-blank-lines-in-buffer 0 :local))
947
948 (:hook variable-pitch-mode
949 acdw/org-fix-lines-before-save)
940 950
941 (advice-add 'org-delete-backward-char 951 (advice-add 'org-delete-backward-char
942 :override #'acdw-org/delete-backward-char)) 952 :override #'acdw-org/delete-backward-char))
diff --git a/lisp/acdw-fonts.el b/lisp/acdw-fonts.el index 6c0cb8d..1b73af7 100644 --- a/lisp/acdw-fonts.el +++ b/lisp/acdw-fonts.el
@@ -127,5 +127,50 @@ This is for emoji fonts."
127 (set-fontset-font t 'symbol 127 (set-fontset-font t 'symbol
128 (font-spec :family font) nil 'append))))) 128 (font-spec :family font) nil 'append)))))
129 129
130
131;;; Variable-pitch
132;; from https://github.com/turbana/emacs-config#variable-pitch
133
134(defcustom acdw-fonts/fixed-pitch-faces '(linum
135 org-block
136 org-block-begin-line
137 org-block-end-line
138 org-checkbox
139 org-code
140 org-date
141 org-document-info-keyword
142 org-hide
143 org-indent
144 org-link
145 org-meta-line
146 org-special-keyword
147 org-table
148 whitespace-space)
149 "Faces to keep fixed-pitch in `acdw/variable-pitch-mode'."
150 :type 'sexp
151 :group 'faces)
152
153(defun acdw-fonts//variable-pitch-add-inherit (attrs parent)
154 "Add `:inherit PARENT' to ATTRS unless already present.
155Handles cases where `:inherit' is already specified."
156 (let ((current-parent (plist-get attrs :inherit)))
157 (unless (or (eq parent current-parent)
158 (and (listp current-parent)
159 (member parent current-parent)))
160 (plist-put attrs :inherit (if current-parent
161 (list current-parent parent)
162 parent)))))
163
164(defun acdw-fonts/adapt-variable-pitch ()
165 "Adapt `variable-pitch-mode' to keep some fonts fixed-pitch."
166 (when variable-pitch-mode
167 (mapc (lambda (face)
168 (when (facep face)
169 (apply #'set-face-attribute
170 face nil (acdw-fonts//variable-pitch-add-inherit
171 (face-attr-construct face)
172 'fixed-pitch))))
173 acdw-fonts/fixed-pitch-faces)))
174
130(provide 'acdw-fonts) 175(provide 'acdw-fonts)
131;;; acdw-fonts.el ends here 176;;; acdw-fonts.el ends here