Aloha Bastien,
Bastien <bzg@gnu.org> writes:
> Hi Thomas,
>This code, adapted from some code I found on John Kitchin's blog, does
> tsd@tsdye.com (Thomas S. Dye) writes:
>
>> Has anyone implemented a helm interface for Org-mode #+name lines? I
>> think it might be useful for inserting cross reference links.
>
> did you try
>
> https://github.com/emacs-helm/helm/blob/master/helm-org.el
>
> ?
what I want.
** Cross references
#+name: tsd-xref
#+begin_src emacs-lisp
(defun tsd-get-names-and-labels ()
(interactive)
(save-excursion
(goto-char (point-min))
(let ((matches '()))
(while (re-search-forward "\\#\\+\\(name\\|label\\):\\s-\\(.*\\)" (point-max) t)
(add-to-list 'matches (match-string-no-properties 2) t))
matches)))
(defun tsd-org-insert-crossref-link (&optional arg)
(interactive (list (completing-read "insert: " (tsd-get-names-and-labels))))
(insert (format "[[%s]]" arg)))
#+end_src
Now, when I'm referring to something I've labeled or named, I call
tsd-org-insert-crossref-link and helm works on a list of labels and
names defined in the buffer.
It's almost as convenient as using Carsten's reftex mode when writing in
LaTeX.