[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Difficulties with `purecopy' discarding text properties from strings

From: Eli Zaretskii
Subject: Re: Difficulties with `purecopy' discarding text properties from strings
Date: Sat, 20 May 2017 00:04:25 +0300

> Date: Fri, 19 May 2017 19:54:58 +0000
> From: Alan Mackenzie <address@hidden>
> Cc: address@hidden
> > How exactly did you do that?  Using #("..." ...)
> > or using (propertize "..." ...)?
> By using propertize:
> (defun mode-line-%-propertize (str)
>   "Add standard mode-line properties to STR, a string.
> These enable certain mouse operations when the mouse pointer is
> hovering over the display of STR in the mode line."
>   (propertize
>    str
>    'local-map mode-line-column-line-number-mode-map
>    'mouse-face 'mode-line-highlight
>    ;; XXX needs better description
>    'help-echo "Size indication mode\n\
> mouse-1: Display Line and Column Mode Menu"))
> (defcustom mode-line-percent-position `(,(mode-line-%-propertize "%p"))
>   "Type of \"percentage offset\" of window through buffer to display
> This option specifies the type of offset displayed in
> `mode-line-position',
> a component of the default `mode-line-format'."
>   :type `(radio
>           (const :tag "nil:  No offset is displayed" nil)
>           (const :tag "\"%o\": Proportion of \"travel\" of the window through 
> the buffer"
>                  (,(mode-line-%-propertize "%o")))
>           (const :tag "\"%p\": Offset of top of window through buffer"
>                  (,(mode-line-%-propertize "%p")))
>           (const :tag "\"%P\": Offset of bottom of window through buffer"
>                  (,(mode-line-%-propertize "%P")))
>           (const :tag "\"%q\": Offsets of both top and bottom of window"
>                  (,(mode-line-%-propertize "%q"))))
>   :version "26.1"
>   :group 'mode-line)
> (put 'mode-line-percent-position 'risky-local-variable t)

Why can't you do this like mode-line-position already does: it uses a
dispatch on specific modes.  You could add more possibilities to the
dispatch, and have the defcustom control the value by setting some
variable to specific values.  That way, the properties don't need to
be in the defcustom itself.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]