branch: externals/org
commit 24ec410f49a7418611ed925134d4e2fbcdeb67ec
Author: Stefan Monnier <monn...@iro.umontreal.ca>
Commit: Kyle Meyer <k...@kyleam.com>

    Backport commit 399824266 from Emacs
    
    * lisp/org-persist.el: Minor cleanup.
    (org-persist-directory, org-persist-remote-files)
    (org-persist-default-expiry): Remove redundant `:group` arg.
    (org-persist-collection-let): Document lack of hygiene.
    Remove `with-no-warnings`.
    (org-persist--find-index): Reindent, and simplify initialization of `r`.
    (org-persist-associated-files:generic): Move before first use.
    
    org-persist.el: Silence fewer warnings and fix found warning
    3998242664604e9e91830b10529cc2da6bd82d8e
    Stefan Monnier
    Sun Jul 13 23:14:53 2025 -0400
---
 lisp/org-persist.el | 67 +++++++++++++++++++++++++----------------------------
 1 file changed, 32 insertions(+), 35 deletions(-)

diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 16ac13ae87..f51b0d5634 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -291,7 +291,6 @@
         cache-dir))
     "org-persist/"))
   "Directory where the data is stored."
-  :group 'org-persist
   :package-version '(Org . "9.6")
   :type 'directory)
 
@@ -306,7 +305,6 @@ up to that number persistent values for remote files.
 
 Note that the last option `check-existence' may cause Emacs to show
 password prompts to log in."
-  :group 'org-persist
   :package-version '(Org . "9.6")
   :type '(choice (const :tag "Never" nil)
                  (const :tag "Always" t)
@@ -321,7 +319,6 @@ session.  When `never', the data never vanishes.  When a 
number, the
 data is deleted that number days after last access.  When a function,
 it should be a function returning non-nil when the data is expired.  The
 function will be called with a single argument - collection."
-  :group 'org-persist
   :package-version '(Org . "9.6")
   :type '(choice (const :tag "Never" never)
                  (const :tag "Always" nil)
@@ -517,32 +514,32 @@ FORMAT and ARGS are passed to `message'."
 ;;;; Working with index
 
 (defmacro org-persist-collection-let (collection &rest body)
-  "Bind container and associated from COLLECTION and execute BODY."
+  "Bind container and associated from COLLECTION and execute BODY.
+BODY is executed in a context with the following additional variables:
+`container', `associated', `path', `inode', `hash', and `key'."
   (declare (debug (form body)) (indent 1))
-  `(with-no-warnings
-     (let* ((container (plist-get ,collection :container))
-            (associated (plist-get ,collection :associated))
-            (path (plist-get associated :file))
-            (inode (plist-get associated :inode))
-            (hash (plist-get associated :hash))
-            (key (plist-get associated :key)))
-       ;; Suppress "unused variable" warnings.
-       (ignore container associated path inode hash key)
-       ,@body)))
+  `(let* ((container (plist-get ,collection :container))
+          (associated (plist-get ,collection :associated))
+          (path (plist-get associated :file))
+          (inode (plist-get associated :inode))
+          (hash (plist-get associated :hash))
+          (key (plist-get associated :key)))
+     ;; Suppress "unused variable" warnings.
+     (ignore container associated path inode hash key)
+     ,@body))
 
 (defun org-persist--find-index (collection)
-"Find COLLECTION in `org-persist--index'."
-(org-persist-collection-let collection
-  (and org-persist--index-hash
-       (catch :found
-         (dolist (cont (cons container container))
-           (let (r)
-             (setq r (or (gethash (cons cont associated) 
org-persist--index-hash)
-                         (and path (gethash (cons cont (list :file path)) 
org-persist--index-hash))
-                         (and inode (gethash (cons cont (list :inode inode)) 
org-persist--index-hash))
-                         (and hash (gethash (cons cont (list :hash hash)) 
org-persist--index-hash))
-                         (and key (gethash (cons cont (list :key key)) 
org-persist--index-hash))))
-             (when r (throw :found r))))))))
+  "Find COLLECTION in `org-persist--index'."
+  (org-persist-collection-let collection
+    (and org-persist--index-hash
+         (catch :found
+           (dolist (cont (cons container container))
+             (let ((r (or (gethash (cons cont associated) 
org-persist--index-hash)
+                          (and path (gethash (cons cont (list :file path)) 
org-persist--index-hash))
+                          (and inode (gethash (cons cont (list :inode inode)) 
org-persist--index-hash))
+                          (and hash (gethash (cons cont (list :hash hash)) 
org-persist--index-hash))
+                          (and key (gethash (cons cont (list :key key)) 
org-persist--index-hash)))))
+               (when r (throw :found r))))))))
 
 (defun org-persist--add-to-index (collection &optional hash-only)
   "Add or update COLLECTION in `org-persist--index'.
@@ -568,6 +565,15 @@ Return PLIST."
           (when key (puthash (cons cont (list :key inode)) collection 
org-persist--index-hash)))
         collection))))
 
+(defmacro org-persist-associated-files:generic (container collection)
+  "List associated files in `org-persist-directory' of CONTAINER in 
COLLECTION."
+  `(let* ((c (org-persist--normalize-container ,container))
+          (assocf-func-symbol (intern (format 
"org-persist-associated-files:%s" (car c)))))
+     (if (fboundp assocf-func-symbol)
+         (funcall assocf-func-symbol c ,collection)
+       (error "org-persist: Read function %s not defined"
+              assocf-func-symbol))))
+
 (defun org-persist--remove-from-index (collection)
   "Remove COLLECTION from `org-persist--index'."
   (let ((existing (org-persist--find-index collection)))
@@ -1194,15 +1200,6 @@ Do nothing in an indirect buffer."
     (when (org-directory-empty-p (file-name-directory persist-file))
       (delete-directory (file-name-directory persist-file)))))
 
-(defmacro org-persist-associated-files:generic (container collection)
-  "List associated files in `org-persist-directory' of CONTAINER in 
COLLECTION."
-  `(let* ((c (org-persist--normalize-container ,container))
-          (assocf-func-symbol (intern (format 
"org-persist-associated-files:%s" (car c)))))
-     (if (fboundp assocf-func-symbol)
-         (funcall assocf-func-symbol c ,collection)
-       (error "org-persist: Read function %s not defined"
-              assocf-func-symbol))))
-
 (defalias 'org-persist-associated-files:elisp #'ignore)
 (defalias 'org-persist-associated-files:index #'ignore)
 (defalias 'org-persist-associated-files:elisp-data #'ignore)

Reply via email to