summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2013-05-02 12:52:47 (GMT)
committer Nicolas Goaziou <n.goaziou@gmail.com>2013-05-02 12:52:47 (GMT)
commit1e32d7bf252f997661ead0d95c0b9423a7cbb559 (patch)
treed96b7ee47d70272c9f758e201bb48746766ecef3
parent168c5584f5a41c4c0890f4caa89fc11cff021c4e (diff)
parentb7301bd639aa557dd9b57e77df8a8e45ff618740 (diff)
downloadorg-mode-1e32d7bf252f997661ead0d95c0b9423a7cbb559.zip
org-mode-1e32d7bf252f997661ead0d95c0b9423a7cbb559.tar.gz
Merge branch 'maint'
-rw-r--r--lisp/ox.el42
1 files changed, 29 insertions, 13 deletions
diff --git a/lisp/ox.el b/lisp/ox.el
index 88b4122..e408c1b 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -3976,27 +3976,43 @@ significant."
;; Split PATH at white spaces so matches are space
;; insensitive.
(path (org-split-string
- (if match-title-p (substring raw-path 1) raw-path))))
+ (if match-title-p (substring raw-path 1) raw-path)))
+ ;; Cache for locations of fuzzy links that are not position dependent
+ (link-cache
+ (or (plist-get info :fuzzy-link-cache)
+ (plist-get (setq info (plist-put info :fuzzy-link-cache
+ (make-hash-table :test 'equal)))
+ :fuzzy-link-cache)))
+ (found-in-cache (gethash path link-cache 'fuzzy-link-not-found)))
(cond
;; First try to find a matching "<<path>>" unless user specified
;; he was looking for a headline (path starts with a "*"
;; character).
((and (not match-title-p)
- (org-element-map (plist-get info :parse-tree) 'target
- (lambda (blob)
- (and (equal (org-split-string (org-element-property :value blob))
- path)
- blob))
- info t)))
+ (or (not (eq found-in-cache 'fuzzy-link-not-found))
+ (puthash path
+ (org-element-map (plist-get info :parse-tree) 'target
+ (lambda (blob)
+ (and (equal (org-split-string
+ (org-element-property :value blob))
+ path)
+ blob))
+ info t)
+ link-cache))))
;; Then try to find an element with a matching "#+NAME: path"
;; affiliated keyword.
((and (not match-title-p)
- (org-element-map (plist-get info :parse-tree)
- org-element-all-elements
- (lambda (el)
- (let ((name (org-element-property :name el)))
- (when (and name (equal (org-split-string name) path)) el)))
- info 'first-match)))
+ (or (not (eq found-in-cache 'fuzzy-link-not-found))
+ (puthash path
+ (org-element-map (plist-get info :parse-tree)
+ org-element-all-elements
+ (lambda (el)
+ (let ((name (org-element-property :name el)))
+ (when (and name
+ (equal (org-split-string name) path))
+ el)))
+ info 'first-match)
+ link-cache))))
;; Last case: link either points to a headline or to nothingness.
;; Try to find the source, with priority given to headlines with
;; the closest common ancestor. If such candidate is found,