diff options
| -rw-r--r-- | lisp/org-id.el | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/lisp/org-id.el b/lisp/org-id.el index ff8024a..9f4d68c 100644 --- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -576,25 +576,27 @@ If SILENT is non-nil, messages are suppressed." (unless silent (cl-incf i) (message "Finding ID locations (%d/%d files): %s" i nfiles file)) - (insert-file-contents file nil nil nil 'replace) - (let ((ids nil) - node - (case-fold-search t)) - (org-with-point-at 1 - (while (re-search-forward id-regexp nil t) - (setq node (org-element-at-point)) - (when (org-element-type-p node 'node-property) - (push (org-element-property :value node) ids))) - (when ids - (push (cons (abbreviate-file-name file) ids) - org-id-locations) - (dolist (id ids) - (cond - ((not (gethash id seen-ids)) (puthash id t seen-ids)) - (silent nil) - (t - (message "Duplicate ID %S" id) - (cl-incf ndup))))))))))) + (let ((buf (or (get-file-buffer file) nil))) + (with-current-buffer (or buf (current-buffer)) + (unless buf (insert-file-contents file nil nil nil 'replace)) + (let ((ids nil) + node + (case-fold-search t)) + (org-with-point-at 1 + (while (re-search-forward id-regexp nil t) + (setq node (org-element-at-point)) + (when (org-element-type-p node 'node-property) + (push (org-element-property :value node) ids))) + (when ids + (push (cons (abbreviate-file-name file) ids) + org-id-locations) + (dolist (id ids) + (cond + ((not (gethash id seen-ids)) (puthash id t seen-ids)) + (silent nil) + (t + (message "Duplicate ID %S" id) + (cl-incf ndup))))))))))))) (setq org-id-files (mapcar #'car org-id-locations)) (org-id-locations-save) ;; Now convert to a hash table. |
