summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2009-11-02 08:07:28 +0100
committerCarsten Dominik <carsten.dominik@gmail.com>2009-11-02 08:23:30 +0100
commitba1e90893d128d8004e4cb6763af692c5a6cd677 (patch)
treef53732cd131564be77a44c93804db75ebd668156
parent55a740afef9a3356ab8a991aff5f2b960fb00e14 (diff)
downloadorg-mode-ba1e90893d128d8004e4cb6763af692c5a6cd677.tar.gz
Agenda: Make `C-c C-o' and RET opening links in clocktables in the agenda
RET will only do this if the cursor is on the link and `org-return-follows-link' is set. `C-c C-o' will work anywhere in the line. Requested by Chris Leyon.
-rwxr-xr-xlisp/ChangeLog8
-rw-r--r--lisp/org-agenda.el55
2 files changed, 41 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2b2290c..b3beeae 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2009-11-02 Carsten Dominik <carsten.dominik@gmail.com>
+
+ * org-agenda.el (org-agenda-open-link): Make this work in agenda
+ clocktables.
+ (org-agenda-switch-to): Follow a link at point if
+ org-return-follows-link' is set and there is nothing else to do in
+ this line.
+
2009-11-01 Dan Davison <davison@stats.ox.ac.uk>
* org-exp-blocks.el: Modify split separator regexp to avoid empty
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 498d901..5e0f4fd 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -5851,7 +5851,7 @@ If this information is not given, the function uses the tree at point."
(defun org-agenda-open-link (&optional arg)
"Follow the link in the current line, if any.
-This looks for a link in the displayed lin in the agenda. It also looks
+This looks for a link in the displayed line in the agenda. It also looks
at the text of the entry itself."
(interactive "P")
(let* ((marker (or (org-get-at-bol 'org-hd-marker)
@@ -5860,14 +5860,21 @@ at the text of the entry itself."
(prefix (buffer-substring
(point-at-bol)
(+ (point-at-bol)
- (org-get-at-bol 'prefix-length)))))
- (unless buffer (error "Don't know where to look for links"))
- (with-current-buffer buffer
- (save-excursion
- (save-restriction
- (widen)
- (goto-char marker)
- (org-offer-links-in-entry arg prefix))))))
+ (or (org-get-at-bol 'prefix-length) 0)))))
+ (cond
+ (buffer
+ (with-current-buffer buffer
+ (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char marker)
+ (org-offer-links-in-entry arg prefix)))))
+ ((or (org-in-regexp (concat "\\(" org-bracket-link-regexp "\\)"))
+ (save-excursion
+ (beginning-of-line 1)
+ (looking-at (concat ".*?\\(" org-bracket-link-regexp "\\)"))))
+ (org-open-link-from-string (match-string 1)))
+ (t (error "No link to open here")))))
(defun org-agenda-copy-local-variable (var)
"Get a variable from a referenced buffer and install it here."
@@ -5879,19 +5886,23 @@ at the text of the entry itself."
(defun org-agenda-switch-to (&optional delete-other-windows)
"Go to the Org-mode file which contains the item at point."
(interactive)
- (let* ((marker (or (org-get-at-bol 'org-marker)
- (org-agenda-error)))
- (buffer (marker-buffer marker))
- (pos (marker-position marker)))
- (switch-to-buffer buffer)
- (and delete-other-windows (delete-other-windows))
- (widen)
- (goto-char pos)
- (when (org-mode-p)
- (org-show-context 'agenda)
- (save-excursion
- (and (outline-next-heading)
- (org-flag-heading nil)))))) ; show the next heading
+ (if (and org-return-follows-link
+ (not (org-get-at-bol 'org-marker))
+ (org-in-regexp org-bracket-link-regexp))
+ (org-open-link-from-string (match-string 0))
+ (let* ((marker (or (org-get-at-bol 'org-marker)
+ (org-agenda-error)))
+ (buffer (marker-buffer marker))
+ (pos (marker-position marker)))
+ (switch-to-buffer buffer)
+ (and delete-other-windows (delete-other-windows))
+ (widen)
+ (goto-char pos)
+ (when (org-mode-p)
+ (org-show-context 'agenda)
+ (save-excursion
+ (and (outline-next-heading)
+ (org-flag-heading nil))))))) ; show the next heading
(defun org-agenda-goto-mouse (ev)
"Go to the Org-mode file which contains the item at the mouse click."