From: Eli Zaretskii <eliz@gnu.org>
To: Kaushal Modi <kaushal.modi@gmail.com>
Cc: 28524@debbugs.gnu.org
Subject: bug#28524: 26.0.60; Truncation in %d displayed numbers in minor mode lighter
Date: Wed, 20 Sep 2017 19:15:55 +0300 [thread overview]
Message-ID: <83d16lfiro.fsf@gnu.org> (raw)
In-Reply-To: <CAFyQvY0F8Bc-phh-ChQER_GxkQCnRSxxVRVotU6zKSmuyujSGQ@mail.gmail.com> (message from Kaushal Modi on Wed, 20 Sep 2017 13:44:49 +0000)
> From: Kaushal Modi <kaushal.modi@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?
next prev parent reply other threads:[~2017-09-20 16:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-20 13:44 bug#28524: 26.0.60; Truncation in %d displayed numbers in minor mode lighter Kaushal Modi
2017-09-20 16:15 ` Eli Zaretskii [this message]
2017-09-20 16:18 ` Kaushal Modi
2017-09-20 19:33 ` Eli Zaretskii
2021-08-13 13:07 ` Lars Ingebrigtsen
2021-08-13 13:46 ` Kaushal Modi
2021-08-13 13:51 ` Lars Ingebrigtsen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83d16lfiro.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=28524@debbugs.gnu.org \
--cc=kaushal.modi@gmail.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 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.