unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: James Cherti <contact@jamescherti.com>
To: emacs-devel@gnu.org
Subject: Re: Should text-scale trigger hooks?
Date: Wed, 6 Nov 2024 20:52:56 -0500	[thread overview]
Message-ID: <b8a34f1a-081b-4822-a946-977529110bd8@jamescherti.com> (raw)
In-Reply-To: <9cf01065-4f23-435b-b895-d02beef860a8@jamescherti.com>

Update: I just realized that text-scale-mode-hook can be utilized 
instead of advice because text-scale-* functions call text-scale-mode 
each time the text scale is changed.

(defun persist-text-scale-adjust-eat ()
   "Adjust the text scale of all ediff buffers."
   (when (derived-mode-p 'eat-mode)
     (run-hooks 'window-configuration-change-hook)))
(defun persist-text-scale-adjust-visual-fill-column ()
   "Adjust the text scale of all ediff buffers."
   (when (bound-and-true-p visual-fill-column-mode)
     (run-hooks 'window-configuration-change-hook)))
(add-hook 'text-scale-mode-hook #'persist-text-scale-adjust-eat)
(add-hook 'text-scale-mode-hook
  #'persist-text-scale-adjust-visual-fill-column)

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

On 2024-11-06 20:17, James Cherti wrote:
> 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/
> 



  reply	other threads:[~2024-11-07  1:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07  1:17 Should text-scale trigger hooks? James Cherti
2024-11-07  1:52 ` James Cherti [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b8a34f1a-081b-4822-a946-977529110bd8@jamescherti.com \
    --to=contact@jamescherti.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).