GNU bug report logs - #28524
26.0.60; Truncation in %d displayed numbers in minor mode lighter

Previous Next

Package: emacs;

Reported by: Kaushal Modi <kaushal.modi <at> gmail.com>

Date: Wed, 20 Sep 2017 15:15:01 UTC

Severity: normal

Tags: moreinfo

Found in version 26.0.60

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 28524 in the body.
You can then email your comments to 28524 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#28524; Package emacs. (Wed, 20 Sep 2017 15:15:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kaushal Modi <kaushal.modi <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 20 Sep 2017 15:15:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Kaushal Modi <kaushal.modi <at> gmail.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: 26.0.60; Truncation in %d displayed numbers in minor mode lighter
Date: Wed, 20 Sep 2017 13:44:49 +0000
[Message part 1 (text/plain, inline)]
Hello,

This issue is a regression from emacs 25.x.

I discovered this issue while using multiple-cursors package that uses a
dynamic minor mode lighter that shows the active number of multiple cursors.

(defcustom mc/mode-line
  `(" mc:" (:eval (format ,(propertize "%d" 'face 'font-lock-warning-face)
                          (mc/num-cursors))))
  "What to display in the mode line while multiple-cursors-mode is active."
  :group 'multiple-cursors)

Ref:
https://github.com/magnars/multiple-cursors.el/blob/10752700084595bb24712c27ba70a2326302e45b/multiple-cursors-core.el#L523-L527

But the issue can be easily recreated using this dummy code:

=====
(defvar test-cache 0)

(defconst test-format-mode-lighter
  `(" test:" (:eval (format ,(propertize "%d" 'face
'font-lock-warning-face) (test-incr)))))

(defun test-incr ()
  (setq test-cache (1+ test-cache))
  test-cache)

(define-minor-mode test-format-mode
  "Test that the dynamic minor mode lighter does not get truncated."
  :lighter test-format-mode-lighter
  (unless test-format-mode
    (setq test-cache 0)))
=====

1. Start emacs -Q (emacs 26+).
2. Evaluate the above dummy code snippet.
3. M-x test-format-mode

You will see this:
[image: image.png]

4. Now move the cursor around.. you will see the number after "test:"
increment.. once it reaches 9, the next increment would be 10.. but then
the numbers disappear altogether. You see this now:

[image: image.png]

Upon doing C-h v test-format-mode-lighter, I see:

test-format-mode-lighter’s value is
(" test:"
 (:eval
   (format
    #("%d" 0 2
      (face font-lock-warning-face))
    (test-incr))))


I don't understand the exact meaning of those numbers "0 2", but looks like
that limits the number of characters to be displayed after "test:"?

As a quick hack, I replace the "%d" in that variable with "%-3d".

Now the C-h v gives:

test-format-mode-lighter’s value is
(" test:"
 (:eval
   (format
    #("%-3d" 0 4
      (face font-lock-warning-face))
    (test-incr))))

So the number of character limit got raised because "%-3d" is literally 4
characters.

If I make that "%-10d".. the limit is literally 5 characters!!

test-format-mode-lighter’s value is
(" test:"
 (:eval
   (format
    #("%-10d" 0 5
      (face font-lock-warning-face))
    (test-incr))))

This strange truncation behavior did not exist on emacs 25+.

My guess is that the

In GNU Emacs 26.0.60 (build 3, x86_64-pc-linux-gnu, GTK+ Version 2.24.23)
 of 2017-09-20
Repository revision: f16a8d5dbd3bb8a319c951bdde9a6a75dbdb8c17
Windowing system distributor 'The X.Org Foundation', version 11.0.60900000
System Description: Red Hat Enterprise Linux Workstation release 6.6
(Santiago)

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --with-modules
 --prefix=/home/kmodi/usr_local/apps/6/emacs/emacs-26
 '--program-transform-name=s/^ctags$/ctags_emacs/'
 'CPPFLAGS=-I/home/kmodi/usr_local/6/include -I/usr/include/freetype2
 -I/usr/include' 'CFLAGS=-ggdb3 -O0' 'CXXFLAGS=-ggdb3 -O0'
 'LDFLAGS=-L/home/kmodi/usr_local/6/lib -L/home/kmodi/usr_local/6/lib64
 -ggdb3'
 PKG_CONFIG_PATH=/home/kmodi/usr_local/6/lib/pkgconfig:/home/kmodi/usr_local/6/lib64/pkgconfig:/cad/adi/apps/gnu/linux/x86_64/6/lib/pkgconfig:/cad/adi/apps/gnu/linux/x86_64/6/lib64/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig:/lib64/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK2 X11 MODULES

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-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
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message subr-x puny seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils elec-pair time-date
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type 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 elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame 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 charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote dbusbind inotify
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 97048 7622)
 (symbols 48 20814 1)
 (miscs 40 42 119)
 (strings 32 28795 1337)
 (string-bytes 1 765341)
 (vectors 16 14940)
 (vector-slots 8 508725 5443)
 (floats 8 48 73)
 (intervals 56 245 0)
 (buffers 992 11)
 (heap 1024 21678 835))

-- 

Kaushal Modi
[Message part 2 (text/html, inline)]
[image.png (image/png, inline)]
[image.png (image/png, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28524; Package emacs. (Wed, 20 Sep 2017 16:17:01 GMT) Full text and rfc822 format available.

Message #8 received at 28524 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Kaushal Modi <kaushal.modi <at> gmail.com>
Cc: 28524 <at> debbugs.gnu.org
Subject: Re: bug#28524: 26.0.60;
 Truncation in %d displayed numbers in minor mode lighter
Date: Wed, 20 Sep 2017 19:15:55 +0300
> From: Kaushal Modi <kaushal.modi <at> gmail.com>
> Date: Wed, 20 Sep 2017 13:44:49 +0000
> 
> (defvar test-cache 0)
> 
> (defconst test-format-mode-lighter
> `(" test:" (:eval (format ,(propertize "%d" 'face 'font-lock-warning-face) (test-incr)))))
> 
> (defun test-incr ()
> (setq test-cache (1+ test-cache))
> test-cache)
> 
> (define-minor-mode test-format-mode
> "Test that the dynamic minor mode lighter does not get truncated."
> :lighter test-format-mode-lighter
> (unless test-format-mode
> (setq test-cache 0)))
> =====
> 
> 1. Start emacs -Q (emacs 26+).
> 2. Evaluate the above dummy code snippet.
> 3. M-x test-format-mode
> 
> You will see this:
> image.png
> 
> 4. Now move the cursor around.. you will see the number after "test:" increment.. once it reaches 9, the next
> increment would be 10.. but then the numbers disappear altogether. You see this now:
> 
> image.png
> 
> Upon doing C-h v test-format-mode-lighter, I see:
> 
> test-format-mode-lighter’s value is
> (" test:"
> (:eval
> (format
> #("%d" 0 2
> (face font-lock-warning-face))
> (test-incr))))
> 
> I don't understand the exact meaning of those numbers "0 2", but looks like that limits the number of
> characters to be displayed after "test:"?

No, it means that the face covers 2 characters starting with the first
one.

> As a quick hack, I replace the "%d" in that variable with "%-3d".
> 
> Now the C-h v gives:
> 
> test-format-mode-lighter’s value is
> (" test:"
> (:eval
> (format
> #("%-3d" 0 4
> (face font-lock-warning-face))
> (test-incr))))
> 
> So the number of character limit got raised because "%-3d" is literally 4 characters.
> 
> If I make that "%-10d".. the limit is literally 5 characters!!

Which is all correct, the problem, if there is one, is elsewhere.

I don't think I understand all the complexity you've gone through,
because this works for me in the current emacs-26 branch:

  (insert (format (propertize "%d" 'face 'font-lock-warning-face) 10))

How is this different from what you do?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28524; Package emacs. (Wed, 20 Sep 2017 16:20:02 GMT) Full text and rfc822 format available.

Message #11 received at 28524 <at> debbugs.gnu.org (full text, mbox):

From: Kaushal Modi <kaushal.modi <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 28524 <at> debbugs.gnu.org
Subject: Re: bug#28524: 26.0.60; Truncation in %d displayed numbers in minor
 mode lighter
Date: Wed, 20 Sep 2017 16:18:53 +0000
[Message part 1 (text/plain, inline)]
On Wed, Sep 20, 2017 at 12:16 PM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > I don't understand the exact meaning of those numbers "0 2", but looks
> like that limits the number of
> > characters to be displayed after "test:"?
>
> No, it means that the face covers 2 characters starting with the first
> one.
>

Thanks.

I don't think I understand all the complexity you've gone through,
> because this works for me in the current emacs-26 branch:
>
>   (insert (format (propertize "%d" 'face 'font-lock-warning-face) 10))
>

That works, and so I had to come up with this recipe. Can you see the
problem too if you follow this recipe? Did you also see the screenshots I
took based on this recipe in emacs -Q?


> How is this different from what you do?
>

It probably has something to do with a function call (test-incr) instead of
a static value like 10?
-- 

Kaushal Modi
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28524; Package emacs. (Wed, 20 Sep 2017 19:35:02 GMT) Full text and rfc822 format available.

Message #14 received at 28524 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Kaushal Modi <kaushal.modi <at> gmail.com>
Cc: 28524 <at> debbugs.gnu.org
Subject: Re: bug#28524: 26.0.60; Truncation in %d displayed numbers in minor
 mode lighter
Date: Wed, 20 Sep 2017 22:33:53 +0300
> From: Kaushal Modi <kaushal.modi <at> gmail.com>
> Date: Wed, 20 Sep 2017 16:18:53 +0000
> Cc: 28524 <at> debbugs.gnu.org
> 
> Can you see the problem too if you follow this recipe?

No, not really.  What I do see is that _sometimes_, very rarely, the
number disappears from the mode line, and sometimes it's there, but
without the face.  However, mostly it is there, and with the right
face, well after the count gets beyond 10.  So the problem is more
subtle than what you seem to think.

> Did you also see the screenshots I took based on this recipe in emacs -Q?

Yes.

>  How is this different from what you do?
> 
> It probably has something to do with a function call (test-incr) instead of a static value like 10?

Maybe.  Not sure.  My question was trying to encourage you to
investigate on your own.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28524; Package emacs. (Fri, 13 Aug 2021 13:08:01 GMT) Full text and rfc822 format available.

Message #17 received at 28524 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Kaushal Modi <kaushal.modi <at> gmail.com>
Cc: 28524 <at> debbugs.gnu.org
Subject: Re: bug#28524: 26.0.60; Truncation in %d displayed numbers in minor
 mode lighter
Date: Fri, 13 Aug 2021 15:07:27 +0200
Kaushal Modi <kaushal.modi <at> gmail.com> writes:

> 4. Now move the cursor around.. you will see the number after "test:"
> increment.. once it reaches 9, the next increment would be 10.. but then the
> numbers disappear altogether. You see this now:

(I'm going through old bug reports that unfortunately were not resolved
at the time.)

I tried reproducing this in Emacs 26.1 (and Emacs 28), but was unable
to -- I could see no display glitches in the mode line like in the
images included here.

Are you still seeing this issue in recent Emacs versions?

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




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 13 Aug 2021 13:08:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28524; Package emacs. (Fri, 13 Aug 2021 13:48:01 GMT) Full text and rfc822 format available.

Message #22 received at 28524 <at> debbugs.gnu.org (full text, mbox):

From: Kaushal Modi <kaushal.modi <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 28524 <at> debbugs.gnu.org
Subject: Re: bug#28524: 26.0.60; Truncation in %d displayed numbers in minor
 mode lighter
Date: Fri, 13 Aug 2021 09:46:21 -0400
[Message part 1 (text/plain, inline)]
Hi Lars,

Thank you for following up on this issue.

I just reran the recipe on the Emacs 28.0.50 build that I have:

Emacs version: GNU Emacs 28.0.50 (build 5, x86_64-pc-linux-gnu, GTK+
Version 3.22.30, cairo version 1.15.12)
 of 2021-08-10, built using commit 1572464b9271472b8d7a36b698541afc59b44870.

./configure options:
  --prefix=/home/kmodi/usr_local/apps/7/emacs/master
'--program-transform-name=s/^ctags$/ctags_emacs/' --with-modules
--with-harfbuzz --with-native-compilation
CPPFLAGS=-I/home/kmodi/stowed/7/include 'CFLAGS=-O2 -march=native'
'LDFLAGS=-L/home/kmodi/stowed/7/lib -L/home/kmodi/stowed/7/lib64'

Features:
  ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LIBOTF LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3
ZLIB

Now I do not see those numbers disappearing in the mode-line even when they
get to 2 digits.

[I also noted that now my build options related to GUI are a bit different
than what I reported with earlier. Earlier, I was on RHEL 6.8, and now I am
on CentOS 7. In any case, I cannot reproduce that issue on my build.]

This issue can be closed.

[image: image.png]


Thanks!

--
Kaushal Modi


On Fri, Aug 13, 2021 at 9:07 AM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> Kaushal Modi <kaushal.modi <at> gmail.com> writes:
>
> > 4. Now move the cursor around.. you will see the number after "test:"
> > increment.. once it reaches 9, the next increment would be 10.. but then
> the
> > numbers disappear altogether. You see this now:
>
> (I'm going through old bug reports that unfortunately were not resolved
> at the time.)
>
> I tried reproducing this in Emacs 26.1 (and Emacs 28), but was unable
> to -- I could see no display glitches in the mode line like in the
> images included here.
>
> Are you still seeing this issue in recent Emacs versions?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no
>
[Message part 2 (text/html, inline)]
[image.png (image/png, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28524; Package emacs. (Fri, 13 Aug 2021 13:52:01 GMT) Full text and rfc822 format available.

Message #25 received at 28524 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Kaushal Modi <kaushal.modi <at> gmail.com>
Cc: 28524 <at> debbugs.gnu.org
Subject: Re: bug#28524: 26.0.60; Truncation in %d displayed numbers in minor
 mode lighter
Date: Fri, 13 Aug 2021 15:51:07 +0200
Kaushal Modi <kaushal.modi <at> gmail.com> writes:

> [I also noted that now my build options related to GUI are a bit different than
> what I reported with earlier. Earlier, I was on RHEL 6.8, and now I am on
> CentOS 7. In any case, I cannot reproduce that issue on my build.]
>
> This issue can be closed.

Thanks for checking; closing this bug report, then.

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




bug closed, send any further explanations to 28524 <at> debbugs.gnu.org and Kaushal Modi <kaushal.modi <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 13 Aug 2021 13:52:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 11 Sep 2021 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 220 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.