From: Juri Linkov <juri@linkov.net>
To: Carlos Pita <carlosjosepita2@gmail.com>
Cc: 51935@debbugs.gnu.org
Subject: bug#51935: 29.0.50; tab-switch hides identically named tabs
Date: Sat, 20 Nov 2021 21:42:12 +0200 [thread overview]
Message-ID: <86ee7amuur.fsf@mail.linkov.net> (raw)
In-Reply-To: <CAEOO5TfC7wXkJuWORpRFv=jrmTgtrhAG5Av6wEq5x3_=7Q97zw@mail.gmail.com> (Carlos Pita's message of "Sat, 20 Nov 2021 00:17:22 -0300")
>> But the problem is that 'C-x t RET' is used mostly when the tab-bar
>> is disabled and not visible, so tabs are not positional in this case.
>
> But there still is the underlying order used by C-TAB/S-C-TAB, isn't it?
C-TAB/S-C-TAB keys are enabled only when tab-bar-mode is enabled.
> Depending on the configured completion framework C-x t RET will show
> candidates in order or not, but the interpretation of the suffix as a
> position seems relatively clear to me even in the unordered case, if
> not anything else at least it's an indication that there are
> additional tabs with the same name.
This could be implemented like below. But it still messes the
text properties of the selected completion candidate,
even with using minibuffer-allow-text-properties,
so something is broken in the default completion framework.
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 1a1d0b1ea5..0590b5fe7c 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1198,13 +1198,24 @@ tab-bar-switch-to-tab
to get the name of the most recently visited tab, the second
most recent, and so on."
(interactive
- (let* ((recent-tabs (mapcar (lambda (tab)
- (alist-get 'name tab))
- (tab-bar--tabs-recent))))
+ (let* ((names '()) (i 1)
+ (recent-tabs
+ (mapcar (lambda (tab)
+ (let ((name (alist-get 'name tab)))
+ (if (member name names)
+ (setq name (format "%s<%s>" name i))
+ (setq name (copy-sequence name))
+ (push name names))
+ (setq i (1+ i))
+ (propertize name 'tab tab)))
+ (tab-bar--tabs-recent)))
+ (minibuffer-allow-text-properties t))
(list (completing-read (format-prompt "Switch to tab by name"
(car recent-tabs))
recent-tabs nil nil nil nil recent-tabs))))
- (tab-bar-select-tab (1+ (or (tab-bar--tab-index-by-name name) 0))))
+ (let ((tab (get-text-property 0 'tab name)))
+ (tab-bar-select-tab (1+ (or (and tab (tab-bar--tab-index tab))
+ (tab-bar--tab-index-by-name name) 0)))))
(defalias 'tab-bar-select-tab-by-name 'tab-bar-switch-to-tab)
--
next prev parent reply other threads:[~2021-11-20 19:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-18 6:10 bug#51935: 29.0.50; tab-switch hides identically named tabs Carlos Pita
2021-11-18 17:32 ` Juri Linkov
2021-11-19 0:31 ` Carlos Pita
2021-11-19 8:36 ` Juri Linkov
2021-11-20 3:17 ` Carlos Pita
2021-11-20 19:42 ` Juri Linkov [this message]
2021-11-22 18:16 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86ee7amuur.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=51935@debbugs.gnu.org \
--cc=carlosjosepita2@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).