I customized variable frame-title-format
to change frame title. However, Emacs only updates frame title when he/she wants to. Can I force Emacs to update (i.e. refresh) the title, say, after evaluating some custom functions?
Here is the frame-title-format:
(setq frame-title-format "%b %* %n")
I want %n
(display if narrowing) to take effect right after narrowing the buffer.
According to https://www.gnu.org/software/emacs/manual/html_node/elisp/Mode-Line-Basics.html
(force-mode-line-update)
also forces menu bar and frame title updates.
I can confirm that a frame title containing "%*" doesn't immediately update when I first modify a buffer and (force-mode-line-update)
helps.
[emacs 24.5.1 on fedora 23 linux]
One way in elisp to force a redisplay is to use (sit-for 0)
. You can define your own functions like the following:
(defun my-narrow-to-region (start end)
(interactive "r")
(narrow-to-region start end)
(sit-for 0))
Note: I can't verify that this solves your problem, as I use Mac OS X, where the frame title is properly updated even without this.
Update: In an earlier version of this answer I suggested using defadvice
. I realized that this wasn't a good idea as it affects all uses of the function, as it gives rise to unwanted side effects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With