unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Should text-scale trigger hooks?
@ 2024-11-07  1:17 James Cherti
  2024-11-07  1:52 ` James Cherti
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: James Cherti @ 2024-11-07  1:17 UTC (permalink / raw)
  To: emacs-devel

I've identified an issue that affects Emacs packages like eat (terminal) 
and visual-fill-column.

The core problem is that functions such as text-scale-increase, 
text-scale-decrease, and text-scale-set do not trigger hooks such as 
window-configuration-change-hook. Because of that, eat does not 
instantly update the window when the text scale is changed and 
visual-fill-column does not update the margin until we resize the window.

Currently, I've implemented workarounds for the eat package:
(defun persist-text-scale-adjust-eat (&rest args)
   "Adjust the text scale of all eat buffers."
   (when (derived-mode-p 'eat-mode)
     (run-hooks 'window-configuration-change-hook)))
(advice-add 'text-scale-increase :after #'persist-text-scale-adjust-eat)
(advice-add 'text-scale-decrease :after #'persist-text-scale-adjust-eat)

I've implemented a similar solution for visual-fill-column (see 
https://codeberg.org/joostkremers/visual-fill-column/pulls/16 ), but the 
visual-fill-column maintainer thinks this is probably not the right 
solution to this problem. I tend to agree with him.

While these workarounds work, I believe a more robust solution would be 
to have text-scale functions automatically trigger hooks such as 
window-configuration-change-hook, or perhaps introduce a dedicated hook 
for text scale that other plugins could utilize.

This would provide a more maintainable solution and prevent the need for 
individual package-specific workarounds.

--
James Cherti
https://www.jamescherti.com/



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-11-08 17:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-07  1:17 Should text-scale trigger hooks? James Cherti
2024-11-07  1:52 ` James Cherti
2024-11-07  6:55 ` Eli Zaretskii
2024-11-07  8:21   ` Joost Kremers
2024-11-07  8:58     ` Eli Zaretskii
2024-11-07  9:42       ` Joost Kremers
2024-11-07 14:16         ` James Cherti
2024-11-08 17:47           ` [External] : " Drew Adams
2024-11-07  8:10 ` Joost Kremers

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).