mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-18 20:40:48 +00:00
Merge branch 'maint'
This commit is contained in:
commit
1e32d7bf25
26
lisp/ox.el
26
lisp/ox.el
|
@ -3976,27 +3976,43 @@ significant."
|
||||||
;; Split PATH at white spaces so matches are space
|
;; Split PATH at white spaces so matches are space
|
||||||
;; insensitive.
|
;; insensitive.
|
||||||
(path (org-split-string
|
(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
|
(cond
|
||||||
;; First try to find a matching "<<path>>" unless user specified
|
;; First try to find a matching "<<path>>" unless user specified
|
||||||
;; he was looking for a headline (path starts with a "*"
|
;; he was looking for a headline (path starts with a "*"
|
||||||
;; character).
|
;; character).
|
||||||
((and (not match-title-p)
|
((and (not match-title-p)
|
||||||
|
(or (not (eq found-in-cache 'fuzzy-link-not-found))
|
||||||
|
(puthash path
|
||||||
(org-element-map (plist-get info :parse-tree) 'target
|
(org-element-map (plist-get info :parse-tree) 'target
|
||||||
(lambda (blob)
|
(lambda (blob)
|
||||||
(and (equal (org-split-string (org-element-property :value blob))
|
(and (equal (org-split-string
|
||||||
|
(org-element-property :value blob))
|
||||||
path)
|
path)
|
||||||
blob))
|
blob))
|
||||||
info t)))
|
info t)
|
||||||
|
link-cache))))
|
||||||
;; Then try to find an element with a matching "#+NAME: path"
|
;; Then try to find an element with a matching "#+NAME: path"
|
||||||
;; affiliated keyword.
|
;; affiliated keyword.
|
||||||
((and (not match-title-p)
|
((and (not match-title-p)
|
||||||
|
(or (not (eq found-in-cache 'fuzzy-link-not-found))
|
||||||
|
(puthash path
|
||||||
(org-element-map (plist-get info :parse-tree)
|
(org-element-map (plist-get info :parse-tree)
|
||||||
org-element-all-elements
|
org-element-all-elements
|
||||||
(lambda (el)
|
(lambda (el)
|
||||||
(let ((name (org-element-property :name el)))
|
(let ((name (org-element-property :name el)))
|
||||||
(when (and name (equal (org-split-string name) path)) el)))
|
(when (and name
|
||||||
info 'first-match)))
|
(equal (org-split-string name) path))
|
||||||
|
el)))
|
||||||
|
info 'first-match)
|
||||||
|
link-cache))))
|
||||||
;; Last case: link either points to a headline or to nothingness.
|
;; Last case: link either points to a headline or to nothingness.
|
||||||
;; Try to find the source, with priority given to headlines with
|
;; Try to find the source, with priority given to headlines with
|
||||||
;; the closest common ancestor. If such candidate is found,
|
;; the closest common ancestor. If such candidate is found,
|
||||||
|
|
Loading…
Reference in a new issue