GNU bug report logs -
#28524
26.0.60; Truncation in %d displayed numbers in minor mode lighter
Previous Next
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.
Full log
Message #8 received at 28524 <at> debbugs.gnu.org (full text, mbox):
> 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?
This bug report was last modified 3 years and 283 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.