emacs-devel
[Top][All Lists]
Advanced

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

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


From: Alan Mackenzie
Subject: Re: Difficulties with `purecopy' discarding text properties from strings
Date: Sat, 20 May 2017 10:29:32 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

Hello, Eli.

On Sat, May 20, 2017 at 00:04:25 +0300, Eli Zaretskii wrote:
> > 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.

I think I was subconsciously worried that redisplay would be reapplying
the text properties at each redisplay.  But either this doesn't happen,
or is no big deal.

I've done not quite what you suggested, but something which I think will
work as well.  The value in mode-line-percent-position is something like
(-3, "%p"), and this gets propertised in mode-line-position.  Please see
my patch in the main thread for this change.

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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