forked from mirrors/org-mode
fixup! org-id-find-id-in-file: Prefer using temporary buffer
* lisp/org-id.el (org-id-find-id-in-file): Fix Emacs 27 compatibility. Avoid modifications not captured by element cache.
This commit is contained in:
parent
d1e4b93519
commit
1ae611c7e3
|
@ -677,13 +677,17 @@ optional argument MARKERP, return the position as a new marker."
|
||||||
(let* ((visiting (find-buffer-visiting file))
|
(let* ((visiting (find-buffer-visiting file))
|
||||||
(buffer (or visiting
|
(buffer (or visiting
|
||||||
(if markerp (find-file-noselect file)
|
(if markerp (find-file-noselect file)
|
||||||
(get-buffer-create " *Org ID temp*" t)))))
|
(if (<= 2 (cdr (func-arity #'get-buffer-create)))
|
||||||
|
(get-buffer-create " *Org ID temp*" t)
|
||||||
|
;; Emacs 27 does not yet have second argument.
|
||||||
|
(get-buffer-create " *Org ID temp*"))))))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(unless (derived-mode-p 'org-mode) (org-mode))
|
(unless (derived-mode-p 'org-mode) (org-mode))
|
||||||
(unless (or visiting markerp)
|
(unless (or visiting markerp)
|
||||||
(buffer-disable-undo)
|
(buffer-disable-undo)
|
||||||
(insert-file-contents file nil nil nil 'replace))
|
(erase-buffer)
|
||||||
|
(insert-file-contents file))
|
||||||
(let ((pos (org-find-entry-with-id id)))
|
(let ((pos (org-find-entry-with-id id)))
|
||||||
(cond
|
(cond
|
||||||
((null pos) nil)
|
((null pos) nil)
|
||||||
|
|
Loading…
Reference in New Issue