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

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

bug#57848: 29.0.50; Problems with private tab-line-tab-name-function


From: Juri Linkov
Subject: bug#57848: 29.0.50; Problems with private tab-line-tab-name-function
Date: Sun, 30 Oct 2022 19:39:30 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu)

> my example (above) returns a plain "%b" string - nonetheless a buffer
> name is being printed as tab name.  Mode-line format specifiers seem
> to be handled without `format-mode-line'.
>
> My question is what the semantics of the return value of
> `tab-line-tab-name-function' are.  Or is the above behavior a bug?

Thanks for finding this issue.  Indeed, currently it has such
weird effect that e.g. `C-x b %s RET' displays the tab name
"no process".

Now this is fixed by using the same solution as used in
`Info-set-mode-line' to escape %-constructs.

>> A user-defined cache key function is a good idea.
>> Please send an example of such function for Info,
>> so I could test the implementation.
>
> I guess something like
>
>   (lambda (b) (buffer-local-value 'mode-line-buffer-identification b))
>
> should do it - a tab's name needs to be changed when the buffer local
> binding of `mode-line-buffer-identification' has been modified.

Now a new function variable `tab-line-cache-key-function' is pushed,
so you can add more cache keys with something like this:

#+begin_src emacs-lisp
(add-hook 'Info-mode-hook
          (defun my-setup-tab-line-for-Info-mode ()
            (add-function :filter-return (local 'tab-line-cache-key-function)
                          (lambda (cache-keys)
                            (cons mode-line-buffer-identification cache-keys)))
            (tab-line-mode +1)
            (setq-local
             tab-line-tab-name-function
             (lambda (b &optional _bs)
               (with-current-buffer b
                 (if (derived-mode-p 'Info-mode)
                     (format-mode-line
                      (apply
                       #'concat
                       (cdr mode-line-buffer-identification))
                      'tab-line-tab nil b)
                   (buffer-name b)))))))
#+end_src

Then visiting even such nodes as (info "(elisp) %-Constructs")
doesn't have anymore the problem that you found above.





reply via email to

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