From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Org mode links for helm Date: Sun, 25 May 2014 07:28:10 -0400 Message-ID: References: <8738fzu7iq.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c258dcf0c5b704fa37c139 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoWbA-0002Fl-3N for emacs-orgmode@gnu.org; Sun, 25 May 2014 07:28:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WoWb6-0008KG-NY for emacs-orgmode@gnu.org; Sun, 25 May 2014 07:28:16 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Thomas S. Dye" Cc: Bastien , Org-mode --001a11c258dcf0c5b704fa37c139 Content-Type: text/plain; charset=UTF-8 nice. I have similar code in org-ref for a ref links to labels, but it doesn't have #+name in it yet, but it does do table names. You might find the function org-label-store-link ( https://github.com/jkitchin/jmax/blob/master/org-ref.org#label) interesting, so you can use C-c l and C-c C-l to put your links in. I think you could do something like that with #+name. John ----------------------------------- John Kitchin Associate Professor Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 http://kitchingroup.cheme.cmu.edu On Sat, May 24, 2014 at 11:32 PM, Thomas S. Dye wrote: > Aloha Bastien, > > Bastien writes: > > > Hi Thomas, > > > > 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 > > > > ? > > This code, adapted from some code I found on John Kitchin's blog, does > 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. > > All the best, > Tom > -- > Thomas S. Dye > http://www.tsdye.com > > --001a11c258dcf0c5b704fa37c139 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
nice. I have similar code in org-ref=C2=A0 for a ref = links to labels, but it doesn't have #+name in it yet, but it does do t= able names. You might find the function org-label-store-link (https://githu= b.com/jkitchin/jmax/blob/master/org-ref.org#label) interesting, so you = can use C-c l and C-c C-l to put your links in. I think you could do someth= ing like that with #+name.



John<= br>
-----------------------------------
John Kitchin
Associate Pro= fessor
Doherty Hall A207F
Department of Chemical Engineering
Carne= gie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu

<= /div>

On Sat, May 24, 2014 at 11:32 PM, Thomas= S. Dye <tsd@tsdye.com> wrote:
Aloha Bastien,

Bastien <bzg@gnu.org> writes:

> Hi Thomas,
>
> tsd@tsdye.com (Thomas S. Dye) wri= tes:
>
>> Has anyone implemented a helm interface for Org-mode #+name lines?= =C2=A0I
>> think it might be useful for inserting cross reference links.
>
> did you try
>
> https://github.com/emacs-helm/helm/blob/master/helm-org.= el
>
> ?

This code, adapted from some code I found on John Kitchin's blog,= does
what I want.

** Cross references
#+name: tsd-xref
#+begin_src emacs-lisp
(defun tsd-get-names-and-labels ()
=C2=A0 (interactive)
=C2=A0 (save-excursion
=C2=A0 =C2=A0 (goto-char (point-min))
=C2=A0 =C2=A0 (let ((matches '()))
=C2=A0 =C2=A0 =C2=A0 (while (re-search-forward "\\#\\+\\(name\\|label\= \):\\s-\\(.*\\)" (point-max) t)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (add-to-list 'matches (match-string-no-prop= erties 2) t))
=C2=A0 =C2=A0 =C2=A0 matches)))

(defun tsd-org-insert-crossref-link (&optional arg)
=C2=A0 (interactive (list (completing-read "insert: " (tsd-get-na= mes-and-labels))))
=C2=A0 (insert (format "[[%s]]" arg)))
#+end_src

Now, when I'm referring to something I've labeled or named, I call<= br> 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 writi= ng in
LaTeX.

All the best,
Tom
--
Thomas S. Dye
http://www.tsdye.com=


--001a11c258dcf0c5b704fa37c139--