emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-orgmode@gnu.org
Subject: Re: Go to heading using LISP
Date: Mon, 10 Jun 2013 12:26:18 +0800	[thread overview]
Message-ID: <8738sq7frp.fsf@ericabrahamsen.net> (raw)
In-Reply-To: loom.20130609T161221-446@post.gmane.org

Alexander Wingård <alexander.wingard@gmail.com> 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	other threads:[~2013-06-10  4:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-08 13:52 Go to heading using LISP Alexander Wingård
2013-06-09  1:36 ` Eric Abrahamsen
2013-06-09 14:43   ` Alexander Wingård
2013-06-10  4:26     ` Eric Abrahamsen [this message]
2013-06-10  5:53       ` Jambunathan K
2013-06-10 19:00 ` Myles English
2013-06-10 21:14   ` Alexander Wingård
2013-06-19 18:24     ` Alexander Wingård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8738sq7frp.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).