From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: [PATCH] Fix the single quote printed in the message printed by org-table-edit-formulas Date: Thu, 10 Mar 2016 22:22:41 -0500 Message-ID: References: <87oaamuw2q.fsf@kyleam.com> <56E221EA.4080106@cs.ucla.edu> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c17ad6fb93a6052dbd7390 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aeDfg-0000un-9i for emacs-orgmode@gnu.org; Thu, 10 Mar 2016 22:23:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aeDfe-0005S0-Ar for emacs-orgmode@gnu.org; Thu, 10 Mar 2016 22:23:24 -0500 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:36438) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aeDfe-0005Rw-1e for emacs-orgmode@gnu.org; Thu, 10 Mar 2016 22:23:22 -0500 Received: by mail-oi0-x232.google.com with SMTP id r187so76642884oih.3 for ; Thu, 10 Mar 2016 19:23:21 -0800 (PST) In-Reply-To: <56E221EA.4080106@cs.ucla.edu> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Paul Eggert Cc: Kyle Meyer , emacs-org list --001a11c17ad6fb93a6052dbd7390 Content-Type: text/plain; charset=UTF-8 On Thu, Mar 10, 2016 at 8:39 PM, Paul Eggert wrote: > Help strings are considered documentation, so you need to escape special > characters in help-echo property strings the same way you'd escape them in > doc strings. Something like this: > > (let* ((str1 "\nhello") > (echo-str1 "left single quote (`) right single quote (') grave > accent (\\=`) apostrophe (\\=') kill-region (\\[kill-region])") > ov) > (let* ((b (+ 1 (point))) > (e (+ b (string-width str1)))) > (insert str1) > (setq ov (make-overlay b e))) > (overlay-put ov 'help-echo echo-str1)) > Thanks Paul. That was very educational. So it turns out that we do not need substitute-command-keys at all for help-echo text. Below is now the latest patch = previous patch + help-echo straight quote fix. >From a897b6e37708cd836ea9576b43006075af80e062 Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Thu, 10 Mar 2016 22:12:44 -0500 Subject: [PATCH] Display quotes in key-bindings as straight quotes * lisp/org-agenda.el (org-agenda-show-the-flagging-note): * lisp/org-footnote.el (org-footnote-goto-definition): * lisp/org-table.el (org-table-edit-formulas): (org-table-align): Straight quote fix * lisp/org-protocol.el (org-protocol-create-for-org): * lisp/org-table.el (org-table-sum): Minor reformatting http://thread.gmane.org/gmane.emacs.orgmode/105594 Fix the quote style displayed when key-bindings are shown in the echo via (message .. (substitute-command-keys ..)). Starting from emacs 25.1, a straight quote is rendered as a right-curly quote by default. So below will render that single quote as curly. (message "C-c '") The fix is to print that quote verbatim using the "%s" modifier: (message "%s" "C-c '") Also an help-echo text property value was fixed in org-table-align. substitute-command-keys should not be used in that. Instead \\[COMMAND] should be used directly in the string. --- lisp/org-agenda.el | 5 +++-- lisp/org-footnote.el | 7 +++---- lisp/org-protocol.el | 2 +- lisp/org-table.el | 17 +++++++---------- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 876ea44..cd69c74 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -10107,8 +10107,9 @@ tag and (if present) the flagging note." (replace-match "\n" t t)) (goto-char (point-min)) (select-window win) - (message (substitute-command-keys "Flagging note pushed to kill ring. \ -Press \\[org-agenda-show-the-flagging-note] again to remove tag and note"))))) + (message "%s" (substitute-command-keys "Flagging note pushed to \ +kill ring. Press \\[org-agenda-show-the-flagging-note] again to remove \ +tag and note"))))) (defun org-agenda-remove-flag (marker) "Remove the FLAGGED tag and any flagging note in the entry." diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index e80685a..a847326 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -531,10 +531,9 @@ value if point was successfully moved." (goto-char (match-end 0)) (org-show-context 'link-search) (when (derived-mode-p 'org-mode) - (message - (substitute-command-keys - "Edit definition and go back with `\\[org-mark-ring-goto]' or, if \ -unique, with `\\[org-ctrl-c-ctrl-c]'."))) + (message "%s" (substitute-command-keys + "Edit definition and go back with \ +`\\[org-mark-ring-goto]' or, if unique, with `\\[org-ctrl-c-ctrl-c]'."))) t)) (defun org-footnote-goto-previous-reference (label) diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el index a249c9e..6510733 100644 --- a/lisp/org-protocol.el +++ b/lisp/org-protocol.el @@ -669,7 +669,7 @@ delegates most of the work to `org-protocol-create'." (require 'org-publish) (let ((all (or (org-publish-get-project-from-filename buffer-file-name)))) (if all (org-protocol-create (cdr all)) - (message "Not in an org-project. Did mean %s?" + (message "Not in an org-project. Did you mean `%s'?" (substitute-command-keys"\\[org-protocol-create]"))))) (defun org-protocol-create (&optional project-plist) diff --git a/lisp/org-table.el b/lisp/org-table.el index 488c912..df81944 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -795,9 +795,8 @@ When nil, simply write \"#ERROR\" in corrupted fields.") (org-add-props x nil 'help-echo (concat - (substitute-command-keys - "Clipped table field, use \\[org-table-edit-field] to \ -edit. Full value is:\n") + "Clipped table field, use \\[org-table-edit-field] \ +to edit. Full value is:\n" (substring-no-properties x))) (let ((l (length x)) (f1 (min fmax @@ -2136,11 +2135,10 @@ If NLAST is a number, only the NLAST fields will actually be summed." s diff) (format "%.0f:%02.0f:%02.0f" h m s)))) (kill-new sres) - (if (org-called-interactively-p 'interactive) - (message "%s" - (substitute-command-keys - (format "Sum of %d items: %-20s (\\[yank] will insert result into buffer)" - (length numbers) sres)))) + (when (org-called-interactively-p 'interactive) + (message "%s" (substitute-command-keys + (format "Sum of %d items: %-20s \ +(\\[yank] will insert result into buffer)" (length numbers) sres)))) sres)))) (defun org-table-get-number-for-summing (s) @@ -3591,8 +3589,7 @@ Parameters get priority." (when (eq org-table-use-standard-references t) (org-table-fedit-toggle-ref-type)) (org-goto-line startline) - (message - (substitute-command-keys "\\\ + (message "%s" (substitute-command-keys "\\\ Edit formulas, finish with `\\[org-ctrl-c-ctrl-c]' or `\\[org-edit-special]'. \ See menu for more commands."))))) -- 2.6.0.rc0.24.gec371ff -- Kaushal Modi --001a11c17ad6fb93a6052dbd7390 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On Thu, Mar 10, 2016 at 8:39 PM, Paul Eggert <eggert@cs.ucla.edu>= wrote:
Help strings are considered documentation, so you need to esca= pe special characters in help-echo property strings the same way you'd = escape them in doc strings. Something like this:

(let* ((str1 "\nhello")
=C2=A0 =C2=A0 =C2=A0 =C2=A0(echo-str1 "left single quote (`) right sin= gle quote (') grave accent (\\=3D`) apostrophe (\\=3D') kill-region= (\\[kill-region])")
=C2=A0 =C2=A0 =C2=A0 =C2=A0ov)
=C2=A0 (let* ((b (+ 1 (point)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(e (+ b (string-width str1))))
=C2=A0 =C2=A0 (insert str1)
=C2=A0 =C2=A0 (setq ov (make-overlay b e)))
=C2=A0 (overlay-put ov 'help-echo echo-str1))
<= br>Thanks Paul. That was very educational. So it turns out that we do not n= eed substitute-command-keys at all for help-echo text.

Below is now the latest pa= tch =3D previous patch + help-echo straight quote fix.

From a897b6e37708cd836ea9576b43006075af80e062 Mon Sep 17 00:00:00 2001
From: Kaushal Modi <kaushal.modi@gmail.com>
Date: Thu, 10 Mar 2016 22:12:44 -0500
Subject: [PATCH] Display quotes in key-bindings as straight quotes
<= div class=3D"gmail_extra">
* lisp/org-a= genda.el (org-agenda-show-the-flagging-note):
* lisp/org-footnote.el (org-footnote-goto-definition):
* lisp/org-table.el (org-table-edit-formulas):
(org-table-align): Straight quote fix

* lisp/org-protocol.e= l (org-protocol-create-for-org):
* lisp/org= -table.el (org-table-sum): Minor reformatting


Fix the quote style displayed when key-bindings are shown in
the echo via (message .. (substitute-command-keys ..)).=

Start= ing from emacs 25.1, a straight quote is rendered as a right-curly
quote by default.
<= br>
So below will render that single quote = as curly.

(message "C-c '")

The fix is to print that quote verbatim using= the "%s" modifier:

(message "%s" "C-c '")

Also an he= lp-echo text property value was fixed in org-table-align.
substitute-command-keys should not be used in that. Instea= d \\[COMMAND]
should be used directly in th= e string.
---
=C2=A0lisp/org-agenda.el =C2=A0 | =C2=A05 +++--
=C2=A0lisp/org-footnote.el | =C2=A07 +++----
=C2=A0lisp/org-protocol.el | =C2=A02 +-
=C2=A0lisp/org-table.el =C2=A0 =C2=A0| 17 +++++++----------
=C2=A04 files changed, 14 insertions(+), 17 deletio= ns(-)

= diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 876ea44..cd69c74 100644
---= a/lisp/org-agenda.el
+++ b/lisp/org-agenda= .el
@@ -10107,8 +10107,9 @@ tag and (if pre= sent) the flagging note."
=C2=A0 (replace-match "\n" = t t))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char= (point-min))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(s= elect-window win)
- =C2=A0 =C2=A0 =C2=A0(me= ssage (substitute-command-keys "Flagging note pushed to kill ring. =C2= =A0\
-Press \\[org-agenda-show-the-flagging= -note] again to remove tag and note")))))
+ =C2=A0 =C2=A0 =C2=A0(message "%s" (substitute-command-keys = "Flagging note pushed to \
+kill ring.= =C2=A0 Press \\[org-agenda-show-the-flagging-note] again to remove \
<= div class=3D"gmail_extra">+tag and note")))))
=C2=A0
=C2=A0(defun org-agenda-remo= ve-flag (marker)
=C2=A0 =C2=A0"Remove = the FLAGGED tag and any flagging note in the entry."
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index e80685a..a847326 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -531,10 +53= 1,9 @@ value if point was successfully moved."
=C2=A0 =C2=A0 =C2=A0(goto-char (match-end 0))
=C2=A0 =C2=A0 =C2=A0(org-show-context 'link-search)
=C2=A0 =C2=A0 =C2=A0(when (derived-mode-p 'org= -mode)
- =C2=A0 =C2=A0 =C2=A0(message
=
- =C2=A0 =C2=A0 =C2=A0 (substitute-command-keys<= /div>
- "Edit definition and go back with `\\[org-mark-ring-goto]'= ; or, if \
-unique, with `\\[org-ctrl-c-ctr= l-c]'.")))
+ =C2=A0 =C2=A0 =C2=A0(= message "%s" (substitute-command-keys
+ =C2=A0 =C2=A0 &q= uot;Edit definition and go back with \
+`\\= [org-mark-ring-goto]' or, if unique, with `\\[org-ctrl-c-ctrl-c]'.&= quot;)))
=C2=A0 =C2=A0 =C2=A0t))
=C2=A0
=C2=A0(defun o= rg-footnote-goto-previous-reference (label)
diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index a249c9e..6510733 100644
--- a/lisp/org-protocol.el
+++ b/lisp/o= rg-protocol.el
@@ -669,7 +669,7 @@ delegate= s most of the work to `org-protocol-create'."
=C2=A0 =C2=A0(require 'org-publish)
=C2=A0 =C2=A0(let ((all (or (org-publish-get-project-from-filename= buffer-file-name))))
=C2=A0 =C2=A0 =C2=A0(= if all (org-protocol-create (cdr all))
- = =C2=A0 =C2=A0 =C2=A0(message "Not in an org-project.=C2=A0 Did mean %s= ?"
+ =C2=A0 =C2=A0 =C2=A0(message &quo= t;Not in an org-project.=C2=A0 Did you mean `%s'?"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (s= ubstitute-command-keys"\\[org-protocol-create]")))))
=C2=A0
=C2=A0(defun org= -protocol-create (&optional project-plist)
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 488c912..df81944 100644
-= -- a/lisp/org-table.el
+++ b/lisp/org-table= .el
@@ -795,9 +795,8 @@ When nil, simply wr= ite \"#ERROR\" in corrupted fields.")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 (org-add-props x nil
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 'help-ec= ho
=C2=A0 =C2=A0 =C2=A0 (concat
- = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(substitute-command-keys
- =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Clipp= ed table field, use \\[org-table-edit-field] to \
-edit.=C2=A0 Full value is:\n")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &q= uot;Clipped table field, use \\[org-table-edit-field] \
+to edit.=C2=A0 Full value is:\n"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(substring-no-properties x)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (= let ((l (length x))
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (f1 (= min fmax
@@ -2136,11 +2135,10 @@ If NLAST i= s a number, only the NLAST fields will actually be summed."
=C2=A0 <= /span> =C2=A0 s diff)
=C2=A0 =C2=A0 =C2=A0 (format "%.0f:%02.= 0f:%02.0f" h m s))))
=C2=A0 (kill-new sres)
- (if (org-c= alled-interactively-p 'interactive)
- =C2=A0 =C2=A0(message &qu= ot;%s"
- =C2=A0 =C2=A0 (substitute-command-keys
- = =C2=A0 =C2=A0 =C2=A0(format "Sum of %d items: %-20s =C2=A0 =C2=A0 (\\[= yank] will insert result into buffer)"
- =C2=A0 =C2=A0 =C2= =A0(length numbers) sres))))
+ (when (org-called-interactively-p &= #39;interactive)
+ =C2=A0 =C2=A0(message "%s" (substitute= -command-keys
+ =C2=A0 (format "Sum of %d items: %-20s =C2= =A0 =C2=A0 \
+(\\[yank] will insert result = into buffer)" (length numbers) sres))))
=C2=A0 sres))))
=C2=A0
=C2=A0(defu= n org-table-get-number-for-summing (s)
@@ -= 3591,8 +3589,7 @@ Parameters get priority."
=C2=A0 =C2=A0 =C2=A0 =C2=A0(when (eq org-table-use-standard-reference= s t)
=C2=A0 (org-table-fedit-toggle-ref-type))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(org-goto-line startline)
- =C2=A0 =C2=A0 =C2=A0(message
- =C2=A0 =C2=A0 =C2=A0 (substitute-command-keys "\\<org-mo= de-map>\
+ =C2=A0 =C2=A0 =C2=A0(message = "%s" (substitute-command-keys "\\<org-mode-map>\
=
=C2=A0Edit formulas, finish with `\\[org-ctrl-c-= ctrl-c]' or `\\[org-edit-special]'. =C2=A0\
=C2=A0See menu for more commands.")))))
=C2=A0
--=C2=A0
2.6.0.rc0.24.gec371ff

=


--
Kaushal Modi
--001a11c17ad6fb93a6052dbd7390--