* bug#66678: 30.0.50; Tabs close erratically in text terminal
@ 2023-10-22 11:21 Petteri Hintsanen
2023-10-22 12:17 ` Eli Zaretskii
2023-10-22 17:42 ` Juri Linkov
0 siblings, 2 replies; 3+ messages in thread
From: Petteri Hintsanen @ 2023-10-22 11:21 UTC (permalink / raw)
To: 66678
[-- Attachment #1: Type: text/plain, Size: 4471 bytes --]
I'm running Emacs in xterm with xterm-mouse-mode and tab-bar-mode
enabled. There, tabs have an "x" mark for closing them. However, tabs
will also close if you click on the character position right after the
buffer name in the tab. This makes it easy to unintentionally close a
tab instead of switching to it, which is very annoying.
Recipe:
- In xterm, start emacs by `emacs -Q -nw'.
- M-x xterm-mouse-mode
- M-x tab-bar-mode
- Create a new tab by clicking on "+" on the tab bar.
Now you should have two tabs named `*scratch*'
- Click on the first (leftmost) tab right after the second asterisk.
Expected behavior: Leftmost tab is selected.
Actual behavior: Leftmost tab is closed.
I traced the issue to `tab-bar-auto-width' function which — I think — is
used to pad a tab text with spaces to make it have a uniform width
within the tab bar. The function erroneously copies 'close-tab text
property from the close button text (tab-bar-close-button) and positions
it right after the buffer name, causing the said behavior.
The attached patch fixes the immediate issue, but I doubt if it is
sufficient, given that there is similar close tab-related logic elsewhere
in the code. Another workaround is to set `tab-bar-close-button' to one
character string "x" instead of " x".
In GNU Emacs 30.0.50 (build 4, x86_64-pc-linux-gnu, GTK+ Version
3.24.38, cairo version 1.16.0) of 2023-10-22 built on romeo
Repository revision: ae337884107c4d5f66aaceef0e8b548565317412
Repository branch: master
System Description: Debian GNU/Linux 12 (bookworm)
Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBOTF LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP
X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB
Important settings:
value of $LC_MESSAGES: en_US.UTF-8
value of $LANG: fi_FI.UTF-8
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
xterm-mouse-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
tab-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
minibuffer-regexp-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 time-date subr-x
cl-extra help-mode icons cl-loaddefs cl-lib cus-start cus-load xt-mouse
term/xterm xterm byte-opt gv bytecomp byte-compile rmc iso-transl
tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
touch-screen 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 dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process emacs)
Memory information:
((conses 16 58490 14195) (symbols 48 7111 0) (strings 32 17493 1913)
(string-bytes 1 469587) (vectors 16 8894)
(vector-slots 8 113240 10638) (floats 8 33 11100)
(intervals 56 256 23) (buffers 992 11))
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Tab bar patch --]
[-- Type: text/x-diff, Size: 747 bytes --]
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index d2815c03ebf..e21367255a0 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1227,7 +1227,9 @@ tab-bar-auto-width
((< prev-width width)
(let* ((space (apply #'propertize " "
(text-properties-at 0 name)))
- (ins-pos (- len (if close-p 1 0)))
+ (ins-pos (- len (if close-p
+ (length tab-bar-close-button)
+ 0)))
(prev-name name))
(while continue
(setq name (concat (substring name 0 ins-pos)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#66678: 30.0.50; Tabs close erratically in text terminal
2023-10-22 11:21 bug#66678: 30.0.50; Tabs close erratically in text terminal Petteri Hintsanen
@ 2023-10-22 12:17 ` Eli Zaretskii
2023-10-22 17:42 ` Juri Linkov
1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2023-10-22 12:17 UTC (permalink / raw)
To: Petteri Hintsanen, Juri Linkov; +Cc: 66678
> From: Petteri Hintsanen <petterih@iki.fi>
> Date: Sun, 22 Oct 2023 14:21:16 +0300
>
> I'm running Emacs in xterm with xterm-mouse-mode and tab-bar-mode
> enabled. There, tabs have an "x" mark for closing them. However, tabs
> will also close if you click on the character position right after the
> buffer name in the tab. This makes it easy to unintentionally close a
> tab instead of switching to it, which is very annoying.
>
> Recipe:
>
> - In xterm, start emacs by `emacs -Q -nw'.
> - M-x xterm-mouse-mode
> - M-x tab-bar-mode
> - Create a new tab by clicking on "+" on the tab bar.
> Now you should have two tabs named `*scratch*'
> - Click on the first (leftmost) tab right after the second asterisk.
>
> Expected behavior: Leftmost tab is selected.
> Actual behavior: Leftmost tab is closed.
This is not specific to xterm or xterm-mouse, it happens with any
mouse-equipped text-mode terminal. It happens in Emacs 29 as well.
> I traced the issue to `tab-bar-auto-width' function which — I think — is
> used to pad a tab text with spaces to make it have a uniform width
> within the tab bar. The function erroneously copies 'close-tab text
> property from the close button text (tab-bar-close-button) and positions
> it right after the buffer name, causing the said behavior.
>
> The attached patch fixes the immediate issue, but I doubt if it is
> sufficient, given that there is similar close tab-related logic elsewhere
> in the code. Another workaround is to set `tab-bar-close-button' to one
> character string "x" instead of " x".
Juri, please install the fix you think is appropriate on the emacs-29
branch, since the problem exists there as well.
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#66678: 30.0.50; Tabs close erratically in text terminal
2023-10-22 11:21 bug#66678: 30.0.50; Tabs close erratically in text terminal Petteri Hintsanen
2023-10-22 12:17 ` Eli Zaretskii
@ 2023-10-22 17:42 ` Juri Linkov
1 sibling, 0 replies; 3+ messages in thread
From: Juri Linkov @ 2023-10-22 17:42 UTC (permalink / raw)
To: Petteri Hintsanen; +Cc: 66678
close 66678 29.1.90
thanks
> - Create a new tab by clicking on "+" on the tab bar.
> Now you should have two tabs named `*scratch*'
> - Click on the first (leftmost) tab right after the second asterisk.
>
> Expected behavior: Leftmost tab is selected.
> Actual behavior: Leftmost tab is closed.
>
> I traced the issue to `tab-bar-auto-width' function which — I think — is
> used to pad a tab text with spaces to make it have a uniform width
> within the tab bar. The function erroneously copies 'close-tab text
> property from the close button text (tab-bar-close-button) and positions
> it right after the buffer name, causing the said behavior.
>
> The attached patch fixes the immediate issue, but I doubt if it is
> sufficient, given that there is similar close tab-related logic elsewhere
> in the code. Another workaround is to set `tab-bar-close-button' to one
> character string "x" instead of " x".
Thank you for finding this subtle bug and fixing it.
The space before "x" was intended to give more space to click
on the close button, i.e. for more wider clicking area.
So better to keep the 'close-tab' text property on the space.
This means that your patch is the right way to fix this.
Now it's pushed to the emacs-29 branch as well as separately
to master to avoid merge conflicts.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-22 17:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-22 11:21 bug#66678: 30.0.50; Tabs close erratically in text terminal Petteri Hintsanen
2023-10-22 12:17 ` Eli Zaretskii
2023-10-22 17:42 ` Juri Linkov
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).