Subject: bug#54598: 27.2; Bad interraction between modus-theme and hs-minor-mode

From: Pierre Téchoueyres <[email-masked]>
Date: Sun, 27 Mar 2022 18:17:17 +0200

Hi everybody,

I'm facing a strange behaviour.  With the following receipe I'm 
unable
to go to to the end of buffer with C-End (nor with M-x 
end-of-buffer).

First You should have modus installed from elpa somewhere. I've 
mine in
~/.emacs.d/elpa-27/

Then evalutate the code below :
  #+begin_src elisp
(let ((modus-theme-install-path (expand-file-name 
"~/.emacs.d/elpa-27/modus-themes-20220323.801/")))
  (setq display-fill-column-indicator-character 9474)
  (add-to-list 'load-path modus-theme-install-path)
  (load (expand-file-name "modus-themes-autoloads.el" 
  modus-theme-install-path))
  (modus-themes-load-vivendi)
  (find-file (expand-file-name "modus-themes.el" 
  modus-theme-install-path))
  (display-fill-column-indicator-mode)
  (hs-minor-mode)
  (hs-hide-all))
  #+end_src

Then try to jump at the end of buffer with C-end or M-x 
end-of-buffer.
The point isn't at end of buffer. See the snapshot.1.png attached.

What I've found is that the following conditions are mandatory to
reproduce the error :
- Use a build for Windows (There is no problem on my Gnu/Linux 
  platform)
- Use a version of modus past f76fc911 where the :height property 
  was
added to the fill-column-indicator face.
- Use hs-minor-mode and hide all regions

On my Gnu/Linux (see Screenshot_20220327_183833.png) there is no 
problems to reach the end of buffer.

You could also see that the behaviour of the fill column isn't the 
same
(I prefer the one on Gnu/Linux)

I've tried to change the behaviour of the face like descrived in 
the
manual with the code bellow :

  #+begin_src elisp
(modus-themes-with-colors
  (custom-set-faces
   `(fill-column-indicator ((,class :foreground ,bg-active)))))
  #+end_src

But I caught the following error :

  #+begin_src 
Debugger entered--Lisp error: (error "’org-beautify’ is not a 
Modus theme")
  signal(error ("’org-beautify’ is not a Modus theme"))
  error("'%s' is not a Modus theme" org-beautify)
  modus-themes--palette(org-beautify)
  modus-themes-current-palette()
  (let* ((class '((class color) (min-colors 89))) (g1663 
  (modus-themes-current-palette)) (bg-main (alist-get 'bg-main 
  g1663)) (fg-main (alist-get 'fg-main g1663)) (bg-dim (alist-get 
  'bg-dim g1663)) (fg-dim (alist-get 'fg-dim g1663)) (bg-alt 
  (alist-get 'bg-alt g1663)) (fg-alt (alist-get 'fg-alt g1663)) 
  (bg-active (alist-get 'bg-active g1663)) (fg-active (alist-get 
  'fg-active g1663)) (bg-inactive (alist-get 'bg-inactive g1663)) 
  (fg-inactive (alist-get 'fg-inactive g1663)) (bg-active-accent 
  (alist-get 'bg-active-accent g1663)) (bg-special-cold (alist-get 
  'bg-special-cold g1663)) (bg-special-faint-cold (alist-get 
  'bg-special-faint-cold g1663)) (fg-special-cold (alist-get 
  'fg-special-cold g1663)) (bg-special-mild (alist-get 
  'bg-special-mild g1663)) (bg-special-faint-mild (alist-get 
  'bg-special-faint-mild g1663)) (fg-special-mild (alist-get 
  'fg-special-mild g1663)) (bg-special-warm (alist-get 
  'bg-special-warm g1663)) (bg-special-faint-warm (alist-get 
  'bg-special-faint-warm g1663)) (fg-special-warm (alist-get 
  'fg-special-warm g1663)) (bg-special-calm (alist-get 
  'bg-special-calm g1663)) (bg-special-faint-calm (alist-get 
  'bg-special-faint-calm g1663)) (fg-special-calm (alist-get 
  'fg-special-calm g1663)) (red (alist-get 'red g1663)) (red-alt 
  (alist-get 'red-alt g1663)) (red-alt-other (alist-get 
  'red-alt-other g1663)) (red-faint (alist-get 'red-faint g1663)) 
  (red-alt-faint (alist-get 'red-alt-faint g1663)) 
  (red-alt-other-faint (alist-get 'red-alt-other-faint g1663)) 
  (green (alist-get 'green g1663)) (green-alt (alist-get 
  'green-alt g1663)) (green-alt-other (alist-get 'green-alt-other 
  g1663)) (green-faint (alist-get 'green-faint g1663)) 
  (green-alt-faint (alist-get 'green-alt-faint g1663)) 
  (green-alt-other-faint (alist-get 'green-alt-other-faint g1663)) 
  (yellow (alist-get 'yellow g1663)) (yellow-alt (alist-get 
  'yellow-alt g1663)) (yellow-alt-other (alist-get 
  'yellow-alt-other g1663)) (yellow-faint (alist-get 'yellow-faint 
  g1663)) (yellow-alt-faint (alist-get 'yellow-alt-faint g1663)) 
  (yellow-alt-other-faint (alist-get 'yellow-alt-other-faint 
  g1663)) (blue (alist-get 'blue g1663)) (blue-alt (alist-get 
  'blue-alt g1663)) (blue-alt-other (alist-get 'blue-alt-other 
  g1663)) (blue-faint (alist-get 'blue-faint g1663)) 
  (blue-alt-faint (alist-get 'blue-alt-faint g1663)) 
  (blue-alt-other-faint (alist-get 'blue-alt-other-faint g1663)) 
  (magenta (alist-get 'magenta g1663)) ...) (ignore class bg-main 
  fg-main bg-dim fg-dim bg-alt fg-alt bg-active fg-active 
  bg-inactive fg-inactive bg-active-accent bg-special-cold 
  bg-special-faint-cold fg-special-cold bg-special-mild 
  bg-special-faint-mild fg-special-mild bg-special-warm 
  bg-special-faint-warm fg-special-warm bg-special-calm 
  bg-special-faint-calm fg-special-calm red red-alt red-alt-other 
  red-faint red-alt-faint red-alt-other-faint green green-alt 
  green-alt-other green-faint green-alt-faint 
  green-alt-other-faint yellow yellow-alt yellow-alt-other 
  yellow-faint yellow-alt-faint yellow-alt-other-faint blue 
  blue-alt blue-alt-other blue-faint blue-alt-faint 
  blue-alt-other-faint magenta ...) (custom-set-faces (list 
  'fill-column-indicator (list (list class ':foreground 
  bg-active)))))
  eval((let* ((class '((class color) (min-colors 89))) (g1663 
  (modus-themes-current-palette)) (bg-main (alist-get 'bg-main 
  g1663)) (fg-main (alist-get 'fg-main g1663)) (bg-dim (alist-get 
  'bg-dim g1663)) (fg-dim (alist-get 'fg-dim g1663)) (bg-alt 
  (alist-get 'bg-alt g1663)) (fg-alt (alist-get 'fg-alt g1663)) 
  (bg-active (alist-get 'bg-active g1663)) (fg-active (alist-get 
  'fg-active g1663)) (bg-inactive (alist-get 'bg-inactive g1663)) 
  (fg-inactive (alist-get 'fg-inactive g1663)) (bg-active-accent 
  (alist-get 'bg-active-accent g1663)) (bg-special-cold (alist-get 
  'bg-special-cold g1663)) (bg-special-faint-cold (alist-get 
  'bg-special-faint-cold g1663)) (fg-special-cold (alist-get 
  'fg-special-cold g1663)) (bg-special-mild (alist-get 
  'bg-special-mild g1663)) (bg-special-faint-mild (alist-get 
  'bg-special-faint-mild g1663)) (fg-special-mild (alist-get 
  'fg-special-mild g1663)) (bg-special-warm (alist-get 
  'bg-special-warm g1663)) (bg-special-faint-warm (alist-get 
  'bg-special-faint-warm g1663)) (fg-special-warm (alist-get 
  'fg-special-warm g1663)) (bg-special-calm (alist-get 
  'bg-special-calm g1663)) (bg-special-faint-calm (alist-get 
  'bg-special-faint-calm g1663)) (fg-special-calm (alist-get 
  'fg-special-calm g1663)) (red (alist-get 'red g1663)) (red-alt 
  (alist-get 'red-alt g1663)) (red-alt-other (alist-get 
  'red-alt-other g1663)) (red-faint (alist-get 'red-faint g1663)) 
  (red-alt-faint (alist-get 'red-alt-faint g1663)) 
  (red-alt-other-faint (alist-get 'red-alt-other-faint g1663)) 
  (green (alist-get 'green g1663)) (green-alt (alist-get 
  'green-alt g1663)) (green-alt-other (alist-get 'green-alt-other 
  g1663)) (green-faint (alist-get 'green-faint g1663)) 
  (green-alt-faint (alist-get 'green-alt-faint g1663)) 
  (green-alt-other-faint (alist-get 'green-alt-other-faint g1663)) 
  (yellow (alist-get 'yellow g1663)) (yellow-alt (alist-get 
  'yellow-alt g1663)) (yellow-alt-other (alist-get 
  'yellow-alt-other g1663)) (yellow-faint (alist-get 'yellow-faint 
  g1663)) (yellow-alt-faint (alist-get 'yellow-alt-faint g1663)) 
  (yellow-alt-other-faint (alist-get 'yellow-alt-other-faint 
  g1663)) (blue (alist-get 'blue g1663)) (blue-alt (alist-get 
  'blue-alt g1663)) (blue-alt-other (alist-get 'blue-alt-other 
  g1663)) (blue-faint (alist-get 'blue-faint g1663)) 
  (blue-alt-faint (alist-get 'blue-alt-faint g1663)) 
  (blue-alt-other-faint (alist-get 'blue-alt-other-faint g1663)) 
  (magenta (alist-get 'magenta g1663)) ...) (ignore class bg-main 
  fg-main bg-dim fg-dim bg-alt fg-alt bg-active fg-active 
  bg-inactive fg-inactive bg-active-accent bg-special-cold 
  bg-special-faint-cold fg-special-cold bg-special-mild 
  bg-special-faint-mild fg-special-mild bg-special-warm 
  bg-special-faint-warm fg-special-warm bg-special-calm 
  bg-special-faint-calm fg-special-calm red red-alt red-alt-other 
  red-faint red-alt-faint red-alt-other-faint green green-alt 
  green-alt-other green-faint green-alt-faint 
  green-alt-other-faint yellow yellow-alt yellow-alt-other 
  yellow-faint yellow-alt-faint yellow-alt-other-faint blue 
  blue-alt blue-alt-other blue-faint blue-alt-faint 
  blue-alt-other-faint magenta ...) (custom-set-faces (list 
  'fill-column-indicator (list (list class ':foreground 
  bg-active))))) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)
  #+end_src

  I've tracked it down to modus-themes--current-theme
  #+begin_src elisp
(defun modus-themes--current-theme ()
  "Return current theme."
  (car custom-enabled-themes))
  #+end_src

  I think those function should filter on symbols and take the 
  first
  occurence of a modus-* theme. Maybe something like :
  #+begin_src elisp
(defun modus-themes--current-theme ()
  "Return current theme."
  (car (seq-filter (lambda (arg) (string-match-p "^modus" 
  (symbol-name arg))) custom-enabled-themes)))
  #+end_src

  Thanks in advance for your help.