emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Go to heading using LISP


From: Eric Abrahamsen
Subject: Re: [O] Go to heading using LISP
Date: Mon, 10 Jun 2013 12:26:18 +0800
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux)

Alexander Wingård <address@hidden> writes:

> Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
>
>> 
>> Alexander Wingård <alexander.wingard <at> gmail.com> writes:
>> 
>> > Hi!
>> >
>> > I want to create special key-bindings that use the org-refile goto
>> > interface to jump to specific headings.
> More specific example, let's say I want to bind keys in my .emacs file:
>
> "C-c b" -> find "gtd.org" and jump to "Projects/Work/Bugs"
> "C-c m" -> find "gtd.org" and jump to "Projects/Work/Meetings"
>> >
>> > My initial attempt was:
>> > (org-refile 4 "gtd.org" "Projects/Work/Bugs")
>> >
>> > But it seems specifying RFLOC is not that simple.
>> >
>> > Someone have any idea how to achieve this or another way to jump to a
>> > heading?
>> 
>> Is the `org-goto' interface close enough? It only does the current
>> buffer, but you can set org-goto-interface to make it behave a fair bit
>> like refile...
> I've looked at that function aswell but it seems even harder to achieve 
> what I want with: Call it from lisp without any user interaction. If you think
> that is possible I would love an example.

Ah, I see. Well, if you're just looking for a lisp function to jump to a
headline, you could use `org-refile-get-targets' to produce a full table
of all the possible refile targets, and then choose among them. (assoc
"gtd.org/Projects/Work/Bugs" (org-refile-get-targets)) will find the
right heading, then I guess the value of point is in that heading
somewhere -- you can visit the file and goto-point.

But if you're just looking to bind a bunch of keys to "jump to specific
heading" commands, I'd use custom ids. Give all the headings in question
ID properties, and then just use something like this:

(global-set-key (kbd "C-c b") (lambda () (org-id-open
"f1d05552-1dce-4004-a914-d2b092d8470e")))

Hope that helps,
Eric




reply via email to

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