emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [RFC] Syntax for macros


From: Florian Beck
Subject: Re: [O] [RFC] Syntax for macros
Date: Thu, 30 Jan 2014 20:25:33 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 30.01.2014 17:59, Nick Dokos wrote:

Are you advocating that the macro syntax should be changed without
worrying about backwards compatibility? That might work if almost nobody
uses macros currently[fn:1], but my impression is that they are used fairly
widely.

The main problem is that this will affect org files in weeks, months or years in the future, which then mysteriously fail to work as expected. I agree, however, with Sebastien that the current syntax is a bit heavy. Two brackets would be better, but still ugly.

A couple of alternative ideas:

1. How about using unicode characters? This would solve the problem of false positives and allow for light markup. E.g.:

(looking-at "\\(?:「\\|{{{\\)\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\(([ \t\n]* \\([^\000]*?\\))\\)?\\(?:」\\|}}}\\)")

2. On the other hand a function to insert a macro might be all we need, e.g.:

(defun org-macro-insert ()
  (interactive)
  (let* ((macros (org-macro--collect-macros))
         (macro (completing-read "Insert macro: " (mapcar 'car macros)))
         (args (string-match "$[[:digit:]]" (cdr (assoc macro macros))))
         pos)
    (insert (format  "{{{%s" macro))
    (when args (insert "(") (setq pos (point)) (insert ")"))
    (insert "}}}")
    (when pos (goto-char pos))))

Maybe even hide the brackets during fontification?

3. Of course, since macros are only relevant when exporting, it should be easy to write an export filter that translates arbitrary chars to brackets.

--
Florian Beck



reply via email to

[Prev in Thread] Current Thread [Next in Thread]