From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Difficulties with `purecopy' discarding text properties from strings Date: Sat, 20 May 2017 10:29:32 +0000 Message-ID: <20170520102932.GA4616@acm.fritz.box> References: <20170519185508.GA5330@acm.fritz.box> <20170519195458.GB5330@acm.fritz.box> <831srk36ee.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1495276239 18017 195.159.176.226 (20 May 2017 10:30:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 20 May 2017 10:30:39 +0000 (UTC) User-Agent: Mutt/1.5.24 (2015-08-30) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 20 12:30:34 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dC1ec-0004Yg-KW for ged-emacs-devel@m.gmane.org; Sat, 20 May 2017 12:30:34 +0200 Original-Received: from localhost ([::1]:33698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dC1eh-0006NR-U9 for ged-emacs-devel@m.gmane.org; Sat, 20 May 2017 06:30:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dC1ec-0006NA-4Q for emacs-devel@gnu.org; Sat, 20 May 2017 06:30:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dC1eZ-0005VC-0g for emacs-devel@gnu.org; Sat, 20 May 2017 06:30:34 -0400 Original-Received: from ocolin.muc.de ([193.149.48.4]:44052 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1dC1eY-0005Ue-LN for emacs-devel@gnu.org; Sat, 20 May 2017 06:30:30 -0400 Original-Received: (qmail 80775 invoked by uid 3782); 20 May 2017 10:30:28 -0000 Original-Received: from acm.muc.de (p548C67C5.dip0.t-ipconnect.de [84.140.103.197]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 20 May 2017 12:30:27 +0200 Original-Received: (qmail 4620 invoked by uid 1000); 20 May 2017 10:29:32 -0000 Content-Disposition: inline In-Reply-To: <831srk36ee.fsf@gnu.org> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.4 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:215009 Archived-At: 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 > > 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).