Making the output of %% functions linkable in agenda views
commitad28fc9a61735900ff6b6bdca3d73c0364aa1a8e
authorMatt Lundin <mdl@imapmail.org>
Wed, 4 May 2011 00:56:54 +0000 (4 00:56 +0000)
committerCarsten Dominik <carsten.dominik@gmail.com>
Wed, 4 May 2011 07:43:01 +0000 (4 09:43 +0200)
treebe6c3e36f6b4ea6d95bd2ebf18ed45c8f6bdc1b1
parenta35b4a7db9eba0204313353e17a655bc6d47a574
Making the output of %% functions linkable in agenda views

charles.sebold@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 <mdl@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