[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 2b49d6fd9c 1/2: org-id-update-id-locations: Disable
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 2b49d6fd9c 1/2: org-id-update-id-locations: Disable cache in throwaway buffers |
Date: |
Sun, 30 Jan 2022 02:57:50 -0500 (EST) |
branch: externals/org
commit 2b49d6fd9c04020a8132bfcfffa449e3e05b47e1
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
org-id-update-id-locations: Disable cache in throwaway buffers
* lisp/org-macs.el (org-element-with-disabled-cache): Move from
org-element.el to org-macs.el
---
lisp/org-element.el | 6 ------
lisp/org-id.el | 51 +++++++++++++++++++++++++++------------------------
lisp/org-macs.el | 6 ++++++
3 files changed, 33 insertions(+), 30 deletions(-)
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 77a9fc6e3e..400138d721 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -265,12 +265,6 @@ specially in `org-element--object-lex'.")
(org-element--set-regexps)
-(defmacro org-element-with-disabled-cache (&rest body)
- "Run BODY without active org-element-cache."
- (declare (debug (form body)) (indent 1))
- `(cl-letf (((symbol-function #'org-element--cache-active-p) (lambda (&rest
_) nil)))
- ,@body))
-
;;;###autoload
(defun org-element-update-syntax ()
"Update parser internals."
diff --git a/lisp/org-id.el b/lisp/org-id.el
index b4acec7bdd..a8f8eb4ebf 100644
--- a/lisp/org-id.el
+++ b/lisp/org-id.el
@@ -76,6 +76,8 @@
(declare-function message-make-fqdn "message" ())
(declare-function org-goto-location "org-goto" (&optional _buf help))
+;; Declared inside `org-element-with-disabled-cache' macro.
+(declare-function org-element--cache-active-p "org-element.el" (&optional
called-from-cache-change-func-p))
;;; Customization
@@ -522,30 +524,31 @@ If SILENT is non-nil, messages are suppressed."
(ndup 0)
(i 0))
(with-temp-buffer
- (delay-mode-hooks
- (org-mode)
- (dolist (file files)
- (when (file-exists-p file)
- (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)
- (case-fold-search t))
- (org-with-point-at 1
- (while (re-search-forward id-regexp nil t)
- (when (org-at-property-p)
- (push (org-entry-get (point) "ID") ids)))
- (when ids
- (push (cons (abbreviate-file-name file) ids)
- org-id-locations)
- (dolist (id ids)
- (cond
- ((not (member id seen-ids)) (push id seen-ids))
- (silent nil)
- (t
- (message "Duplicate ID %S" id)
- (cl-incf ndup)))))))))))
+ (org-element-with-disabled-cache
+ (delay-mode-hooks
+ (org-mode)
+ (dolist (file files)
+ (when (file-exists-p file)
+ (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)
+ (case-fold-search t))
+ (org-with-point-at 1
+ (while (re-search-forward id-regexp nil t)
+ (when (org-at-property-p)
+ (push (org-entry-get (point) "ID") ids)))
+ (when ids
+ (push (cons (abbreviate-file-name file) ids)
+ org-id-locations)
+ (dolist (id ids)
+ (cond
+ ((not (member id seen-ids)) (push id 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.
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 3c902b6033..b39af91038 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -212,6 +212,12 @@ because otherwise all these markers will point to nowhere."
`(let (pop-up-frames pop-up-windows)
,@body))
+(defmacro org-element-with-disabled-cache (&rest body)
+ "Run BODY without active org-element-cache."
+ (declare (debug (form body)) (indent 1))
+ `(cl-letf (((symbol-function #'org-element--cache-active-p) (lambda (&rest
_) nil)))
+ ,@body))
+
;;; Buffer and windows