emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 9e5c25ba75 1/2: org-persist-unregister: Allow remov


From: ELPA Syncer
Subject: [elpa] externals/org 9e5c25ba75 1/2: org-persist-unregister: Allow removing related containers
Date: Tue, 3 Jan 2023 03:58:02 -0500 (EST)

branch: externals/org
commit 9e5c25ba7522a34a3ffbad518d14fd9efddf6bcf
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    org-persist-unregister: Allow removing related containers
    
    * lisp/org-persist.el (org-persist-unregister): Add new optional key
    :remove-related to remove all the containers stored alongside with
    CONTAINER in addition to CONTAINER itself.  Update to docstring.
---
 lisp/org-persist.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 9df385b82b..43a35e6f4c 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -906,20 +906,22 @@ with `org-persist-write'."
       (add-hook 'kill-buffer-hook #'org-persist-write-all-buffer nil 'local)))
   (when write-immediately (org-persist-write container associated)))
 
-(defun org-persist-unregister (container &optional associated)
+(cl-defun org-persist-unregister (container &optional associated &key 
remove-related)
   "Unregister CONTAINER in ASSOCIATED to be persistent.
-When ASSOCIATED is `all', unregister CONTAINER everywhere."
+When ASSOCIATED is `all', unregister CONTAINER everywhere.
+When REMOVE-RELATED is non-nil, remove all the containers stored with
+the CONTAINER as well."
   (unless org-persist--index (org-persist--load-index))
   (setq container (org-persist--normalize-container container))
   (setq associated (org-persist--normalize-associated associated))
   (if (eq associated 'all)
       (mapc (lambda (collection)
               (when (member container (plist-get collection :container))
-                (org-persist-unregister container (plist-get collection 
:associated))))
+                (org-persist-unregister container (plist-get collection 
:associated) :remove-related remove-related)))
             org-persist--index)
     (let ((collection (org-persist--find-index `(:container ,container 
:associated ,associated))))
       (when collection
-        (if (= (length (plist-get collection :container)) 1)
+        (if (or remove-related (= (length (plist-get collection :container)) 
1))
             (org-persist--remove-from-index collection)
           (plist-put collection :container
                      (remove container (plist-get collection :container)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]