branch: externals/logos commit 59ed10c263c160229e6596f22e90c7a5bf8e29fb Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Revise how fringe is updated (amend bfab7c9) The problem with the previous commit was that it (i) did not apply to all buffers, (ii) was not scoped by logos-focus-mode so it caused unwanted side-effects. --- README.org | 9 ++++----- logos.el | 14 ++++++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.org b/README.org index e844d95a48..35b4f84e14 100644 --- a/README.org +++ b/README.org @@ -490,12 +490,12 @@ it remaps its background color to be the same as that of the ~default~ face. For example, if the main background is white while the fringe is gray, the fringe will become white as well. -#+findex: logos-update-fringe-color-post-theme-load +#+findex: logos-update-fringe-in-buffers The problem with this approach is that the color is not automatically updated upon switching to a new theme, such as by toggling between one with a light background to another with a dark one. The solution is to -assign the ~logos-update-fringe-color-post-theme-load~ function to a -hook that is triggered by the theme-loading operation. +assign the ~logos-update-fringe-in-buffers~ function to a hook that is +triggered by the theme-loading operation. Some themes provide such a hook. For example, the =modus-themes= package has the ~modus-themes-after-load-theme-hook~ (the themes @@ -503,8 +503,7 @@ package has the ~modus-themes-after-load-theme-hook~ (the themes higher). #+begin_src emacs-lisp -(add-hook 'modus-themes-after-load-theme-hook - #'logos-update-fringe-color-post-theme-load) +(add-hook 'modus-themes-after-load-theme-hook #'logos-update-fringe-in-buffers) #+end_src A user-defined, theme-agnostic setup for such a hook can be configured diff --git a/logos.el b/logos.el index 4b0e92100b..8ace6a8cad 100644 --- a/logos.el +++ b/logos.el @@ -443,8 +443,15 @@ options: `logos-scroll-lock', `logos-variable-pitch', (when logos--fringe-remap-cookie (face-remap-remove-relative logos--fringe-remap-cookie))) -(defun logos-update-fringe-color-post-theme-load () - "Recalculate the remapped fringe color. +(defun logos--update-fringe (buffer) + "Update fringe in current BUFFER." + (with-current-buffer buffer + (when logos-focus-mode + (logos--remove-fringe-remap) + (logos--hide-fringe)))) + +(defun logos-update-fringe-in-buffers () + "Run `logos--update-fringe' through the `buffer-list'. This is only relevant if the user option `logos-hide-fringe' is non-nil and the `logos-focus-mode' is enabled. @@ -452,8 +459,7 @@ Bind this function to a hook that runs at the post theme load phase. For example: `modus-themes-after-load-theme-hook' from the `modus-themes' (`modus-operandi' and `modus-vivendi' themes are built into Emacs)." - (logos--remove-fringe-remap) - (logos--hide-fringe)) + (mapc #'logos--update-fringe (buffer-list))) (provide 'logos) ;;; logos.el ends here