Re: [O] Making the output of %% functions linkable in agenda views

2011-05-03 Thread charles . sebold
On 7 Apr 2011, Charles Sebold wrote:

 Here's a test.  Take the line below and put it in an agenda file, then
 view the agenda.

 %%(format %s (concat [[elisp:(info)] [Link to info]]))

 The results as I see them give me a link that I can mouse-click on,
 but I can't move point to it and hit C-c C-o.

 What do I need to do to make this a normal org link in every way?  Or
 is this a bug?

 (Obviously this is just a demo problem, I'm doing something much more
 hideously complicated in real life, but this was good enough to share
 to show what the problem was.)

*bump*

Anybody care to take this on?
-- 
Charles Sebold  3rd of May, 2011
GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600) | No Gnus v0.18 | org-mode 7.5
 




Re: [O] Making the output of %% functions linkable in agenda views

2011-05-03 Thread Nick Dokos
charles.seb...@lcms.org wrote:

 On 7 Apr 2011, Charles Sebold wrote:
 
  Here's a test.  Take the line below and put it in an agenda file, then
  view the agenda.
 
  %%(format %s (concat [[elisp:(info)] [Link to info]]))
 
  The results as I see them give me a link that I can mouse-click on,
  but I can't move point to it and hit C-c C-o.
 
  What do I need to do to make this a normal org link in every way?  Or
  is this a bug?
 
  (Obviously this is just a demo problem, I'm doing something much more
  hideously complicated in real life, but this was good enough to share
  to show what the problem was.)
 

Well, this feels like a bug: when I C-c C-o on it, it says No links,
but if I press RET to go to the agenda file and then C-x k to kill the
buffer, and then do C-c C-o again I get the Execute (info) as elisp?
prompt (and if I say yes, it does indeed open Info). So there is
something funky going on, but I'm not sure what.

Nick




Re: [O] Making the output of %% functions linkable in agenda views

2011-05-03 Thread Matt Lundin
charles.seb...@lcms.org writes:

 On 7 Apr 2011, Charles Sebold wrote:

 Here's a test.  Take the line below and put it in an agenda file, then
 view the agenda.

 %%(format %s (concat [[elisp:(info)] [Link to info]]))

 The results as I see them give me a link that I can mouse-click on,
 but I can't move point to it and hit C-c C-o.

 What do I need to do to make this a normal org link in every way?  Or
 is this a bug?


Here's what seems to be going on. 

Clicking with the mouse works because it calls org-open-at-mouse, which
(by calling org-open-at-point) simply looks at the text surrounding the
click point to find a link.

The function org-agenda-open-link, on the other hand, grabs part of the
headline as a string (the prefix), then jumps to the location in the
original buffer and calls org-offer-links-in-entry to look for links in
both the entry and the prefix of agenda text. Obviously, it won't find
your link in the original entry since it looks like this:

%%(format %s (concat [[elisp:(info)] [Link to info]]))

I think it shouldn't be a problem to pass the whole agenda line to
org-offer-links-in-entry. This will not result in duplicate links, since
org-offer-links-in-entry uniquifies the links.

I've attached a patch.

The bigger question, however, is why the expression above is even
showing up in the agenda, since it contains no scheduling information.
:)

Best,
Matt

From 58c7621c0c84b9c1930098a098e4559aa516eec0 Mon Sep 17 00:00:00 2001
From: Matt Lundin m...@imapmail.org
Date: Tue, 3 May 2011 15:54:35 -0400
Subject: [PATCH] Pass entire text of agenda line to org-offer-links-in-entry.

* lisp/org-agenda.el (org-agenda-open-link): Pass entire text of
  agenda line to org-offer-links-in-entry.

This fixes bug noticed by Charles Sebold, in which links that are
dynamically formatted for the agenda view are ignored.
http://permalink.gmane.org/gmane.emacs.orgmode/40673
---
 lisp/org-agenda.el |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 65f7cea..609edd4 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6879,9 +6879,7 @@ at the text of the entry itself.
 		 (org-get-at-bol 'org-marker)))
 	 (buffer (and marker (marker-buffer marker)))
 	 (prefix (buffer-substring
-		  (point-at-bol)
-		  (or (text-property-any (point-at-bol) (point-at-eol) 'org-heading t)
-		  (point-at-bol)
+		  (point-at-bol) (point-at-eol
 (cond
  (buffer
   (with-current-buffer buffer
-- 
1.7.5



Re: [O] Making the output of %% functions linkable in agenda views

2011-05-03 Thread Sebold, Charles
On 3 May 2011, Matt Lundin wrote:

 The bigger question, however, is why the expression above is even
 showing up in the agenda, since it contains no scheduling information.
 :)

Hm.  I didn't think about whether anybody else could see it, come to
think of it; my real problem (for which this was just a mock-up) shows
up in a heavily customized agenda I set up, which isn't schedule-based.
-- 
Charles Sebold  3rd of May, 2011
  GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 No Gnus v0.18 | Org-mode version 7.5 (release_7.5.246.ga35b4)




Re: [O] Making the output of %% functions linkable in agenda views

2011-05-03 Thread Matt Lundin
charles.seb...@lcms.org (Sebold, Charles) writes:

 On 3 May 2011, Matt Lundin wrote:

 The bigger question, however, is why the expression above is even
 showing up in the agenda, since it contains no scheduling information.
 :)

 Hm.  I didn't think about whether anybody else could see it, come to
 think of it; my real problem (for which this was just a mock-up) shows
 up in a heavily customized agenda I set up, which isn't schedule-based.

I should clarify. I, too, can see the link in the agenda. I had been
under the impression that only diary sexps will appear in the agenda,
but it seems that a generic sexp that returns a string will also show
up.

I'm not sure whether this is a feature or a bug.

Best,
Matt



Re: [O] Making the output of %% functions linkable in agenda views

2011-05-03 Thread Sebold, Charles
On 3 May 2011, Matt Lundin wrote:

 I should clarify. I, too, can see the link in the agenda. I had been
 under the impression that only diary sexps will appear in the agenda,
 but it seems that a generic sexp that returns a string will also show
 up.

 I'm not sure whether this is a feature or a bug.

OK, I see now.  I built this based on the behavior of google-weather-el,
which includes a function for inclusion in agendas.

I think it's a feature; in my (real-world) case, my function runs based
on the value of the local variable `date' (apparently set when the
agenda is built) and provides a correspondingly different result for
every day's agenda.  That is legitimately useful.  Google-weather-el
works the same way.  See:

(info (org)Weekly/daily agenda)

...for examples of org-mode itself using this (e.g., for
org-calendar-holiday, org-bbdb-anniversary, etc.).
-- 
Charles Sebold  3rd of May, 2011
  GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 No Gnus v0.18 | Org-mode version 7.5 (release_7.5.246.ga35b4)




Re: [O] Making the output of %% functions linkable in agenda views

2011-05-03 Thread Nick Dokos
Matt Lundin m...@imapmail.org wrote:


 I should clarify. I, too, can see the link in the agenda. I had been
 under the impression that only diary sexps will appear in the agenda,
 but it seems that a generic sexp that returns a string will also show
 up.
 
 I'm not sure whether this is a feature or a bug.
 

I *think* it's a feature but I'm really not sure: the regexp is just
^?%%( so it does not seem to care what comes after it. Various things
(like the sunrise/sunset hacks) use it, so if it is deemed to be a
bug-to-be-fixed, they will break when it *is* fixed :-)

So is a diary sexp just something that matches ^?%%( *diary ?

Nick



Re: [O] Making the output of %% functions linkable in agenda views

2011-05-03 Thread Matt Lundin
Nick Dokos nicholas.do...@hp.com writes:

 Matt Lundin m...@imapmail.org wrote:


 I should clarify. I, too, can see the link in the agenda. I had been
 under the impression that only diary sexps will appear in the agenda,
 but it seems that a generic sexp that returns a string will also show
 up.
 
 I'm not sure whether this is a feature or a bug.
 

 I *think* it's a feature but I'm really not sure: the regexp is just
 ^?%%( so it does not seem to care what comes after it. Various things
 (like the sunrise/sunset hacks) use it, so if it is deemed to be a
 bug-to-be-fixed, they will break when it *is* fixed :-)

Thanks! Yes this indeed a feature. I just wanted to make sure I wasn't
sending a patch that enhanced a bug. :)

Best,
Matt