From 32959ca977b7b05bcbeef14c559de85ba7838243 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 19 May 2021 12:37:57 -0500 Subject: Add variable-pitch-mode in Org and Info --- lisp/acdw-fonts.el | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'lisp') 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." (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 -- cgit 1.4.1-21-gabe81