emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Is it possible to create links to M-x occur results?
@ 2013-05-01 22:41 Leo Alekseyev
  2013-05-02 14:07 ` Rick Frankel
  0 siblings, 1 reply; 8+ messages in thread
From: Leo Alekseyev @ 2013-05-01 22:41 UTC (permalink / raw)
  To: Emacs orgmode

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

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!

--Leo

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is it possible to create links to M-x occur results?
  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
  0 siblings, 1 reply; 8+ messages in thread
From: Rick Frankel @ 2013-05-02 14:07 UTC (permalink / raw)
  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 
> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is it possible to create links to M-x occur results?
  2013-05-02 14:07 ` Rick Frankel
@ 2013-05-02 17:25   ` Leo Alekseyev
  2013-05-03  7:14     ` Carsten Dominik
  0 siblings, 1 reply; 8+ messages in thread
From: Leo Alekseyev @ 2013-05-02 17:25 UTC (permalink / raw)
  To: Rick Frankel; +Cc: Emacs orgmode

[-- 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 --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is it possible to create links to M-x occur results?
  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:39       ` Rick Frankel
  0 siblings, 2 replies; 8+ messages in thread
From: Carsten Dominik @ 2013-05-03  7:14 UTC (permalink / raw)
  To: Leo Alekseyev; +Cc: Rick Frankel, Emacs orgmode

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


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
> 


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is it possible to create links to M-x occur results?
  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
  1 sibling, 1 reply; 8+ messages in thread
From: Memnon Anon @ 2013-05-03  8:21 UTC (permalink / raw)
  To: emacs-orgmode

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...

It is probably easier to fix it directly...

   http://orgmode.org/worg/worg-git.html 

should get you started with that.

Go ahead, it is really not that difficult ;).

And if things get messed up, it is VC after all, so very easy to fix any
'mistake' that may have happened.

Memnon

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is it possible to create links to M-x occur results?
  2013-05-03  8:21       ` Memnon Anon
@ 2013-05-03 12:10         ` Nicolas Richard
  0 siblings, 0 replies; 8+ messages in thread
From: Nicolas Richard @ 2013-05-03 12:10 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: Is it possible to create links to M-x occur results?
  2013-05-03  7:14     ` Carsten Dominik
  2013-05-03  8:21       ` Memnon Anon
@ 2013-05-03 12:39       ` Rick Frankel
  2013-05-05 13:44         ` Viktor Rosenfeld
  1 sibling, 1 reply; 8+ messages in thread
From: Rick Frankel @ 2013-05-03 12:39 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Emacs orgmode

On Fri, May 03, 2013 at 09:14:43AM +0200, Carsten Dominik wrote:
>    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...

I have added it to org-hacks.org between "Store link to a message when
sending in Gnus" and "Send html messages and attachments with
Wanderlust", but when i push to master, i get the following in the log
output from the git-hook and it' doesn't show up in the website:

       remote: Publishing file /home/emacs/git/worg/sitemap.org using `org-publish-org-to-html'
       remote: Symbol's function definition is void: org-publish-org-to-html

rick

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is it possible to create links to M-x occur results?
  2013-05-03 12:39       ` Rick Frankel
@ 2013-05-05 13:44         ` Viktor Rosenfeld
  0 siblings, 0 replies; 8+ messages in thread
From: Viktor Rosenfeld @ 2013-05-05 13:44 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Carsten Dominik

Hi,

Rick Frankel wrote:

> On Fri, May 03, 2013 at 09:14:43AM +0200, Carsten Dominik wrote:
> >    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...
> 
> I have added it to org-hacks.org between "Store link to a message when
> sending in Gnus" and "Send html messages and attachments with
> Wanderlust", but when i push to master, i get the following in the log
> output from the git-hook and it' doesn't show up in the website:
> 
>        remote: Publishing file /home/emacs/git/worg/sitemap.org using `org-publish-org-to-html'
>        remote: Symbol's function definition is void: org-publish-org-to-html
> 

I just pushed a change to Worg and got the same error message.

Cheers,
Viktor

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-05-05 13:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2013-05-03 12:39       ` Rick Frankel
2013-05-05 13:44         ` Viktor Rosenfeld

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).