Nice! Short and sweet, and works great. It should go on orgmode.orgsomewhere in the cool hacks section. On Thu, May 2, 2013 at 7:07 AM, Rick Frankel wrote: > On 01.05.2013 18:41, Leo Alekseyev wrote: > >> Howdy Org-folks, >> >> Something that I've found myself wishing for time and time again is to >> be able to follow the link to a file and immediately pop into a set of >> M-x occur results given some search term for that file. That way I >> could link to an overview of a file's class/function definitions, or >> config stanzas, or other useful things. Given that we can create >> links to arbitrary elisp, I am sure that this can be done in >> principle, but if there's a quick recipe that someone has come up >> with, I'd love to hear about it! >> > > That seems like a fun exercise. so: > > #+BEGIN_SRC elisp > (defun org-occur-open (uri) > "Visit the file specified by URI, and run `occur' on the fragment > \(anything after '#') in the uri." > (let ((list (split-string uri "#"))) > (org-open-file (car list) t) > (occur (mapconcat 'identity (cdr list) "#")))) > (org-add-link-type "occur" 'org-occur-open) > #+END_SRC > > and you can use a link like: > > occur:m/file.txt#regex > > rick >