Function: org-agenda-open-link

org-agenda-open-link is an interactive and byte-compiled function defined in org-agenda.el.gz.

Signature

(org-agenda-open-link &optional ARG)

Documentation

Open the link(s) in the current entry, if any.

This looks for a link in the displayed line in the agenda. It also looks at the text of the entry itself.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-agenda.el.gz
(defun org-agenda-open-link (&optional arg)
  "Open the link(s) in the current entry, if any.
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)
		     (org-get-at-bol 'org-marker)))
	 (buffer (and marker (marker-buffer marker)))
         (prefix (buffer-substring (line-beginning-position)
                                   (line-end-position)))
	 (lkall (and buffer (org-offer-links-in-entry
			     buffer marker arg prefix)))
	 (lk0 (car lkall))
	 (lk (if (stringp lk0) (list lk0) lk0))
	 (lkend (cdr lkall))
	 trg)
    (cond
     ((and buffer lk)
      (mapcar (lambda(l)
		(with-current-buffer buffer
		  (setq trg (and (string-match org-link-bracket-re l)
				 (match-string 1 l)))
		  (if (or (not trg) (string-match org-link-any-re trg))
		      ;; Don't use `org-with-wide-buffer' here as
		      ;; opening the link may result in moving the point
		      (save-restriction
			(widen)
			(goto-char marker)
			(when (search-forward l nil lkend)
			  (goto-char (match-beginning 0))
			  (org-open-at-point)))
		    ;; This is an internal link, widen the buffer
		    ;; FIXME: use `org-switch-to-buffer-other-window'?
		    (switch-to-buffer-other-window buffer)
		    (widen)
		    (goto-char marker)
		    (when (search-forward l nil lkend)
		      (goto-char (match-beginning 0))
		      (org-open-at-point)))))
	      lk))
     ((or (org-in-regexp (concat "\\(" org-link-bracket-re "\\)"))
	  (save-excursion
	    (beginning-of-line 1)
	    (looking-at (concat ".*?\\(" org-link-bracket-re "\\)"))))
      (org-link-open-from-string (match-string 1)))
     (t (message "No link to open here")))))