[Top][All Lists]

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

[O] Function that jumps to an entry with a certain CUSTOM_ID

From: Christoph LANGE
Subject: [O] Function that jumps to an entry with a certain CUSTOM_ID
Date: Tue, 31 Mar 2015 18:36:45 +0200
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0

Hi all,

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.

--- %< --- %< --- %< --- %< --- %< --- %< --- %< --- %< --- %< --- %< ---
(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."
  (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.

I noticed that org-babel-ref-goto-headline-id does something similar, so maybe some code could be shared among the two functions.



Dr. Christoph Lange, Enterprise Information Systems Department
Applied Computer Science @ University of Bonn; Fraunhofer IAIS
http://langec.wordpress.com/about, Skype duke4701

→ Semantic Publishing Challenge: Assessing the Quality of Scientific Output
ESWC, 31 May–4 June 2014, Portorož, Slovenia. https://tinyurl.com/SPChallenge15
  Submission deadline 27 March (abstracts: 20 March)

reply via email to

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