summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-08-04 14:32:55 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-08-04 14:32:55 +0200
commit776449fd7d07d56fd947d72706da9f682cdc994b (patch)
tree4527e50a2016c8b0c32e8f77162de8b264e2bb80
parentb4d85b47a9fe0b39b59f7b9295203e1d30c76c9a (diff)
downloadorg-mode-776449fd7d07d56fd947d72706da9f682cdc994b.tar.gz
Prevent duplicating calls to `org-link-search'
* lisp/org.el (org-open-at-point): Do not call twice `org-link-search' when destination is not accessible within the current narrowed part of the buffer.
-rwxr-xr-xlisp/org.el30
1 files changed, 16 insertions, 14 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 66ae69e..2a8e8db 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10827,22 +10827,24 @@ link in a property drawer line."
(if (not arg) (org-mark-ring-push)
(switch-to-buffer-other-window
(org-get-buffer-for-internal-link (current-buffer))))
- (let ((cmd
- (if (equal type "radio")
- `(org-search-radio-target
- ,(org-element-property :path link))
- `(org-link-search
- ,(if (member type '("custom-id" "coderef"))
- (org-element-property :raw-link link)
- path)
+ (let ((destination
+ (org-with-wide-buffer
+ (if (equal type "radio")
+ (org-search-radio-target
+ (org-element-property :path link))
+ (org-link-search
+ (if (member type '("custom-id" "coderef"))
+ (org-element-property :raw-link link)
+ path)
;; Prevent fuzzy links from matching
;; themselves.
- ,(and (equal type "fuzzy")
- (+ 2
- (org-element-property :begin link)))))))
- (condition-case nil
- (let ((org-link-search-inhibit-query t)) (eval cmd))
- (error (progn (widen) (eval cmd)))))))
+ (and (equal type "fuzzy")
+ (+ 2 (org-element-property :begin link)))))
+ (point))))
+ (unless (and (<= (point-min) destination)
+ (>= (point-max) destination))
+ (widen))
+ (goto-char destination))))
(t (browse-url-at-point))))))
;; On a footnote reference or at a footnote definition's label.
((or (eq type 'footnote-reference)