From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rick Frankel Subject: Re: Is it possible to create links to M-x occur results? Date: Thu, 02 May 2013 10:07:28 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:59920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXuAZ-0001el-O2 for emacs-orgmode@gnu.org; Thu, 02 May 2013 10:07:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UXuAT-00077G-4I for emacs-orgmode@gnu.org; Thu, 02 May 2013 10:07:35 -0400 Received: from [204.62.15.78] (port=49612 helo=mail.rickster.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXuAS-000776-Vg for emacs-orgmode@gnu.org; Thu, 02 May 2013 10:07:29 -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: Emacs orgmode 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=20 > to > be able to follow the link to a file and immediately pop into a set=20 > of > M-x occur results given some search term for that file.=C2=A0 That way = I > could link to an overview of a file's class/function definitions, or > config stanzas, or other useful things.=C2=A0 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