unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Ben Sferrazza <ben.sferrazza@aeonsemi.com>
Cc: 52881@debbugs.gnu.org
Subject: bug#52881: setting tab-line-separator to any value breaks clicking tabs with mouse
Date: Thu, 30 Dec 2021 10:05:24 +0200	[thread overview]
Message-ID: <868rw28qm3.fsf@mail.linkov.net> (raw)
In-Reply-To: <CO1PR19MB498434CB237DCE18B9763C5F95449@CO1PR19MB4984.namprd19.prod.outlook.com> (Ben Sferrazza's message of "Wed, 29 Dec 2021 21:47:27 +0000")

[-- Attachment #1: Type: text/plain, Size: 477 bytes --]

> This is using Emacs 27.2 on a CentOS8 machine at work. I use Emacs
> exclusively with -nw in a terminal with mouse support enabled.
>
> Using something like
>
> (setq tab-line-separator " | ")
>
> breaks the ability to click on a tab to select it. Leaving it at the
> default value avoids the bug.

Sorry, tab-line had hard-coded assumption on separators
no longer than 1 character wide.

Eli, is it ok to push this patch to the release branch
to support longer separators:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: tab-line-separator.patch --]
[-- Type: text/x-diff, Size: 4363 bytes --]

diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index af0647acf7..5eae2eb7c4 100644
--- a/lisp/tab-line.el
+++ b/lisp/tab-line.el
@@ -636,7 +638,10 @@ tab-line-auto-hscroll
                  (not (integerp hscroll)))
         (let ((selected (seq-position strings 'selected
                                       (lambda (str prop)
-                                        (get-pos-property 1 prop str)))))
+                                        (or (get-pos-property 0 prop str)
+                                            (and (next-single-property-change 0 prop str)
+                                                 (get-pos-property (next-single-property-change 0 prop str)
+                                                                   prop str)))))))
           (cond
            ((null selected)
             ;; Do nothing if no tab is selected
@@ -656,7 +661,11 @@ tab-line-auto-hscroll
                        (new-hscroll (when tab-prop
                                       (seq-position strings tab-prop
                                                     (lambda (str tab)
-                                                      (eq (get-pos-property 1 'tab str) tab))))))
+                                                      (eq (or (get-pos-property 0 'tab str)
+                                                              (and (next-single-property-change 0 'tab str)
+                                                                   (get-pos-property (next-single-property-change 0 'tab str)
+                                                                                     'tab str)))
+                                                          tab))))))
                   (when new-hscroll
                     (setq hscroll (float new-hscroll))
                     (set-window-parameter nil 'tab-line-hscroll hscroll)))
@@ -683,7 +692,11 @@ tab-line-auto-hscroll
                        (new-hscroll (when tab-prop
                                       (seq-position strings tab-prop
                                                     (lambda (str tab)
-                                                      (eq (get-pos-property 1 'tab str) tab))))))
+                                                      (eq (or (get-pos-property 0 'tab str)
+                                                              (and (next-single-property-change 0 'tab str)
+                                                                   (get-pos-property (next-single-property-change 0 'tab str)
+                                                                                     'tab str)))
+                                                          tab))))))
                   (when new-hscroll
                     (setq hscroll (float new-hscroll))
                     (set-window-parameter nil 'tab-line-hscroll hscroll)))))))))
@@ -742,7 +755,10 @@ tab-line-select-tab
 using the `previous-buffer' command."
   (interactive "e")
   (let* ((posnp (event-start event))
-         (tab (get-pos-property 1 'tab (car (posn-string posnp))))
+         (tab (or (get-pos-property 0 'tab (car (posn-string posnp)))
+                  (and (next-single-property-change 0 'tab (car (posn-string posnp)))
+                       (get-pos-property (next-single-property-change 0 'tab (car (posn-string posnp)))
+                                         'tab (car (posn-string posnp))))))
          (buffer (if (bufferp tab) tab (cdr (assq 'buffer tab)))))
     (if buffer
         (tab-line-select-tab-buffer buffer (posn-window posnp))
@@ -858,7 +874,10 @@ tab-line-close-tab
   (interactive (list last-nonmenu-event))
   (let* ((posnp (and (listp event) (event-start event)))
          (window (and posnp (posn-window posnp)))
-         (tab (get-pos-property 1 'tab (car (posn-string posnp))))
+         (tab (or (get-pos-property 0 'tab (car (posn-string posnp)))
+                  (and (next-single-property-change 0 'tab (car (posn-string posnp)))
+                       (get-pos-property (next-single-property-change 0 'tab (car (posn-string posnp)))
+                                         'tab (car (posn-string posnp))))))
          (buffer (if (bufferp tab) tab (cdr (assq 'buffer tab))))
          (close-function (unless (bufferp tab) (cdr (assq 'close tab)))))
     (with-selected-window (or window (selected-window))

  reply	other threads:[~2021-12-30  8:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-29 21:47 bug#52881: setting tab-line-separator to any value breaks clicking tabs with mouse Ben Sferrazza
2021-12-30  8:05 ` Juri Linkov [this message]
2021-12-30  8:44   ` Eli Zaretskii
2021-12-30 16:08     ` Juri Linkov
2021-12-30 16:43       ` Eli Zaretskii
2021-12-31  9:21         ` Juri Linkov
2022-01-02 18:04           ` 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=868rw28qm3.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=52881@debbugs.gnu.org \
    --cc=ben.sferrazza@aeonsemi.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).