emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* linking to region
@ 2009-09-24 17:38 Maurizio Vitale
  2009-09-24 20:14 ` Bernt Hansen
  0 siblings, 1 reply; 5+ messages in thread
From: Maurizio Vitale @ 2009-09-24 17:38 UTC (permalink / raw)
  To: emacs-orgmode


Is it possible to grab a link to a region in a file in such a way that
C-c C-o visit the file after narrowing-to-region?

The reason I'd like this is that I'm starting using org-mode for
requirement tracking and when referencing a standard I'd find
preferable to open only the relevant fragment rather than the complete
document.

Regards,

        Maurizio
-- 

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

* Re: linking to region
  2009-09-24 17:38 linking to region Maurizio Vitale
@ 2009-09-24 20:14 ` Bernt Hansen
  2009-09-24 20:39   ` Maurizio Vitale
  0 siblings, 1 reply; 5+ messages in thread
From: Bernt Hansen @ 2009-09-24 20:14 UTC (permalink / raw)
  To: maurizio.vitale; +Cc: emacs-orgmode

Maurizio Vitale
<mav@cuma.i-did-not-set--mail-host-address--so-tickle-me> writes:

> Is it possible to grab a link to a region in a file in such a way that
> C-c C-o visit the file after narrowing-to-region?
>
> The reason I'd like this is that I'm starting using org-mode for
> requirement tracking and when referencing a standard I'd find
> preferable to open only the relevant fragment rather than the complete
> document.

I don't think that's currently possible without writing a little lisp
code.  There is an org-follow-link-hook but it doesn't seem to be
executed for all link types - only browser urls if I'm reading the code
correctly.

The following patch seems to fix it so it executes for plain file links
too.  You can probably create a function that goes to the point and then
narrows the text around the point using this hook.

I tested this by setting the hook with 

(setq org-follow-link-hook 'hide-other)

HTH,

Bernt


--8<---------------cut here---------------start------------->8---
From 1999493a3c9cdbf989a932726b6aadcf4b72c14e Mon Sep 17 00:00:00 2001
From: Bernt Hansen <bernt@norang.ca>
Date: Thu, 24 Sep 2009 16:04:38 -0400
Subject: [PATCH] Enable org-follow-link-hook for all link types

This hook was only executing for browser links.  Now we always execute the hook
after visiting a link assuming no error occurs.
---
This patch is available at git://git.norang.ca/org-mode for-carsten

 lisp/org.el |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 078c3b7..546df35 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8099,8 +8099,8 @@ application the system uses for this file type."
 
 	 (t
 	  (browse-url-at-point))))))
-   (move-marker org-open-link-marker nil)
-   (run-hook-with-args 'org-follow-link-hook)))
+   (move-marker org-open-link-marker nil))
+  (run-hook-with-args 'org-follow-link-hook))
 
 (defun org-offer-links-in-entry (&optional nth zero)
   "Offer links in the curren entry and follow the selected link.
-- 
1.6.5.rc1.19.g8426
--8<---------------cut here---------------end--------------->8---

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

* Re: linking to region
  2009-09-24 20:14 ` Bernt Hansen
@ 2009-09-24 20:39   ` Maurizio Vitale
  2009-09-24 20:44     ` Bernt Hansen
  0 siblings, 1 reply; 5+ messages in thread
From: Maurizio Vitale @ 2009-09-24 20:39 UTC (permalink / raw)
  To: emacs-orgmode

>>>>> "Bernt" == Bernt Hansen <bernt@norang.ca> writes:

    >> Is it possible to grab a link to a region in a file in such a way
    >> that C-c C-o visit the file after narrowing-to-region?
    >> 
    >> The reason I'd like this is that I'm starting using org-mode for
    >> requirement tracking and when referencing a standard I'd find
    >> preferable to open only the relevant fragment rather than the
    >> complete document.

    Bernt> I don't think that's currently possible without writing a
    Bernt> little lisp code.  There is an org-follow-link-hook but it
    Bernt> doesn't seem to be executed for all link types - only browser
    Bernt> urls if I'm reading the code correctly.

But the region should be encoded in the link, as there no way to figure
out what is the extent of the interesting area automatically.

Regarding org-follow-link-hook, I'm not familiar with org-mode code, but
it seems to me that is invoked for all URL types, but only after the
'viewing' has happened. I may well be wrong.

Thanks for the suggestion.
Regards, 

         Maurizio

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

* Re: linking to region
  2009-09-24 20:39   ` Maurizio Vitale
@ 2009-09-24 20:44     ` Bernt Hansen
  2009-09-24 20:52       ` Carsten Dominik
  0 siblings, 1 reply; 5+ messages in thread
From: Bernt Hansen @ 2009-09-24 20:44 UTC (permalink / raw)
  To: maurizio.vitale; +Cc: emacs-orgmode

Maurizio Vitale
<mav@cuma.i-did-not-set--mail-host-address--so-tickle-me> writes:

>>>>>> "Bernt" == Bernt Hansen <bernt@norang.ca> writes:
>
>     >> Is it possible to grab a link to a region in a file in such a way
>     >> that C-c C-o visit the file after narrowing-to-region?
>     >> 
>     >> The reason I'd like this is that I'm starting using org-mode for
>     >> requirement tracking and when referencing a standard I'd find
>     >> preferable to open only the relevant fragment rather than the
>     >> complete document.
>
>     Bernt> I don't think that's currently possible without writing a
>     Bernt> little lisp code.  There is an org-follow-link-hook but it
>     Bernt> doesn't seem to be executed for all link types - only browser
>     Bernt> urls if I'm reading the code correctly.
>
> But the region should be encoded in the link, as there no way to figure
> out what is the extent of the interesting area automatically.

Current links don't have region information - just a match to the first
occurrence of text in the file.  What would a region link look like and
how would you generate one?

>
> Regarding org-follow-link-hook, I'm not familiar with org-mode code,
>but it seems to me that is invoked for all URL types, but only after
>the 'viewing' has happened. I may well be wrong.

That didn't seem to be the case for my quick test of the hook.

-Bernt

PS. Please use reply-all when responding otherwise I might miss articles
    that are really addressed to me.

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

* Re: Re: linking to region
  2009-09-24 20:44     ` Bernt Hansen
@ 2009-09-24 20:52       ` Carsten Dominik
  0 siblings, 0 replies; 5+ messages in thread
From: Carsten Dominik @ 2009-09-24 20:52 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: maurizio.vitale, emacs-orgmode


On Sep 24, 2009, at 9:44 PM, Bernt Hansen wrote:
>
>>
>> Regarding org-follow-link-hook, I'm not familiar with org-mode code,
>> but it seems to me that is invoked for all URL types, but only after
>> the 'viewing' has happened. I may well be wrong.
>
> That didn't seem to be the case for my quick test of the hook.

That was a bug, fixed now.

- Carsten

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

end of thread, other threads:[~2009-09-24 20:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-24 17:38 linking to region Maurizio Vitale
2009-09-24 20:14 ` Bernt Hansen
2009-09-24 20:39   ` Maurizio Vitale
2009-09-24 20:44     ` Bernt Hansen
2009-09-24 20:52       ` Carsten Dominik

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