branch: externals/fontaine
commit 6b5862891aba9dccddf315c90c1a5a72a0875cd3
Author: Protesilaos Stavrou <i...@protesilaos.com>
Commit: Protesilaos Stavrou <i...@protesilaos.com>

    Update documentation and sample configuration
---
 README.org  | 29 +++++++++++++++++++++++++++--
 fontaine.el | 22 +++++++++++++++++++---
 2 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/README.org b/README.org
index 71b826bf38..9146c42610 100644
--- a/README.org
+++ b/README.org
@@ -122,8 +122,18 @@ command is for interactive use only and is supposed to be 
used for
 previewing certain styles before eventually codifying them as presets.
 
 Changing the ~bold~ and ~italic~ faces only has a noticeable effect if
-the underlying does not hardcode a weight and slant but inherits from
-those faces instead (e.g. the ~modus-themes~).
+the underlying theme does not hardcode a weight and slant but inherits
+from those faces instead (e.g. the ~modus-themes~).
+
+#+vindex: fontaine-latest-state-file
+#+findex: fontaine-store-latest-preset
+#+findex: fontaine-restore-latest-preset
+The latest value of ~fontaine-set-preset~ is stored in a file whose
+location is defined in ~fontaine-latest-state-file~.  Saving is done by
+the ~fontaine-store-latest-preset~ function, which should be assigned to
+a hook (e.g. ~kill-emacs-hook~).  To restore that value, the user can
+call the function ~fontaine-restore-latest-preset~ (such as by adding it
+to their init file).
 
 As for the name of this package, it is the French word for "fountain"
 which, in turn, is what the font or source is.  However, I will not
@@ -189,6 +199,9 @@ Remember to read the relevant doc strings.
 #+begin_src emacs-lisp
 (require 'fontaine)
 
+(setq fontaine-latest-state-file
+      (locate-user-emacs-file "fontaine-latest-state.eld"))
+
 (setq fontaine-presets
       '((regular
          :default-family "Hack"
@@ -221,11 +234,23 @@ Remember to read the relevant doc strings.
          :italic-slant italic
          :line-spacing 1)))
 
+(fontaine-restore-latest-preset)
+
+;; Use `fontaine-recovered-preset' if available, else fall back to the
+;; desired style from `fontaine-presets'.
+(if-let ((state fontaine-recovered-preset))
+    (fontaine-set-preset state)
+  (fontaine-set-preset 'regular))
+
+;; The other side of `fontaine-restore-latest-preset'.
+(add-hook 'kill-emacs-hook #'fontaine-store-latest-preset)
+
 ;; fontaine does not define any key bindings.  This is just a sample that
 ;; respects the key binding conventions.  Evaluate:
 ;;
 ;;     (info "(elisp) Key Binding Conventions")
 (define-key global-map (kbd "C-c f") #'fontaine-set-preset)
+(define-key global-map (kbd "C-c F") #'fontaine-set-face-font)
 #+end_src
 
 * GNU Free Documentation License
diff --git a/fontaine.el b/fontaine.el
index 172e8314e8..695a300823 100644
--- a/fontaine.el
+++ b/fontaine.el
@@ -72,6 +72,17 @@
 ;; command is for interactive use only and is supposed to be used for
 ;; previewing certain styles before eventually codifying them as presets.
 ;;
+;; Changing the `bold' and `italic' faces only has a noticeable effect if
+;; the underlying theme does not hardcode a weight and slant but inherits
+;; from those faces instead (e.g. the `modus-themes').
+;;
+;; The latest value of `fontaine-set-preset' is stored in a file whose
+;; location is defined in `fontaine-latest-state-file'.  Saving is done by
+;; the `fontaine-store-latest-preset' function, which should be assigned to
+;; a hook (e.g. `kill-emacs-hook').  To restore that value, the user can
+;; call the function `fontaine-restore-latest-preset' (such as by adding it
+;; to their init file).
+;;
 ;; As for the name of this package, it is the French word for "fountain"
 ;; which, in turn, is what the font or source is.  However, I will not
 ;; blame you if you can only interpret it as a descriptive acronym: FONTs
@@ -224,8 +235,12 @@ Use the desired preset with the command 
`fontaine-set-preset'."
 
 (defcustom fontaine-latest-state-file
   (locate-user-emacs-file "fontaine-latest-state.eld")
-  "File to save the value of `fontaine-set-preset'.
-Saving is done by the `fontaine-store-latest-preset' function."
+  "File to save the latest value of `fontaine-set-preset'.
+Saving is done by the `fontaine-store-latest-preset' function,
+which should be assigned to a hook (e.g. `kill-emacs-hook').
+
+This is then used to restore the last value with the function
+`fontaine-restore-latest-preset'."
   :type 'file
   :group 'fontaine)
 
@@ -506,7 +521,8 @@ Can be assigned to `kill-emacs-hook'."
 
 ;;;###autoload
 (defun fontaine-restore-latest-preset ()
-  "Restore latest preset set by `fontaine-set-preset'."
+  "Restore latest preset set by `fontaine-set-preset'.
+The value is stored in `fontaine-latest-state-file'."
   (when-let* ((file fontaine-latest-state-file)
               ((file-exists-p file)))
     (setq fontaine-recovered-preset

Reply via email to