emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Is it possible to create links to M-x occur results ?


From: Rick Frankel
Subject: Re: [O] Is it possible to create links to M-x occur results ?
Date: Thu, 02 May 2013 10:07:28 -0400
User-agent: Roundcube Webmail/0.7.1

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



reply via email to

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