From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Difficulties with `purecopy' discarding text properties from strings Date: Sat, 20 May 2017 00:04:25 +0300 Message-ID: <831srk36ee.fsf@gnu.org> References: <20170519185508.GA5330@acm.fritz.box> <20170519195458.GB5330@acm.fritz.box> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1495227897 10836 195.159.176.226 (19 May 2017 21:04:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 19 May 2017 21:04:57 +0000 (UTC) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 19 23:04:49 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 1dBp4r-0002e9-KC for ged-emacs-devel@m.gmane.org; Fri, 19 May 2017 23:04:49 +0200 Original-Received: from localhost ([::1]:60254 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBp4w-0002Tq-N7 for ged-emacs-devel@m.gmane.org; Fri, 19 May 2017 17:04:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBp4p-0002Te-Uz for emacs-devel@gnu.org; Fri, 19 May 2017 17:04:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBp4m-0001RC-Mr for emacs-devel@gnu.org; Fri, 19 May 2017 17:04:47 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:36143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBp4m-0001Qy-Jx; Fri, 19 May 2017 17:04:44 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4715 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dBp4l-0004Wd-RS; Fri, 19 May 2017 17:04:44 -0400 In-reply-to: <20170519195458.GB5330@acm.fritz.box> (message from Alan Mackenzie on Fri, 19 May 2017 19:54:58 +0000) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:215003 Archived-At: > 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.