From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: Go to heading using LISP Date: Mon, 10 Jun 2013 12:26:18 +0800 Message-ID: <8738sq7frp.fsf@ericabrahamsen.net> References: <874nd8awvz.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UltgW-0007Fa-LF for emacs-orgmode@gnu.org; Mon, 10 Jun 2013 00:26:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UltgV-0007Dy-F9 for emacs-orgmode@gnu.org; Mon, 10 Jun 2013 00:26:24 -0400 Received: from plane.gmane.org ([80.91.229.3]:41903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UltgV-0007Ds-8W for emacs-orgmode@gnu.org; Mon, 10 Jun 2013 00:26:23 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UltgT-0006xt-PD for emacs-orgmode@gnu.org; Mon, 10 Jun 2013 06:26:21 +0200 Received: from 114.252.252.196 ([114.252.252.196]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 10 Jun 2013 06:26:21 +0200 Received: from eric by 114.252.252.196 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 10 Jun 2013 06:26:21 +0200 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: emacs-orgmode@gnu.org Alexander Wingård writes: > Eric Abrahamsen ericabrahamsen.net> writes: > >> >> Alexander Wingård 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