From cf282408a3bca176391818f88d13faa52176502a Mon Sep 17 00:00:00 2001 From: Protesilaos Stavrou Date: Mon, 18 Dec 2023 09:53:18 +0200 Subject: [PATCH] prot-emacs.org: add the missing fontaine block that I accidentaly removed --- .../prot-emacs-modules/prot-emacs-theme.el | 112 +++++++++++++++++ emacs/.emacs.d/prot-emacs.org | 119 ++++++++++++++++++ 2 files changed, 231 insertions(+) diff --git a/emacs/.emacs.d/prot-emacs-modules/prot-emacs-theme.el b/emacs/.emacs.d/prot-emacs-modules/prot-emacs-theme.el index fe9702fc..cd99e7ad 100644 --- a/emacs/.emacs.d/prot-emacs-modules/prot-emacs-theme.el +++ b/emacs/.emacs.d/prot-emacs-modules/prot-emacs-theme.el @@ -161,4 +161,116 @@ (theme-buffet-timer-hours 1)) +;;;; Fontaine (font configurations) +;; Read the manual: +(prot-emacs-package fontaine + (:install t) + (:delay 1) + ;; This is defined in Emacs C code: it belongs to font settings. + (setq x-underline-at-descent-line nil) + + ;; And this is for Emacs28. + (setq-default text-scale-remap-header-line t) + + ;; This is the default value. Just including it here for + ;; completeness. + (setq fontaine-latest-state-file (locate-user-emacs-file "fontaine-latest-state.eld")) + + ;; Iosevka Comfy is my highly customised build of Iosevka with + ;; monospaced and duospaced (quasi-proportional) variants as well as + ;; support or no support for ligatures: + ;; . + ;; + ;; | Family | Shapes | Spacing | Style | Ligatures | + ;; |---------------------------------+--------+---------+------------+-----------| + ;; | Iosevka Comfy | Sans | Compact | Monospaced | Yes | + ;; | Iosevka Comfy Fixed | Sans | Compact | Monospaced | No | + ;; | Iosevka Comfy Duo | Sans | Compact | Duospaced | Yes | + ;; |---------------------------------+--------+---------+------------+-----------| + ;; | Iosevka Comfy Motion | Slab | Compact | Monospaced | Yes | + ;; | Iosevka Comfy Motion Fixed | Slab | Compact | Monospaced | No | + ;; | Iosevka Comfy Motion Duo | Slab | Compact | Duospaced | Yes | + ;; |---------------------------------+--------+---------+------------+-----------| + ;; | Iosevka Comfy Wide | Sans | Wide | Monospaced | Yes | + ;; | Iosevka Comfy Wide Fixed | Sans | Wide | Monospaced | No | + ;; | Iosevka Comfy Wide Duo | Sans | Wide | Duospaced | Yes | + ;; |---------------------------------+--------+---------+------------+-----------| + ;; | Iosevka Comfy Wide Motion | Slab | Wide | Monospaced | Yes | + ;; | Iosevka Comfy Wide Motion Fixed | Slab | Wide | Monospaced | No | + ;; | Iosevka Comfy Wide Motion Duo | Slab | Wide | Duospaced | Yes | + (setq fontaine-presets + '((small + :default-family "Iosevka Comfy Motion" + :default-height 80 + :variable-pitch-family "Iosevka Comfy Duo") + (regular) ; like this it uses all the fallback values and is named `regular' + (medium + :default-weight semilight + :default-height 115 + :bold-weight extrabold) + (large + :inherit medium + :default-height 150) + (presentation + :inherit medium + :default-weight light + :default-height 180) + (t + ;; I keep all properties for didactic purposes, but most can be + ;; omitted. See the fontaine manual for the technicalities: + ;; . + :default-family "Iosevka Comfy" + :default-weight regular + :default-height 100 + :fixed-pitch-family nil ; falls back to :default-family + :fixed-pitch-weight nil ; falls back to :default-weight + :fixed-pitch-height 1.0 + :fixed-pitch-serif-family nil ; falls back to :default-family + :fixed-pitch-serif-weight nil ; falls back to :default-weight + :fixed-pitch-serif-height 1.0 + :variable-pitch-family "Iosevka Comfy Motion Duo" + :variable-pitch-weight nil + :variable-pitch-height 1.0 + :bold-family nil ; use whatever the underlying face has + :bold-weight bold + :italic-family nil + :italic-slant italic + :line-spacing nil))) + + ;; Set last preset or fall back to desired style from `fontaine-presets'. + (fontaine-set-preset (or (fontaine-restore-latest-preset) 'regular)) + + ;; The other side of `fontaine-restore-latest-preset'. + (add-hook 'kill-emacs-hook #'fontaine-store-latest-preset) + + ;; Persist font configurations while switching themes. The + ;; `enable-theme-functions' is from Emacs 29. + (add-hook 'enable-theme-functions #'fontaine-apply-current-preset) + + (define-key global-map (kbd "C-c f") #'fontaine-set-preset) + (define-key global-map (kbd "C-c F") #'fontaine-set-face-font)) + +;;;;; `variable-pitch-mode' setup + +(prot-emacs-configure + (:delay 5) + (define-key ctl-x-x-map (kbd "v") #'variable-pitch-mode) + + ;; NOTE 2022-11-20: This may not cover every case, though it works + ;; fine in my workflow. I am still undecided by EWW. + (defun prot/enable-variable-pitch () + (unless (derived-mode-p 'mhtml-mode 'nxml-mode 'yaml-mode) + (variable-pitch-mode 1))) + + (defvar prot/enable-variable-pitch-in-hooks + '(text-mode-hook + notmuch-show-mode-hook + elfeed-show-mode-hook) + "List of hook symbols to add `prot/enable-variable-pitch' to.") + + (mapc + (lambda (hook) + (add-hook hook #'prot/enable-variable-pitch)) + prot/enable-variable-pitch-in-hooks)) + (provide 'prot-emacs-theme) diff --git a/emacs/.emacs.d/prot-emacs.org b/emacs/.emacs.d/prot-emacs.org index fcab863c..22e018c3 100644 --- a/emacs/.emacs.d/prot-emacs.org +++ b/emacs/.emacs.d/prot-emacs.org @@ -2072,6 +2072,125 @@ Bruno Boal is the lead developer and I am a co-maintainer. (theme-buffet-timer-hours 1)) #+end_src +*** The =prot-emacs-theme.el= section about ~fontaine~ +:PROPERTIES: +:CUSTOM_ID: h:cb41fef0-41a5-4a85-9552-496d96290258 +:END: + +#+begin_src emacs-lisp :tangle "prot-emacs-modules/prot-emacs-theme.el" +;;;; Fontaine (font configurations) +;; Read the manual: +(prot-emacs-package fontaine + (:install t) + (:delay 1) + ;; This is defined in Emacs C code: it belongs to font settings. + (setq x-underline-at-descent-line nil) + + ;; And this is for Emacs28. + (setq-default text-scale-remap-header-line t) + + ;; This is the default value. Just including it here for + ;; completeness. + (setq fontaine-latest-state-file (locate-user-emacs-file "fontaine-latest-state.eld")) + + ;; Iosevka Comfy is my highly customised build of Iosevka with + ;; monospaced and duospaced (quasi-proportional) variants as well as + ;; support or no support for ligatures: + ;; . + ;; + ;; | Family | Shapes | Spacing | Style | Ligatures | + ;; |---------------------------------+--------+---------+------------+-----------| + ;; | Iosevka Comfy | Sans | Compact | Monospaced | Yes | + ;; | Iosevka Comfy Fixed | Sans | Compact | Monospaced | No | + ;; | Iosevka Comfy Duo | Sans | Compact | Duospaced | Yes | + ;; |---------------------------------+--------+---------+------------+-----------| + ;; | Iosevka Comfy Motion | Slab | Compact | Monospaced | Yes | + ;; | Iosevka Comfy Motion Fixed | Slab | Compact | Monospaced | No | + ;; | Iosevka Comfy Motion Duo | Slab | Compact | Duospaced | Yes | + ;; |---------------------------------+--------+---------+------------+-----------| + ;; | Iosevka Comfy Wide | Sans | Wide | Monospaced | Yes | + ;; | Iosevka Comfy Wide Fixed | Sans | Wide | Monospaced | No | + ;; | Iosevka Comfy Wide Duo | Sans | Wide | Duospaced | Yes | + ;; |---------------------------------+--------+---------+------------+-----------| + ;; | Iosevka Comfy Wide Motion | Slab | Wide | Monospaced | Yes | + ;; | Iosevka Comfy Wide Motion Fixed | Slab | Wide | Monospaced | No | + ;; | Iosevka Comfy Wide Motion Duo | Slab | Wide | Duospaced | Yes | + (setq fontaine-presets + '((small + :default-family "Iosevka Comfy Motion" + :default-height 80 + :variable-pitch-family "Iosevka Comfy Duo") + (regular) ; like this it uses all the fallback values and is named `regular' + (medium + :default-weight semilight + :default-height 115 + :bold-weight extrabold) + (large + :inherit medium + :default-height 150) + (presentation + :inherit medium + :default-weight light + :default-height 180) + (t + ;; I keep all properties for didactic purposes, but most can be + ;; omitted. See the fontaine manual for the technicalities: + ;; . + :default-family "Iosevka Comfy" + :default-weight regular + :default-height 100 + :fixed-pitch-family nil ; falls back to :default-family + :fixed-pitch-weight nil ; falls back to :default-weight + :fixed-pitch-height 1.0 + :fixed-pitch-serif-family nil ; falls back to :default-family + :fixed-pitch-serif-weight nil ; falls back to :default-weight + :fixed-pitch-serif-height 1.0 + :variable-pitch-family "Iosevka Comfy Motion Duo" + :variable-pitch-weight nil + :variable-pitch-height 1.0 + :bold-family nil ; use whatever the underlying face has + :bold-weight bold + :italic-family nil + :italic-slant italic + :line-spacing nil))) + + ;; Set last preset or fall back to desired style from `fontaine-presets'. + (fontaine-set-preset (or (fontaine-restore-latest-preset) 'regular)) + + ;; The other side of `fontaine-restore-latest-preset'. + (add-hook 'kill-emacs-hook #'fontaine-store-latest-preset) + + ;; Persist font configurations while switching themes. The + ;; `enable-theme-functions' is from Emacs 29. + (add-hook 'enable-theme-functions #'fontaine-apply-current-preset) + + (define-key global-map (kbd "C-c f") #'fontaine-set-preset) + (define-key global-map (kbd "C-c F") #'fontaine-set-face-font)) + +;;;;; `variable-pitch-mode' setup + +(prot-emacs-configure + (:delay 5) + (define-key ctl-x-x-map (kbd "v") #'variable-pitch-mode) + + ;; NOTE 2022-11-20: This may not cover every case, though it works + ;; fine in my workflow. I am still undecided by EWW. + (defun prot/enable-variable-pitch () + (unless (derived-mode-p 'mhtml-mode 'nxml-mode 'yaml-mode) + (variable-pitch-mode 1))) + + (defvar prot/enable-variable-pitch-in-hooks + '(text-mode-hook + notmuch-show-mode-hook + elfeed-show-mode-hook) + "List of hook symbols to add `prot/enable-variable-pitch' to.") + + (mapc + (lambda (hook) + (add-hook hook #'prot/enable-variable-pitch)) + prot/enable-variable-pitch-in-hooks)) +#+end_src + *** The =prot-emacs-theme.el= call to ~provide~ :PROPERTIES: :CUSTOM_ID: h:bac0ce0a-db68-42e7-ba2c-f350f91f80ef