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