emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rick Frankel <rick@rickster.com>
To: Leo Alekseyev <dnquark@gmail.com>
Cc: Emacs orgmode <emacs-orgmode@gnu.org>
Subject: Re: Is it possible to create links to M-x occur results?
Date: Thu, 02 May 2013 10:07:28 -0400	[thread overview]
Message-ID: <a93998d8051d9b6321785bd83529408e@mail.rickster.com> (raw)
In-Reply-To: <CADzxs1=qZcfhSudqZO9svaNbEdp9XDbQtg90vRmXHTcCkUOoxw@mail.gmail.com>

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	other threads:[~2013-05-02 14:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-01 22:41 Is it possible to create links to M-x occur results? Leo Alekseyev
2013-05-02 14:07 ` Rick Frankel [this message]
2013-05-02 17:25   ` Leo Alekseyev
2013-05-03  7:14     ` Carsten Dominik
2013-05-03  8:21       ` Memnon Anon
2013-05-03 12:10         ` Nicolas Richard
2013-05-03 12:39       ` Rick Frankel
2013-05-05 13:44         ` Viktor Rosenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a93998d8051d9b6321785bd83529408e@mail.rickster.com \
    --to=rick@rickster.com \
    --cc=dnquark@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).