emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Leo Alekseyev <dnquark@gmail.com>
To: Rick Frankel <rick@rickster.com>
Cc: Emacs orgmode <emacs-orgmode@gnu.org>
Subject: Re: Is it possible to create links to M-x occur results?
Date: Thu, 2 May 2013 10:25:29 -0700	[thread overview]
Message-ID: <CADzxs1m2NJ0J4Qe+bNs2r8hdiKef+5e5TP07ayOxAXQ2VesKRA@mail.gmail.com> (raw)
In-Reply-To: <a93998d8051d9b6321785bd83529408e@mail.rickster.com>

[-- Attachment #1: Type: text/plain, Size: 1271 bytes --]

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 <rick@rickster.com> 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
>

[-- Attachment #2: Type: text/html, Size: 1984 bytes --]

  reply	other threads:[~2013-05-02 17:25 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
2013-05-02 17:25   ` Leo Alekseyev [this message]
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=CADzxs1m2NJ0J4Qe+bNs2r8hdiKef+5e5TP07ayOxAXQ2VesKRA@mail.gmail.com \
    --to=dnquark@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=rick@rickster.com \
    /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).