summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2009-09-12 07:05:21 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2009-09-12 07:05:21 +0200
commit0054bf1105c43d7f7c68154625a49fb1f46ef4f2 (patch)
treee81a1caedec4f3b36d8502fb27a768e4a07fee2f
parent317ea8bf9d845b31378e0162456a8b01496b9d23 (diff)
downloadorg-mode-0054bf1105c43d7f7c68154625a49fb1f46ef4f2.tar.gz
Store link to referenced entries in agenda
Peter Westlake writes: > Could I request this as a small feature enhancement, please? > Commands like org-refile have an agenda equivalent so that > the same keys work in the agenda, and it would be very nice > to be able to store a link to an item that way as well.
-rw-r--r--doc/org.texi5
-rwxr-xr-xlisp/ChangeLog8
-rw-r--r--lisp/org-macs.el1
-rw-r--r--lisp/org.el10
4 files changed, 24 insertions, 0 deletions
diff --git a/doc/org.texi b/doc/org.texi
index b1ff3d8..b042ed9 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -2973,6 +2973,11 @@ search string. If the automatically created link is not working correctly or
accurately enough, you can write custom functions to select the search string
and to do the search for particular file types---see @ref{Custom searches}.
The key binding @kbd{C-c l} is only a suggestion---see @ref{Installation}.
+
+@b{Agenda view}@*
+When the cursor is in an agenda view, the created link points to the
+entry referenced by the current line.
+
@c
@kindex C-c C-l
@cindex link completion
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 30c24bd..fabee58 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2009-09-12 Carsten Dominik <carsten.dominik@gmail.com>
+
+ * org.el (org-store-link): When in agenda buffer, link to
+ referenced entry.
+
+ * org-macs.el (org-with-point-at): Add a `lisp-indent-function'
+ property.
+
2009-09-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-first-lines): Fix problem with
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 4aa5816..192e1cd 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -102,6 +102,7 @@ We use a macro so that the test can happen at compilation time."
(save-excursion
(goto-char (or ,pom (point)))
,@body)))
+(put 'org-with-point-at 'lisp-indent-function 1)
(defmacro org-no-warnings (&rest body)
(cons (if (fboundp 'with-no-warnings) 'with-no-warnings 'progn) body))
diff --git a/lisp/org.el b/lisp/org.el
index 291720f..68f5aca 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7141,6 +7141,8 @@ type. For a simple example of an export function, see `org-bbdb.el'."
(setcdr (assoc type org-link-protocols) (list follow export))
(push (list type follow export) org-link-protocols)))
+(defvar org-agenda-buffer-name)
+
;;;###autoload
(defun org-store-link (arg)
"\\<org-mode-map>Store an org-link to the current location.
@@ -7180,6 +7182,14 @@ For file links, arg negates `org-context-in-file-links'."
(insert link)
(setq link (concat "(" label ")") desc nil)))
+ ((equal (org-bound-and-true-p org-agenda-buffer-name) (buffer-name))
+ ;; We are in the agenda, link to referenced location
+ (let ((m (or (get-text-property (point) 'org-hd-marker)
+ (get-text-property (point) 'org-marker))))
+ (unless m (error "Don't know what location to link to"))
+ (org-with-point-at m
+ (call-interactively 'org-store-link))))
+
((eq major-mode 'calendar-mode)
(let ((cd (calendar-cursor-to-date)))
(setq link