From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Is it possible to create links to M-x occur results? Date: Fri, 3 May 2013 09:14:43 +0200 Message-ID: <1770C68C-47FD-4E0A-89C1-79DFE3F9CE82@gmail.com> References: Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_2CEF970C-D95C-4A13-A2EE-398FD7EE62CA" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:35759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYAJV-0005Bo-Bo for emacs-orgmode@gnu.org; Fri, 03 May 2013 03:21:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UYAJQ-0008CR-Bm for emacs-orgmode@gnu.org; Fri, 03 May 2013 03:21:53 -0400 Received: from ezel.ic.uva.nl ([146.50.108.158]:44449) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYAJQ-0008Aw-2f for emacs-orgmode@gnu.org; Fri, 03 May 2013 03:21:48 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Leo Alekseyev Cc: Rick Frankel , Emacs orgmode --Apple-Mail=_2CEF970C-D95C-4A13-A2EE-398FD7EE62CA Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 On 2.5.2013, at 19:25, Leo Alekseyev wrote: > Nice! Short and sweet, and works great. It should go on orgmode.org = somewhere in the cool hacks section. Make a patch if you don't have write access to worg... - Carsten >=20 >=20 > On Thu, May 2, 2013 at 7:07 AM, Rick Frankel = wrote: > On 01.05.2013 18:41, Leo Alekseyev wrote: > Howdy Org-folks, >=20 > 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! >=20 > That seems like a fun exercise. so: >=20 > #+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 >=20 > and you can use a link like: >=20 > occur:m/file.txt#regex >=20 > rick >=20 --Apple-Mail=_2CEF970C-D95C-4A13-A2EE-398FD7EE62CA Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=iso-8859-1
On 2.5.2013, at 19:25, Leo Alekseyev <dnquark@gmail.com> wrote:

Nice!  Short and sweet, and works great.  It should go on orgmode.org somewhere in the cool hacks section.

Make a patch if you don't have write access to worg...

- Carsten



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


--Apple-Mail=_2CEF970C-D95C-4A13-A2EE-398FD7EE62CA--