help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Update `minibuffer-line' on buffer switches


From: Stefan Monnier
Subject: Re: Update `minibuffer-line' on buffer switches
Date: Sun, 28 Jun 2015 23:36:51 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> very expensive.  Furthermore, it would be nice to have hook(s)
> corresponding to buffer switching, e.g. tracking an event of entering
> (transferring focus) to another buffer.

These are actually fairly tricky to define in a way that corresponds to
your intuitive understanding.

But you might get partway there, by doing something like

  (add-function :after pre-redisplay-function
                (lambda (windows)
                  ;; Only recompute if we've switched window, or if
                  ;; (force-mode-line-update t) has been called.
                  (unless (and (consp windows) (null (cdr windows)))
                    (minibuffer-line--update))))

> Wouldn't Emacs 25 benefit the flexibility offered by such hooks?
> What do you think Stefan?

"switching buffer" already has a hook: window-configuration-change-hook.
Changing which window is selected does not have a hook, OTOH.

Adding a hook to `select-window' could work, but could be a bit tricky
since this function is sometimes used internally at places which don't
correspond to something which the end-user would consider as relevant.

I guess we could synthesize such a hook with pre-redisplay-function by
comparing the current selected-window with the window that was selected
last time pre-redisplay-function was run (or the same could be done with
post-command-hook).  Not sure how often that would be useful.


        Stefan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]