From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#57848: 29.0.50; Problems with private tab-line-tab-name-function Date: Sun, 30 Oct 2022 09:24:00 +0200 Organization: LINKOV.NET Message-ID: <868rkxretr.fsf@mail.linkov.net> References: <8735cs53vn.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2067"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: Alexandros Prekates , Robert Pluim , 57848@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 30 08:38:36 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1op2tv-0000PU-Kw for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 Oct 2022 08:38:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1op2tQ-0003Ph-NO; Sun, 30 Oct 2022 03:38:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1op2tP-0003P5-1D for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2022 03:38:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1op2tO-0000YW-Ot for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2022 03:38:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1op2tO-00014F-8v for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2022 03:38:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Oct 2022 07:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57848 X-GNU-PR-Package: emacs Original-Received: via spool by 57848-submit@debbugs.gnu.org id=B57848.16671154594051 (code B ref 57848); Sun, 30 Oct 2022 07:38:02 +0000 Original-Received: (at 57848) by debbugs.gnu.org; 30 Oct 2022 07:37:39 +0000 Original-Received: from localhost ([127.0.0.1]:37256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1op2t1-00013H-8F for submit@debbugs.gnu.org; Sun, 30 Oct 2022 03:37:39 -0400 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:47787) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1op2sy-000131-Gf for 57848@debbugs.gnu.org; Sun, 30 Oct 2022 03:37:37 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 075E4C0006; Sun, 30 Oct 2022 07:37:27 +0000 (UTC) In-Reply-To: <8735cs53vn.fsf@web.de> (Michael Heerdegen's message of "Fri, 16 Sep 2022 06:39:56 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246597 Archived-At: > (1) When using `tab-line-mode' together with > > #+begin_src emacs-lisp > (setq-local tab-line-tab-name-function > (lambda (_b &optional _bs) "%b")) > #+end_src > > I get tabs that are all named equally - all named after the currently > active tab's buffer. > > I didn't know that mode-line format sequences are valid. Are they? If > they are (would be nice), could we document this, fix the behavior (I > guess the interpretation is done in the context of a wrong current > buffer), and maybe allow all kinds of mode-line-format values, like > lists? All mode-line format sequences are valid, but only in the context of the right buffer. So you can use such tab-name function: #+begin_src emacs-lisp (setq tab-line-tab-name-function (lambda (b &optional _bs) (format-mode-line "%b" 'tab-line-tab nil b))) #+end_src This confirms that all mode-line format sequences can be used: #+begin_src emacs-lisp (setq tab-line-tab-name-function (lambda (b &optional _bs) (format-mode-line mode-line-format 'tab-line-tab nil b))) #+end_src > (2) What I actually had tried was to get nicely named tabs for Info > buffers (including the clones created with M-n). > > I tried with something like this: > > #+begin_src emacs-lisp > (add-hook 'Info-mode-hook > (defun my-setup-tab-line-for-Info-mode () > (tab-line-mode +1) > (setq-local > tab-line-tab-name-function > (lambda (b &optional _bs) > (with-current-buffer b > (apply > #'concat > (cdr mode-line-buffer-identification))))))) > #+end_src Using the same as above, this could look like: #+begin_src emacs-lisp (add-hook 'Info-mode-hook (defun my-setup-tab-line-for-Info-mode () (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 > but with that the tab names are not updated while browsing Info pages. > > The problem here seems to be related to the caching mechanism that > doesn't recognize the need to update; invalidating the cache explicitly > like with this very ugly hack: > > #+begin_src emacs-lisp > (add-variable-watcher > 'mode-line-buffer-identification > (defun my-Info-mode-line-buffer-identification-watcher > (_symbol _newval _operation where) > (when (and (eq where (current-buffer)) > (derived-mode-p 'Info-mode)) > (set-window-parameter nil 'tab-line-cache nil)))) > #+end_src > > makes it work. > > It would be nice to provide a way to get cases like this work , e.g. by > allowing to specify buffer-local cache key returning functions. 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.