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: Nicolas Richard
Subject: Re: [O] Is it possible to create links to M-x occur results?
Date: Fri, 03 May 2013 14:10:46 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Memnon Anon <address@hidden> writes:
> Carsten Dominik <address@hidden> writes:
>> On 2.5.2013, at 19:25, Leo Alekseyev <address@hidden> 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...
> Go ahead, it is really not that difficult ;).

Yeah, let's go ahead indeed.

>From db3313e2e88741a4084988bba656530d09ac7356 Mon Sep 17 00:00:00 2001
From: Nicolas Richard <address@hidden>
Date: Fri, 3 May 2013 14:04:01 +0200
Subject: [PATCH] org-hacks.org: Support for occur: links

---
 org-hacks.org | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/org-hacks.org b/org-hacks.org
index 290dcf1..56cd24b 100644
--- a/org-hacks.org
+++ b/org-hacks.org
@@ -1109,6 +1109,29 @@ accomplish this:
 
 Then just use `M-x my-org-insert-link' instead of `org-insert-link'.
 
+*** Insert a link that activates =M-x occur= in the target buffer
+Posted on the Org-mode mailing list by Rick Frankel
+(http://lists.gnu.org/archive/html/emacs-orgmode/2013-05/msg00072.html), this
+is support for =occur:= links to automagically open an *Occur* session.
+
+#+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
+
+Links are written like this :
+
+#+begin_src org
+  [[occur:m/file.txt#regex][text]]
+#+end_src
+
+
+
 ** Archiving Content in Org-Mode
 *** Preserve top level headings when archiving to a file
 #+index: Archiving!Preserve top level headings
-- 
1.8.1.5




reply via email to

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