summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2014-11-20 23:35:28 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2014-11-20 23:35:28 +0100
commit40f2b885f67585f500ae0bfec2c4c8c511de30b2 (patch)
treed39163d2d2710f5d9f094ce594d2602c046bdee5
parent0e52f02f2cec6baf3efa3156331fbdd630241989 (diff)
downloadorg-mode-40f2b885f67585f500ae0bfec2c4c8c511de30b2.tar.gz
Open outer link on nested links
* lisp/org.el (org-open-at-point): Open outer link on nested links. * testing/lisp/test-org.el (test-org/open-at-point/inline-image): New test. Suggested-by: Daniel Bausch <bausch@dvs.tu-darmstadt.de> <http://permalink.gmane.org/gmane.emacs.orgmode/92796>
-rwxr-xr-xlisp/org.el17
-rw-r--r--testing/lisp/test-org.el8
2 files changed, 19 insertions, 6 deletions
diff --git a/lisp/org.el b/lisp/org.el
index dbd2cb7..6ab13f4 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10791,8 +10791,13 @@ link in a property drawer line."
(>= (point) (match-beginning 5)))))
(org-tags-view arg (substring (match-string 5) 0 -1)))
((eq type 'link)
- (let ((type (org-element-property :type context))
- (path (org-link-unescape (org-element-property :path context))))
+ ;; When link is located within the description of another
+ ;; link (e.g., an inline image), always open the parent
+ ;; link.
+ (let*((link (let ((up (org-element-property :parent context)))
+ (if (eq (org-element-type up) 'link) up context)))
+ (type (org-element-property :type link))
+ (path (org-link-unescape (org-element-property :path link))))
;; Switch back to REFERENCE-BUFFER needed when called in
;; a temporary buffer through `org-open-link-from-string'.
(with-current-buffer (or reference-buffer (current-buffer))
@@ -10811,8 +10816,8 @@ link in a property drawer line."
;; Note : "file+emacs" and "file+sys" types are
;; hard-coded in order to escape the previous
;; limitation.
- (let* ((option (org-element-property :search-option context))
- (app (org-element-property :application context))
+ (let* ((option (org-element-property :search-option link))
+ (app (org-element-property :application link))
(dedicated-function
(nth 1 (assoc app org-link-protocols))))
(if dedicated-function
@@ -10889,11 +10894,11 @@ link in a property drawer line."
(org-get-buffer-for-internal-link (current-buffer))))
(let ((cmd `(org-link-search
,(if (member type '("custom-id" "coderef"))
- (org-element-property :raw-link context)
+ (org-element-property :raw-link link)
path)
,(cond ((equal arg '(4)) 'occur)
((equal arg '(16)) 'org-occur))
- ,(org-element-property :begin context))))
+ ,(org-element-property :begin link))))
(condition-case nil
(let ((org-link-search-inhibit-query t))
(eval cmd))
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 6a71938..cee6752 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1376,6 +1376,14 @@ drops support for Emacs 24.1 and 24.2."
(looking-at "\nThe Emacs Editor")
(kill-buffer))))))
+(ert-deftest test-org/open-at-point/inline-image ()
+ "Test `org-open-at-point' on nested links."
+ (should
+ (org-test-with-temp-text "[[info:org#Top][info:<point>emacs#Top]]"
+ (org-open-at-point)
+ (prog1 (with-current-buffer "*info*" (looking-at "\nOrg Mode Manual"))
+ (kill-buffer "*info*")))))
+
;;; Node Properties