Re: Propertize C string for percent position in mode-line?

Eli Zaretskii <[email protected]> Tue, 07 Jul 2026 14:18:18 +0300
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
> Date: Tue, 7 Jul 2026 12:02:55 +0200
> From: Frank Steiner <[email protected]>
> 
> Hi,
> 
> I wonder if there is any way to show "percent position" (%p or %o) in
> the mode-line with a property *and* restricting it to 3 chars, i.e.
> showing "Bot" instead of "Bottom".
> 
> Currently I have
> 
> (propertize "L%l C%c %o" 'face 'modeline-blue-face 'display '(min-width (15.0)))
> 
> showing line/column/percent in blue and giving the block a min-width
> so that the following buffer name is at a somewhat fixed position.
> 
> Unfortunately, "%o" and "%p" both show "Bottom" although the help-text
> (at least for mode-line-format) says they would show "Bot". I'm aware of
> 'mode-line-percent-position but from the email archive I've learned it
> cannot be propertized because (-3 "%o") is a C string and not a Lisp string.

No, "%o" is not a C string, since it is defined (by your Lisp code) in
Lisp.

This works for me:

  (setq mode-line-format (list -3 '(:propertize "%o" face warning)))