emacs-devel
[Top][All Lists]
Advanced

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

Re: [nongnu] elpa/opam-switch-mode 8b8670ca8b 1/3: feat(opam-switch-mod


From: Stefan Monnier
Subject: Re: [nongnu] elpa/opam-switch-mode 8b8670ca8b 1/3: feat(opam-switch-mode-lighter): Show the switch name in the mode-bar
Date: Tue, 11 Jul 2023 18:09:12 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

>> Instead of `redraw-display` you want `force-mode-line-update`.
> OK thanks. But we specifically need to update the mode-line for *all* frames.
> While `force-mode-line-update` only deals with the current buffer,
> and `(force-mode-line-update t)` just seems to deal with all buffers from the 
> current frame.
> Do you confirm?

No, `(force-mode-line-update t)` should apply to all frames.

> Sure: I had done this slight duplication outside of `opam-switch-set-switch`
> because the need for `redraw-display` only showed up when using the menu
> — direct calls to `M-x opam-switch-set-switch …` were fine.

IIRC that's because the use of the minibuffer forces a more complete
redisplay which happens to recompute those modelines, tho I'd be
surprised if it recomputes the modelines of all frames.

>> Also, in some circumstances the mode lines can be updated fairly often
>> (e.g. after every key press, and/or every process output received by
>> a filter), so it might be worthwhile to memoize/precompute the
>> lighter rather than recompute it every time the modeline is updated.
>
> Thanks for the suggestion, but IINM your patch only precomputes the lighter 
> once,
> while it would need to be recomputed each time we change the opam switch,
> otherwise the ligther becomes out-of-sync.

No, I reset it to nil at the same time as I call
`force-mode-line-update`, which should cause it to be recomputed at the
next redisplay.

> and given no subexpression of the current (opam-switch-mode-lighter)
> involves any external system call, I'd say it is not that inefficient/costly…

It's not too bad, admittedly.

> https://github.com/ocaml/merlin/blob/4f6c7cfee2344dd75e9568f25c0c1576521ec049/emacs/merlin.el#L2046
> Are you OK with that point?

It's up to you.


        Stefan




reply via email to

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