unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: Difficulties with `purecopy' discarding text properties from strings
Date: Sat, 20 May 2017 10:29:32 +0000	[thread overview]
Message-ID: <20170520102932.GA4616@acm.fritz.box> (raw)
In-Reply-To: <831srk36ee.fsf@gnu.org>

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 <acm@muc.de>
> > Cc: emacs-devel@gnu.org

> > > 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	other threads:[~2017-05-20 10:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-19 18:55 Difficulties with `purecopy' discarding text properties from strings Alan Mackenzie
2017-05-19 19:11 ` Daniel Colascione
2017-05-19 20:04   ` Alan Mackenzie
2017-05-19 19:22 ` Stefan Monnier
2017-05-19 19:54   ` Alan Mackenzie
2017-05-19 21:04     ` Eli Zaretskii
2017-05-20 10:29       ` Alan Mackenzie [this message]
2017-05-20  2:58     ` Stefan Monnier
2017-05-20 10:40       ` Alan Mackenzie

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170520102932.GA4616@acm.fritz.box \
    --to=acm@muc.de \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).