From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Function that jumps to an entry with a certain CUSTOM_ID Date: Tue, 31 Mar 2015 21:55:03 +0200 Message-ID: <87mw2tx7qg.fsf@nicolasgoaziou.fr> References: <551ACD1D.6020501@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yd2ET-0000Bh-1Q for emacs-orgmode@gnu.org; Tue, 31 Mar 2015 15:53:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yd2EP-0007DI-FZ for emacs-orgmode@gnu.org; Tue, 31 Mar 2015 15:53:52 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:45630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yd2EP-0007D8-9Q for emacs-orgmode@gnu.org; Tue, 31 Mar 2015 15:53:49 -0400 In-Reply-To: <551ACD1D.6020501@gmail.com> (Christoph LANGE's message of "Tue, 31 Mar 2015 18:36:45 +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: Christoph LANGE Cc: "emacs-orgmode@gnu.org" Hello, Christoph LANGE writes: > the following function has served me well for a few years, so > I thought I'd share it. I would even be happy to contribute it to the > codebase of org-mode (core or contrib); however in this case someone > would have to point me to a fool-proof guide for how to do this. > I know that for contributing code I will have to sign some FSF > copyright forms, and I know how to use git, but I don't know the exact > org-mode specific steps of doing so. The problem is that we're running out of interesting keybindings. "C-c j" is not an option since it is reserved to users. Another option would be to add it to Worg. > --- %< --- %< --- %< --- %< --- %< --- %< --- %< --- %< --- %< --- %< --- > (defun org-jump-to-id () > "Asks for an identifier and searches for the first entry in the > current file that has this identifier as a CUSTOM_ID property." > (interactive) > (let* ((property "CUSTOM_ID") > (custom-id (org-icompleting-read "CUSTOM_ID of entry: " > (mapcar 'list > (org-property-values property))))) > (org-link-search (concat "#" custom-id)))) > > (define-key org-mode-map (kbd "\C-cj") 'org-jump-to-id) > --- %< --- %< --- %< --- %< --- %< --- %< --- %< --- %< --- %< --- %< --- > > This implementation works efficiently in a 4 MB org file with 100 IDs. > Together with ido or helm I find it a very user-friendly way of > jumping to frequently used headlines. Note that you can use (let ((h (org-find-property "CUSTOM_ID" custom-id))) (when h (goto-char h))) instead of (org-link-search ...) for one less level of indirection. > I noticed that org-babel-ref-goto-headline-id does something similar, > so maybe some code could be shared among the two functions. Indeed. I modified it so it uses `org-find-property'. Regards, -- Nicolas Goaziou