How can I match the values for the keys (org mode attributes) #+label
OR #+name
?
Example: Using get-labels ()
I got fig:foo
. Nice.
How can I get fig:bar
as well?
#+label: fig:foo
#+name: fig:bar
While this one works for #+label
:
(re-search-forward "#\\+label: \\([a-zA-z0-9:-]*\\)" (point-max) t)
This one fails i.e. matches only #+name
:
(re-search-forward "#\\+label:\\|#\\+name: \\([a-zA-z0-9:-]*\\)" (point-max) t)
Used here
(defun get-labels ()
(interactive)
(save-excursion
(goto-char (point-min))
(let ((matches '()))
(while (re-search-forward "#\\+label: \\([a-zA-z0-9:-]*\\)" (point-max) t)
(add-to-list 'matches (match-string-no-properties 1) t))
matches)))
.
# -*- mode: snippet -*-
# --
cref:${1:$$(yas-choose-value (get-labels))} $0