From: "Juan Manuel Macías" <maciaschain@posteo.net>
To: Eric S Fraga <e.fraga@ucl.ac.uk>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Possibility of using alternative separators in macros
Date: Tue, 11 May 2021 16:12:11 +0000 [thread overview]
Message-ID: <8735ut8d2c.fsf@posteo.net> (raw)
In-Reply-To: <87r1id7cwb.fsf@ucl.ac.uk> (Eric S. Fraga's message of "Tue, 11 May 2021 12:01:08 +0100")
Hello Eric,
It's a typo, sorry: I forgot, when I made the patch, to add the asterisk
to the `let' expression in org-element-macro-parser, therefore the `sep'
variable was not recognized.
The correct function is:
(defun org-element-macro-parser ()
"Parse macro at point, if any.
When at a macro, return a list whose car is `macro' and cdr
a plist with `:key', `:args', `:begin', `:end', `:value', `:sep' and
`:post-blank' as keywords. Otherwise, return nil.
Assume point is at the macro."
(save-excursion
(when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\([^a-zA-Z\s()]?[^-a-zA-Z0-9_\s]?\\)\\((\\([^\000]*?\\))\\)?}}}")
(let* ((begin (point)) ;; <==== missing asterisk :-(
(key (downcase (match-string-no-properties 1)))
(value (match-string-no-properties 0))
(post-blank (progn (goto-char (match-end 0))
(skip-chars-forward " \t")))
(end (point))
(sep (if (not (equal (match-string-no-properties 2) ""))
(match-string-no-properties 2)
","))
(args (pcase (match-string-no-properties 4)
(`nil nil)
(a (org-macro-extract-arguments
sep
(replace-regexp-in-string
"[ \t\r\n]+" " " (org-trim a)))))))
(list 'macro
(list :key key
:value value
:args args
:begin begin
:end end
:sep sep
:post-blank post-blank))))))
Eric S Fraga writes:
> Hello Juan,
>
> On Friday, 30 Apr 2021 at 13:26, Juan Manuel Macías wrote:
>> Hi all,
>>
>> I would like to propose (patch attached) the possibility of using an
>> alternate character for separate arguments in replacement macros,
>> following a suggestion from Nicolas Goaziou in this (closed) thread:
>> https://orgmode.org/list/87o8ead42u.fsf@nicolasgoaziou.fr/
>
> I finally got around to trying this out, applying the patch just now to
> the latest org from the git repository. I get the following when I try
> to export:
>
> Debugger entered--Lisp error: (void-variable sep)
> org-element-macro-parser()
> org-element--object-lex((bold code entity export-snippet
> footnote-reference inline-babel-call inline-src-block italic
> line-break latex-fragment link macro radio-target statistics-cookie
> strike-through subscript superscript target timestamp underline
> verbatim))
> org-element-context()
> org-macro-replace-all((("date" . "") ("title" . "The title")
> ("email" . "") ("author" . "Professor Eric S Fraga") ("lastchange" .
> "2021.03.31 15:03") ("calc" .
> "@@latex:{\\color{green!50!black}\\texttt{ $1 }}@@") ("cite" .
> "[[$2][@@latex:\\vfill\\Citation{$1}@@]]") ("overlay" .
> "@@latex:\\begin{textblock}{$4}($2,$3)@@[[file:$1]]@...") ("parameter"
> . "src_elisp[:results value raw :var $1=(esf/get-para...") ("constant"
> closure (t) (&optional $1 &rest _) (progn (message "Getting constant
> %s" $1) (org-table-get-constant $1))) ("input-file" . "m.org")
> ("modification-time" . #f(compiled-function (arg1 &optional arg2 &rest
> _) #<bytecode 0x1a91bc3b547f3a1c>)) ("keyword" lambda (arg1 &rest _)
> (org-macro--find-keyword-value arg1)) ("n" lambda (&optional arg1 arg2
> &rest _) (org-macro--counter-increment arg1 arg2)) ("property" lambda
> (arg1 &optional arg2 &rest _) (org-macro--get-property arg1 arg2))
> ("time" lambda (arg1 &rest _) (format-time-string arg1)))
> ("DESCRIPTION" "KEYWORDS" "SUBTITLE" "DATE" "TITLE" "DATE" "AUTHOR"))
> org-export-as(latex nil nil nil nil)
> org-export-to-buffer(latex "*Org LATEX Export*" nil nil nil nil nil #f(compiled-function () #<bytecode 0xbb0539acd91d>))
> org-latex-export-as-latex(nil nil nil nil)
> org-export-dispatch(nil)
> funcall-interactively(org-export-dispatch nil)
> command-execute(org-export-dispatch)
next prev parent reply other threads:[~2021-05-11 16:16 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-30 13:26 [PATCH] Possibility of using alternative separators in macros Juan Manuel Macías
2021-05-01 8:30 ` Bastien
2021-05-01 10:04 ` Nicolas Goaziou
2021-05-01 10:17 ` Bastien
2021-05-01 10:18 ` Bastien
2021-05-01 21:50 ` Juan Manuel Macías
2021-05-02 21:08 ` Christian Moe
2021-05-12 11:49 ` Maxim Nikulin
2021-05-16 19:21 ` Christian Moe
2021-05-17 17:03 ` Maxim Nikulin
2021-05-17 18:51 ` Christian Moe
2021-05-02 12:13 ` Eric S Fraga
2021-05-11 11:01 ` Eric S Fraga
2021-05-11 16:12 ` Juan Manuel Macías [this message]
[not found] ` <87im3prvz8.fsf@ucl.ac.uk>
2021-05-11 18:25 ` Juan Manuel Macías
2021-05-15 13:29 ` Bastien
2021-05-15 20:14 ` Juan Manuel Macías
2021-05-15 20:25 ` Bastien
2021-05-15 21:05 ` Juan Manuel Macías
2021-05-16 12:17 ` Bastien
2021-05-16 16:48 ` Maxim Nikulin
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=8735ut8d2c.fsf@posteo.net \
--to=maciaschain@posteo.net \
--cc=e.fraga@ucl.ac.uk \
--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).