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

tpeplt <[email protected]> Tue, 07 Jul 2026 14:13:05 -0400
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
Frank Steiner <[email protected]> writes:

> First of all: you pushed me into the right direction and so my
> result is now
>
> '(:propertize ("L%l C%c " (-3 "%o")) face modeline-blue-face display (min-width (15.0)))
>
> which does exactly what I want. Thank you very much for that!
>
> Eli Zaretskii wrote:
>
>> No, "%o" is not a C string, since it is defined (by your Lisp code) in
>> Lisp.
>
> I got that from https://lists.gnu.org/r/emacs-devel/2021-11/msg01763.html
> and thought you said there that we could not propertize
> mode-line-percent-position for that C-string reason, but I got that wrong.
> It turned out that the whole problem was that I sometimes still don't
> understand when to use ' and when not. 

Typing:

   C-h v mode-line-format

shows that ‘mode-line-format’ is a user option.  Since Emacs
29, the new macro ‘setopt’ should be used to set the values
of user options.  

In addition to executing a possible ‘custom-set’ form
associated with the user option, it can emit a warning when
the type of value does not match the user option’s declared
type, which might have caught your inappropriate quote
error.

Also, you can use the Easy Customization interface to
experiment with and set values for user options.  One way to
access this is:

   M-x customize-option RET
   Customize variable: mode-line-format RET

A feature of the EC interface is the ‘State’ button.  When
you click on it, a menu will pop up which contains, among
other items, two radio buttons.  You can use these buttons
to switch the display of your Lisp expression between the
current value and the Lisp expression that you will
set/save.  This allows you to enter your Lisp value (say, an
email address) and see the corresponding Lisp expression
(say, a string that represents the email address).  This
helps to reduce the confusion and source of errors when
even experience Emacs Lisp programmers do not know the
complete syntax required for a particular user option.


-- 
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.