all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#71601: 29.1; force-mode-line-update does not refresh names of tab-lines
@ 2024-06-16 22:58 Al Haji-Ali
  2024-06-17  6:11 ` Juri Linkov
  0 siblings, 1 reply; 4+ messages in thread
From: Al Haji-Ali @ 2024-06-16 22:58 UTC (permalink / raw)
  To: 71601


In an `emacs -Q`, I tried the following code:

(progn
  (tab-line-mode)
  (setq-local tab-line-tab-name-function
	      (defun my/tab-name(tab &optional _)
	        (with-current-buffer tab
                  (concat (buffer-name) " " (format-time-string "%S"))))))

This works fine and I get the seconds after the buffer-name. However, I seem to have no way of updating the tab-line to cause the names to be refreshed (except to add or remove a tab).
The documentation of `force-mode-line-update` and the `:set` code of `tab-line-tab-name-function` suggest that calling `(force-mode-line-update t)` would do the trick, but on my Emacs, this does not work. Is this a bug or am I misunderstanding the documentation?

I apologize that I am unable to test this on Emacs 30.

-- Al

In GNU Emacs 29.1 (build 1, aarch64-apple-darwin22.5.0, Carbon Version
 169 AppKit 2299.6) of 2023-09-09 built on m2air.local
Windowing system distributor 'Apple Inc.', version 14.1.2
System Description:  macOS 14.1.2

Configured using:
 'configure --enable-locallisppath=/opt/homebrew/share/emacs/site-lisp
 --infodir=/opt/homebrew/Cellar/emacs-mac/emacs-29.1-mac-10.0/share/info
 --mandir=/opt/homebrew/Cellar/emacs-mac/emacs-29.1-mac-10.0/share/man
 --prefix=/opt/homebrew/Cellar/emacs-mac/emacs-29.1-mac-10.0 --with-mac
 --enable-mac-app=/opt/homebrew/Cellar/emacs-mac/emacs-29.1-mac-10.0
 --with-gnutls --with-modules --with-mac-metal --with-native-compilation
 --with-tree-sitter 'CFLAGS=-I/opt/homebrew/opt/gcc/include
 -I/opt/homebrew/opt/libgccjit/include'
 'LDFLAGS=-L/opt/homebrew/lib/gcc/13 -I/opt/homebrew/opt/gcc/include
 -I/opt/homebrew/opt/libgccjit/include''

Configured features:
ACL GLIB GMP GNUTLS JSON LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE
PDUMPER RSVG SQLITE3 THREADS TOOLKIT_SCROLL_BARS TREE_SITTER XIM ZLIB

Important settings:
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tab-line-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mac-mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils help-fns radix-tree
cl-print byte-opt debug backtrace find-func tab-line time-date
cl-loaddefs comp comp-cstr warnings icons subr-x rx cl-seq cl-macs gv
cl-extra help-mode bytecomp byte-compile cl-lib jka-compr info rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/mac-win mac-win
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads kqueue mac multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 96353 12870)
 (symbols 48 8005 0)
 (strings 32 24415 2462)
 (string-bytes 1 758586)
 (vectors 16 19730)
 (vector-slots 8 372131 16557)
 (floats 8 35 184)
 (intervals 56 535 0)
 (buffers 984 17))





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

* bug#71601: 29.1; force-mode-line-update does not refresh names of tab-lines
  2024-06-16 22:58 bug#71601: 29.1; force-mode-line-update does not refresh names of tab-lines Al Haji-Ali
@ 2024-06-17  6:11 ` Juri Linkov
  2024-06-17  8:31   ` Al Haji-Ali
  0 siblings, 1 reply; 4+ messages in thread
From: Juri Linkov @ 2024-06-17  6:11 UTC (permalink / raw)
  To: Al Haji-Ali; +Cc: 71601

> (progn
>   (tab-line-mode)
>   (setq-local tab-line-tab-name-function
> 	      (defun my/tab-name(tab &optional _)
> 	        (with-current-buffer tab
>                   (concat (buffer-name) " " (format-time-string "%S"))))))
>
> This works fine and I get the seconds after the buffer-name.  However,
> I seem to have no way of updating the tab-line to cause the names to
> be refreshed (except to add or remove a tab).
> The documentation of `force-mode-line-update` and the `:set` code of
> `tab-line-tab-name-function` suggest that calling
> `(force-mode-line-update t)` would do the trick, but on my Emacs, this
> does not work.  Is this a bug or am I misunderstanding the
> documentation?

Please try to set `tab-line-cache-key-function` to a function
that is a copy of `tab-line-cache-key-default` but where
at the end there is appended your addition of (format-time-string "%S"):

(setq tab-line-cache-key-function
      (lambda (tabs)
	(list
	 tabs
	 ;; handle buffer renames
	 (buffer-name (window-buffer))
	 ;; handle tab-line scrolling
	 (window-parameter nil 'tab-line-hscroll)
	 ;; for setting face 'tab-line-tab-current'
	 (mode-line-window-selected-p)
	 ;; for `tab-line-tab-face-modified'
	 (and (memq 'tab-line-tab-face-modified
		    tab-line-tab-face-functions)
              (buffer-file-name)
              (buffer-modified-p))
         ;; Added key:
	 (format-time-string "%S"))))

This will clear the cache every time when (format-time-string "%S")
changes, i.e. every second.

If this works, please suggest where would you expect to find this information.
Should the documentation be updated for 'tab-line-tab-name-function'?





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

* bug#71601: 29.1; force-mode-line-update does not refresh names of tab-lines
  2024-06-17  6:11 ` Juri Linkov
@ 2024-06-17  8:31   ` Al Haji-Ali
  2024-06-17 16:49     ` Juri Linkov
  0 siblings, 1 reply; 4+ messages in thread
From: Al Haji-Ali @ 2024-06-17  8:31 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 71601

On 17/06/2024, Juri Linkov wrote:
>
> Please try to set `tab-line-cache-key-function` to a function
> that is a copy of `tab-line-cache-key-default` but where
> at the end there is appended your addition of (format-time-string "%S"):

Indeed, the tab caching seems to be the issue. I resolved it slightly differently by clearing the cache before calling `force-mode-line-update`. 

(set-window-parameter nil 'tab-line-cache nil)
(force-mode-line-update)

whenever I want to update the tab names.

I would suggest that a solution for forcing name updates is included in the documentation for `tab-line-tab-name-format-function`, possibly defining a new function like
`tab-line-force-update`.
Also, shouldn't the cache be cleared in the `:set` code of `tab-line-tab-name-format-function`? (That's where I actually figured out that I needed to call `force-mode-line-update`).

-- Al





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

* bug#71601: 29.1; force-mode-line-update does not refresh names of tab-lines
  2024-06-17  8:31   ` Al Haji-Ali
@ 2024-06-17 16:49     ` Juri Linkov
  0 siblings, 0 replies; 4+ messages in thread
From: Juri Linkov @ 2024-06-17 16:49 UTC (permalink / raw)
  To: Al Haji-Ali; +Cc: 71601

close 71601 30.0.50
thanks

>> Please try to set `tab-line-cache-key-function` to a function
>> that is a copy of `tab-line-cache-key-default` but where
>> at the end there is appended your addition of (format-time-string "%S"):
>
> Indeed, the tab caching seems to be the issue.  I resolved it slightly
> differently by clearing the cache before calling
> `force-mode-line-update`.
>
> (set-window-parameter nil 'tab-line-cache nil)
> (force-mode-line-update)
>
> whenever I want to update the tab names.
>
> I would suggest that a solution for forcing name updates is included
> in the documentation for `tab-line-tab-name-format-function`, possibly
> defining a new function like
> `tab-line-force-update`.
> Also, shouldn't the cache be cleared in the `:set` code of
> `tab-line-tab-name-format-function`?  (That's where I actually figured
> out that I needed to call `force-mode-line-update`).

Thanks for the suggestion.  So the function `tab-line-force-update`
for the `:set` code is pushed now.





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

end of thread, other threads:[~2024-06-17 16:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-16 22:58 bug#71601: 29.1; force-mode-line-update does not refresh names of tab-lines Al Haji-Ali
2024-06-17  6:11 ` Juri Linkov
2024-06-17  8:31   ` Al Haji-Ali
2024-06-17 16:49     ` Juri Linkov

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.