all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#55207: 29.0.50; tab-bar-format-align-right only works correctly with monospace characters
@ 2022-05-01 15:50 Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-05-01 17:55 ` Juri Linkov
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-05-01 15:50 UTC (permalink / raw)
  To: 55207


When a character using a variable pitch font or an image (I've only
tested this with XBM images) is displayed on the tab bar after
'tab-bar-format-align-right', the resulting text ends before the end of
the tab bar.

Exact recipe (assuming the default font for the tab bar is variable pitch):

1. $ emacs -Q
2. M-: (setq tab-bar-format '(tab-bar-format-align-right tab-bar-format-tabs tab-bar-separator))
3. M-x tab-bar-mode

After following these steps, the initial tab ends before the end
of the tab bar, and the gap grows with each additional tab.


In GNU Emacs 29.0.50 (build 10, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0)
 of 2022-05-01 built on coldharbour
Repository revision: 5f220d9555a908dd9957afa27d168d74adf6c7df
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure --with-x-toolkit=gtk3 --with-xinput2
 --with-native-compilation --with-xwidgets --prefix=/opt/Emacs'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11
XDBE XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB

Important settings:
  value of $LC_CTYPE: en_US.UTF-8
  value of $LANG: en_IL
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  emms-mode-line-mode: t
  emms-playing-time-display-mode: t
  emms-playing-time-mode: t
  electric-pair-mode: t
  delete-selection-mode: t
  pixel-scroll-precision-mode: t
  repeat-mode: t
  vcomplete-mode: t
  swsw-mode: t
  global-auto-revert-mode: t
  display-time-mode: t
  minibuffer-electric-default-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/daniel/etc/emacs/elpa/transient-0.3.7/transient hides /opt/Emacs/share/emacs/29.0.50/lisp/transient

Features:
(shadow emacsbug vc vc-git diff-mode vc-dispatcher dired-aux sort smiley
gnus-cite mail-extr textsec uni-scripts idna-mapping ucs-normalize
uni-confusable textsec-check gnus-bcklg gnus-async gnus-dup gnus-ml
disp-table nnml gnus-topic nndraft nnmh timezone mm-archive url-http
url-gw url-cache url-auth utf-7 nnrss mm-url epa-file cl-extra
network-stream nsm gnus-agent gnus-srvr gnus-score score-mode nnvirtual
gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig
gnus-cache gnus-sum shr pixel-fill kinsoku url-file url-dired svg dom
init-gnus gnus-demon nntp gnus-group gnus-undo easy-mmode cus-start
gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 netrc
nnoo parse-time iso8601 gnus-spec gnus-int gnus-range message sendmail
yank-media rmc puny rfc822 mml mml-sec epa derived epg rfc6068
epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047
rfc2045 ietf-drums mailabbrev gmm-utils mailheader gnus-win gnus
nnheader gnus-util mail-utils range mm-util mail-prsvr time-date
checkdoc lisp-mnt help-mode flymake-proc flymake project compile
text-property-search comint ansi-color warnings thingatpt flyspell
ispell display-line-numbers modus-operandi-theme cal-julian modus-themes
solar cal-dst cal-menu calendar cal-loaddefs init-interfaces init-web
init-volume init-emms emms-mode-line emms-player-mpv emms-playing-time
emms-player-simple emms-info-opusinfo emms-info emms-later-do emms
emms-compat init-battery battery dbus xml init-programs dired
dired-loaddefs init-shell init-pass auth-source-pass init-programming
elec-pair init-ui delsel pixel-scroll cua-base ring format-spec repeat
vcomplete swsw autorevert filenotify time minibuf-eldef init-personal
pcase init-base server finder-inf package browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
url-util mailcap url-handlers url-parse auth-source cl-seq eieio
eieio-core cl-macs eieio-loaddefs password-cache json map url-vars seq
gv subr-x byte-opt bytecomp byte-compile cconv info cus-edit pp cus-load
wid-edit cl-loaddefs cl-lib iso-transl tooltip eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd 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 simple cl-generic 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 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
xwidget-internal dbusbind inotify lcms2 dynamic-setting
system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit
xinput2 x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 542700 52961)
 (symbols 48 24357 0)
 (strings 32 93082 3762)
 (string-bytes 1 2788588)
 (vectors 16 58794)
 (vector-slots 8 1024008 47173)
 (floats 8 684 500)
 (intervals 56 610 223)
 (buffers 992 26))





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#55207: 29.0.50; tab-bar-format-align-right only works correctly with monospace characters
  2022-05-01 15:50 bug#55207: 29.0.50; tab-bar-format-align-right only works correctly with monospace characters Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-05-01 17:55 ` Juri Linkov
  2022-05-01 18:01   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2022-05-01 17:55 UTC (permalink / raw)
  To: 55207; +Cc: daniel

> When a character using a variable pitch font or an image (I've only
> tested this with XBM images) is displayed on the tab bar after
> 'tab-bar-format-align-right', the resulting text ends before the end of
> the tab bar.
>
> Exact recipe (assuming the default font for the tab bar is variable pitch):
>
> 1. $ emacs -Q
> 2. M-: (setq tab-bar-format '(tab-bar-format-align-right tab-bar-format-tabs tab-bar-separator))
> 3. M-x tab-bar-mode
>
> After following these steps, the initial tab ends before the end
> of the tab bar, and the gap grows with each additional tab.

Thanks for the bug report.  Indeed the property :align-to
in tab-bar-format-align-right fails to align to the proper width
when using a variable pitch font.  Unfortunately, I have no idea
how to fix this.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#55207: 29.0.50; tab-bar-format-align-right only works correctly with monospace characters
  2022-05-01 17:55 ` Juri Linkov
@ 2022-05-01 18:01   ` Lars Ingebrigtsen
  2022-05-01 18:21     ` Juri Linkov
  0 siblings, 1 reply; 9+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-01 18:01 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 55207, daniel

Juri Linkov <juri@linkov.net> writes:

> Thanks for the bug report.  Indeed the property :align-to
> in tab-bar-format-align-right fails to align to the proper width
> when using a variable pitch font.  Unfortunately, I have no idea
> how to fix this.

I am completely unfamiliar with how the tar bar works, but -- can't you
just measure the widths of the elements with string-pixel-width or the
like and use that to compute the alignments?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#55207: 29.0.50; tab-bar-format-align-right only works correctly with monospace characters
  2022-05-01 18:01   ` Lars Ingebrigtsen
@ 2022-05-01 18:21     ` Juri Linkov
  2022-05-02 15:25       ` Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2022-05-01 18:21 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55207, daniel

> I am completely unfamiliar with how the tar bar works, but -- can't you
> just measure the widths of the elements with string-pixel-width or the
> like and use that to compute the alignments?

Thanks for the suggestion.  This works quite nicely.
Only a very small amount of pixels are still misaligned.

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 03b49e9657..7896e051ab 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -915,8 +915,8 @@ tab-bar-format-align-right
   (let* ((rest (cdr (memq 'tab-bar-format-align-right tab-bar-format)))
          (rest (tab-bar-format-list rest))
          (rest (mapconcat (lambda (item) (nth 2 item)) rest ""))
-         (hpos (length rest))
-         (str (propertize " " 'display `(space :align-to (- right ,hpos)))))
+         (hpos (string-pixel-width rest))
+         (str (propertize " " 'display `(space :align-to (- right (,hpos))))))
     `((align-right menu-item ,str ignore))))





^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#55207: 29.0.50; tab-bar-format-align-right only works correctly with monospace characters
  2022-05-01 18:21     ` Juri Linkov
@ 2022-05-02 15:25       ` Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-05-02 19:06         ` Juri Linkov
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-05-02 15:25 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lars Ingebrigtsen, 55207

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

>>>>> Juri Linkov writes:

    > Thanks for the suggestion.  This works quite nicely.  Only a very
    > small amount of pixels are still misaligned.

Hi Juri and Lars,

This patch seems to almost completely remove the issue in the simple
case I reported.

However, in the more complicated configuration I actually use it doesn't
make much of a difference:

Before

[-- Attachment #2: before --]
[-- Type: image/png, Size: 4639 bytes --]

[-- Attachment #3: Type: text/plain, Size: 7 bytes --]


After

[-- Attachment #4: after --]
[-- Type: image/png, Size: 4266 bytes --]

[-- Attachment #5: Type: text/plain, Size: 139 bytes --]


(Both screen shots extend to the right end of the tab bar)

The icons on the mode line are small XBM images, the theme is Modus
Operandi.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#55207: 29.0.50; tab-bar-format-align-right only works correctly with monospace characters
  2022-05-02 15:25       ` Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-05-02 19:06         ` Juri Linkov
  2022-05-03  7:40           ` Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2022-05-02 19:06 UTC (permalink / raw)
  To: Daniel Semyonov; +Cc: Lars Ingebrigtsen, 55207

> However, in the more complicated configuration I actually use it doesn't
> make much of a difference:
> ...
> The icons on the mode line are small XBM images, the theme is Modus
> Operandi.

I guess you are using global-mode-string with XBM images.
Could you then try something like this to see what number it returns?

(string-pixel-width (string-trim-right (format-mode-line global-mode-string)))





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#55207: 29.0.50; tab-bar-format-align-right only works correctly with monospace characters
  2022-05-02 19:06         ` Juri Linkov
@ 2022-05-03  7:40           ` Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-05-03 17:52             ` Juri Linkov
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-05-03  7:40 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lars Ingebrigtsen, 55207

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

>>>>> Juri Linkov writes:

    > I guess you are using global-mode-string with XBM images.

I should've added this to the last message, but this is my tab bar
configuration (just a little bit over engineered):

(init-base-customize display-time-format "%H:%M %d/%m/%y"
                     display-time-mail-function #'ignore)
(display-time-mode)

(setq global-mode-string
      '(:eval
        `(""
          ,(and (boundp 'init-gnus-unread-mail-string)
                init-gnus-unread-mail-string)
          ,(and (boundp 'init-gnus-unread-news-string)
                init-gnus-unread-news-string)
          ,(and (boundp 'init-volume-string)
                init-volume-string)
          ,(and (boundp 'emms-mode-line-string)
                emms-mode-line-string)
          ,(and (boundp 'emms-playing-time-string)
                emms-playing-time-string)
          " | " ,(string-trim-right display-time-string))))
(init-base-customize tab-bar-format
                     '( tab-bar-format-tabs tab-bar-format-align-right
                        tab-bar-format-global))
(tab-bar-mode)


('init-base-customize' is just a convenience macro which calls
'customize-set-variable' under the hood and the value of 'init-*-string' is
a string of the form "x: y " where 'x' is a letter and 'y' is a number or
percentage; 'x:' is replaced with an XBM image using the 'display'
property on GUI frames).

    > Could you then try something like this to see what number it
    > returns?

I did some further testing, first adding arbitrary text to the
'global-mode-string', then adding more images and finally adding both.
I've attached screen shots of my full Emacs frame with an example of
each test case, taken right after evaluating your provided expression
(so the number is shown in the echo area).  The buffer shown in the
images shows the exact changes I made to the 'global-mode-string' in
each test.

I've also attached the envelope and volume icons seen in the screen
shots, just in case they may be useful.

Hopefully this information proves useful, thank you for looking into
this.


[-- Attachment #2: control --]
[-- Type: image/png, Size: 135538 bytes --]

[-- Attachment #3: added text --]
[-- Type: image/png, Size: 135443 bytes --]

[-- Attachment #4: added image --]
[-- Type: image/png, Size: 131180 bytes --]

[-- Attachment #5: added image and text --]
[-- Type: image/png, Size: 131534 bytes --]

[-- Attachment #6: volume icon --]
[-- Type: image/x-xbitmap, Size: 240 bytes --]

[-- Attachment #7: envelope icon --]
[-- Type: image/x-xbitmap, Size: 222 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#55207: 29.0.50; tab-bar-format-align-right only works correctly with monospace characters
  2022-05-03  7:40           ` Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-05-03 17:52             ` Juri Linkov
  2022-05-04 11:00               ` Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2022-05-03 17:52 UTC (permalink / raw)
  To: Daniel Semyonov; +Cc: Lars Ingebrigtsen, 55207

> Hopefully this information proves useful, thank you for looking into
> this.

Thanks, this helped to realize that the pixel width should be calculated
with the same face that is really used on the tab bar.  Could you please
try a new patch.  At least, I see that it works with your test cases.

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 03b49e9657..4d5ec4098c 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -915,8 +915,8 @@ tab-bar-format-align-right
   (let* ((rest (cdr (memq 'tab-bar-format-align-right tab-bar-format)))
          (rest (tab-bar-format-list rest))
          (rest (mapconcat (lambda (item) (nth 2 item)) rest ""))
-         (hpos (length rest))
-         (str (propertize " " 'display `(space :align-to (- right ,hpos)))))
+         (hpos (string-pixel-width (propertize rest 'face 'tab-bar)))
+         (str (propertize " " 'display `(space :align-to (- right (,hpos))))))
     `((align-right menu-item ,str ignore))))





^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#55207: 29.0.50; tab-bar-format-align-right only works correctly with monospace characters
  2022-05-03 17:52             ` Juri Linkov
@ 2022-05-04 11:00               ` Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-05-04 11:00 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 55207-done

>>>>> Juri Linkov writes:

    > Could you please try a new patch.  At least, I see that it works
    > with your test cases.

The new patch seems to completely fix the issue, thanks!





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-05-04 11:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-01 15:50 bug#55207: 29.0.50; tab-bar-format-align-right only works correctly with monospace characters Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-01 17:55 ` Juri Linkov
2022-05-01 18:01   ` Lars Ingebrigtsen
2022-05-01 18:21     ` Juri Linkov
2022-05-02 15:25       ` Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-02 19:06         ` Juri Linkov
2022-05-03  7:40           ` Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-03 17:52             ` Juri Linkov
2022-05-04 11:00               ` Daniel Semyonov via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.