emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Achim Gratz <Stromeko@nexgo.de>
To: emacs-orgmode@gnu.org
Subject: Re: [RFC] Org version of the Org manual
Date: Sun, 17 Mar 2013 11:28:29 +0100	[thread overview]
Message-ID: <87r4jeqq0i.fsf@Rainer.invalid> (raw)
In-Reply-To: m1bob8cffh.fsf@tsdye.com

[-- Attachment #1: Type: text/plain, Size: 97 bytes --]

Hi Tom,

I have a patch that should fix your problems with some characters in
macro expansions:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-fix-macro-expansion-with-separators-and-backslashes.patch --]
[-- Type: text/x-patch, Size: 2589 bytes --]

From 27b22d17f629a50bd485a0320dac45616d7ceb7f Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.DE>
Date: Sun, 17 Mar 2013 10:20:10 +0100
Subject: [PATCH] fix macro expansion with separators and backslashes

* lisp/org-element.el (org-element-macro-parser): Do not try to
  "repair bad splits", only split at the correct places.
* lisp/org-macro.el (org-macro-expand): Do not try to interpret the
  macro replacement text as a regex.

Allow to write macros like {{{kbd(\\)}}} and {{{kbd(\\,)}}} and expand
them correctly.  A backslash at the end of an argument was incorrectly
trying to cons the next argument (which may not exist).
---
 lisp/org-element.el | 16 +++++-----------
 lisp/org-macro.el   |  2 +-
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index ba2461a..337cad0 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -3117,20 +3117,14 @@ (defun org-element-macro-parser ()
 	  (post-blank (progn (goto-char (match-end 0))
 			     (skip-chars-forward " \t")))
 	  (end (point))
-	  (args (let ((args (org-match-string-no-properties 3)) args2)
+	  (args (let ((args (org-match-string-no-properties 3)))
 		  (when args
 		    ;; Do not use `org-split-string' since empty
 		    ;; strings are meaningful here.
-		    (setq args (split-string args ","))
-		    (while args
-		      (while (string-match "\\\\\\'" (car args))
-			;; Repair bad splits, when comma is protected,
-                        ;; and thus not a real separator.
-			(setcar (cdr args) (concat (substring (car args) 0 -1)
-						   "," (nth 1 args)))
-			(pop args))
-		      (push (pop args) args2))
-		    (mapcar 'org-trim (nreverse args2))))))
+		    (setq args (replace-regexp-in-string "," "\000" args))
+		    (setq args (replace-regexp-in-string "\\\\\000" "," args))
+		    (setq args (split-string args "\000"))
+		    (mapcar 'org-trim args)))))
       (list 'macro
 	    (list :key key
 		  :value value
diff --git a/lisp/org-macro.el b/lisp/org-macro.el
index 88cbdf7..3e07295 100644
--- a/lisp/org-macro.el
+++ b/lisp/org-macro.el
@@ -137,7 +137,7 @@ (defun org-macro-expand (macro templates)
                                (org-element-property :args macro))
                           ;; No argument: remove place-holder.
                           ""))
-                    template)))
+                    template nil 'literal)))
         ;; VALUE starts with "(eval": it is a s-exp, `eval' it.
         (when (string-match "\\`(eval\\>" value)
           (setq value (eval (read value))))
-- 
1.8.1.4


[-- Attachment #3: Type: text/plain, Size: 226 bytes --]


I hope Nicolas will apply it or make a better patch.  The quoting used
unfortunately is not idempotent, so you need to know how many times your
macro will get expanded, but it is a start.  You should now be able to
do this:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0001-put-back-macros-with-problematic-characters.patch --]
[-- Type: text/x-patch, Size: 2827 bytes --]

From 042ad50bd06cbc5ab97c753cb5cfce8908121242 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.DE>
Date: Sun, 17 Mar 2013 11:27:21 +0100
Subject: [PATCH] put back macros with "problematic characters"

---
 orgmanual.org | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/orgmanual.org b/orgmanual.org
index 6aa6b81..d50b20b 100644
--- a/orgmanual.org
+++ b/orgmanual.org
@@ -4254,13 +4254,10 @@ Priorities can be attached to any outline node; they do not need to be TODO
 items.
 
 #+attr_texinfo: :table-type table :indic @asis
-  - {{{kbd(C-c XXX)}}} ::
+  - {{{kbd(C-c \\,)}}} ::
 
-    {{{kindex(C-c ,)}}}
-    #+comment:    {{{kindex(@kbd{C-c ,})}}}
-    #+comment: Preceding line won't export to pdf
-    {{{findex(org-priority)}}}
-    #+comment: Should be C-c ,
+       {{{kindex(C-c \\,)}}}
+       {{{findex(org-priority)}}}
 
     Set the priority of the current headline (~org-priority~). The
     command prompts for a priority character {{{samp(A)}}}, {{{samp(B)}}}
@@ -9226,9 +9223,7 @@ the other commands, the cursor needs to be in the desired line.
 
 - ~\~ ~org-agenda-filter-by-tag-refine~ ::
 
-  #+comment: {{{kindex(XXX)}}}
-  #+comment: Should be \
-  @@info:kindex \\@@
+  {{{kindex(\)}}}
 
   Narrow the current agenda filter by an additional condition. When
   called with prefix arg, remove the entries that /do/ have the tag, or
@@ -9350,11 +9345,9 @@ the other commands, the cursor needs to be in the desired line.
   Set tags for the current headline. If there is an active region in the
   agenda, change a tag for all headings in the region.
 
-- {{{kbd(,)}}} ::
+- {{{kbd(\\,)}}} ::
 
-  #+comment: {{{kindex(XXX)}}}
-  #+comment: Should be a comma
-  @@info:kindex ,@@
+  {{{kindex(\\,)}}}
 
   Set the priority for the current item (~org-agenda-priority~). Org
   mode prompts for the priority character. If you reply with
@@ -10691,12 +10684,9 @@ If you would like to see entities displayed as UTF8 characters, use the
 following command:[fn:108]
 
 #+attr_texinfo: :table-type table :indic @asis
-- @@info:@kbd{C-c C-x XXX}@@ ::
-
-  #+comment: {{{kindex(C-c C-x XXX)}}}
-  #+comment: Should be \
+- {{{kbd(C-c C-x \)}}} ::
   
-  @@info:kindex C-c C-x \\
+  {{{kindex(C-c C-x \)}}}
 
   Toggle display of entities as UTF-8 characters. This does not change
   the buffer content which remains plain ASCII, but it overlays the
@@ -10740,9 +10730,7 @@ subscript, but ~a_{b}~ will.
 #+attr_texinfo: :table-type table :indic @asis
 - @@info:@kbd{C-c C-x \\}@@ ::
 
-  #+comment: {{{kindex(C-c C-x XXX)}}}
-  #+comment: Should be \
-  @@info:@kindex C-c C-x \@@
+  {{{kindex(C-c C-x \)}}}
 
   In addition to showing entities as UTF-8 characters, this command will
   also format sub- and superscripts in a WYSIWYM way.
-- 
1.8.1.4


[-- Attachment #5: Type: text/plain, Size: 200 bytes --]




Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

  parent reply	other threads:[~2013-03-17 10:28 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-25 20:21 [RFC] Org version of the Org manual Thomas S. Dye
2013-02-25 21:21 ` Carsten Dominik
2013-03-04 21:28 ` Achim Gratz
2013-03-06  3:14   ` Thomas S. Dye
2013-03-06  7:44     ` Yagnesh Raghava Yakkala
2013-03-06  8:18       ` Achim Gratz
2013-03-06  8:29         ` Bastien
2013-03-06  8:40           ` Nicolas Goaziou
2013-03-06  8:44           ` Achim Gratz
2013-03-06 10:18             ` Jambunathan K
2013-03-07 17:35       ` Thomas S. Dye
2013-03-07 18:22         ` Achim Gratz
2013-03-07 18:49           ` Thomas S. Dye
2013-03-09 23:53           ` Thomas S. Dye
2013-03-10 12:24             ` Achim Gratz
2013-03-10 19:01               ` Jonathan Leech-Pepin
2013-03-10 19:25                 ` Achim Gratz
2013-03-10 19:39                   ` Jonathan Leech-Pepin
2013-03-10 20:23                     ` Nicolas Goaziou
2013-03-10 20:40                       ` Jonathan Leech-Pepin
2013-03-11  0:32               ` Thomas S. Dye
2013-03-11  6:43                 ` Achim Gratz
2013-03-11 16:18                   ` Thomas S. Dye
2013-03-16 16:00 ` Achim Gratz
2013-03-17  1:19   ` Thomas S. Dye
2013-03-17  5:50     ` Carsten Dominik
2013-03-17  6:54       ` Achim Gratz
2013-03-17 12:33         ` Carsten Dominik
2013-03-17 13:34           ` Achim Gratz
2013-03-17 15:37             ` Carsten Dominik
2013-03-17 17:36               ` Achim Gratz
2013-03-17 19:58                 ` Carsten Dominik
2013-03-17  7:01       ` Sebastien Vauban
2013-03-17 12:36         ` Carsten Dominik
2013-03-17 10:28 ` Achim Gratz [this message]
2013-03-21 21:02   ` Nicolas Goaziou
2013-03-22  7:50     ` Achim Gratz
2013-03-22 14:22       ` Nicolas Goaziou
2013-03-22 16:46         ` Achim Gratz
2013-03-22 18:17           ` Nicolas Goaziou
2013-03-23  7:32             ` Achim Gratz
2013-03-23 20:17               ` Nicolas Goaziou
2013-04-27 18:16   ` Achim Gratz
2013-04-28  7:29     ` Nicolas Goaziou
2013-04-28  8:28       ` Achim Gratz

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.orgmode.org/

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

  git send-email \
    --in-reply-to=87r4jeqq0i.fsf@Rainer.invalid \
    --to=stromeko@nexgo.de \
    --cc=emacs-orgmode@gnu.org \
    /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/org-mode.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).