Add variable-pitch-mode in Org and Info

This commit is contained in:
Case Duckworth 2021-05-19 12:37:57 -05:00
parent 3eeb9fb1a1
commit 32959ca977
2 changed files with 56 additions and 1 deletions

12
init.el
View File

@ -365,6 +365,9 @@
(setup imenu
(:option imenu-auto-rescan t))
(setup Info
(:hook variable-pitch-mode))
(setup isearch
(:option search-default-mode t))
@ -578,6 +581,9 @@
uniquify-after-kill-buffer-p t
uniquify-ignore-buffers-re "^\\*"))
(setup variable-pitch-mode
(:hook acdw-fonts/adapt-variable-pitch))
(setup view
(:option view-read-only t)
@ -936,7 +942,11 @@ if ripgrep is installed, otherwise `consult-grep'."
(:bind "RET" acdw-org/return-dwim
"<S-return>" acdw-org/org-table-copy-down)
(add-hook 'before-save-hook #'acdw-org/fix-blank-lines-in-buffer)
(defun acdw/org-fix-lines-before-save ()
(add-hook 'before-save-hook #'acdw-org/fix-blank-lines-in-buffer 0 :local))
(:hook variable-pitch-mode
acdw/org-fix-lines-before-save)
(advice-add 'org-delete-backward-char
:override #'acdw-org/delete-backward-char))

View File

@ -127,5 +127,50 @@ This is for emoji fonts."
(set-fontset-font t 'symbol
(font-spec :family font) nil 'append)))))
;;; Variable-pitch
;; from https://github.com/turbana/emacs-config#variable-pitch
(defcustom acdw-fonts/fixed-pitch-faces '(linum
org-block
org-block-begin-line
org-block-end-line
org-checkbox
org-code
org-date
org-document-info-keyword
org-hide
org-indent
org-link
org-meta-line
org-special-keyword
org-table
whitespace-space)
"Faces to keep fixed-pitch in `acdw/variable-pitch-mode'."
:type 'sexp
:group 'faces)
(defun acdw-fonts//variable-pitch-add-inherit (attrs parent)
"Add `:inherit PARENT' to ATTRS unless already present.
Handles cases where `:inherit' is already specified."
(let ((current-parent (plist-get attrs :inherit)))
(unless (or (eq parent current-parent)
(and (listp current-parent)
(member parent current-parent)))
(plist-put attrs :inherit (if current-parent
(list current-parent parent)
parent)))))
(defun acdw-fonts/adapt-variable-pitch ()
"Adapt `variable-pitch-mode' to keep some fonts fixed-pitch."
(when variable-pitch-mode
(mapc (lambda (face)
(when (facep face)
(apply #'set-face-attribute
face nil (acdw-fonts//variable-pitch-add-inherit
(face-attr-construct face)
'fixed-pitch))))
acdw-fonts/fixed-pitch-faces)))
(provide 'acdw-fonts)
;;; acdw-fonts.el ends here