emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Nicolas Richard" <theonewiththeevillook@yahoo.fr>
To: emacs-orgmode@gnu.org
Subject: Re: Is it possible to create links to M-x occur results?
Date: Fri, 03 May 2013 14:10:46 +0200	[thread overview]
Message-ID: <87bo8sclh5.fsf@yahoo.fr> (raw)
In-Reply-To: 8761z0jx6d.fsf@mean.albasani.net

Memnon Anon <gegendosenfleisch@googlemail.com> writes:
> Carsten Dominik <carsten.dominik@gmail.com> writes:
>> 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...
> 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 <theonewiththeevillook@yahoo.fr>
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	other threads:[~2013-05-03 12:10 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
2013-05-03  7:14     ` Carsten Dominik
2013-05-03  8:21       ` Memnon Anon
2013-05-03 12:10         ` Nicolas Richard [this message]
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=87bo8sclh5.fsf@yahoo.fr \
    --to=theonewiththeevillook@yahoo.fr \
    --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).