* [PATCH] assoc-delete-all missing from 26.1
@ 2023-12-28 22:29 Justin
2023-12-28 23:04 ` Ihor Radchenko
0 siblings, 1 reply; 2+ messages in thread
From: Justin @ 2023-12-28 22:29 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 2144 bytes --]
* lisp/org-compat: add org-assoc-delete-all from compat/compat-27.el
* lisp/org-persist: use org-assoc-delete-all
---
lisp/org-compat.el | 18 ++++++++++++++++++
lisp/org-persist.el | 2 +-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 8b1f16355..6fcea1837 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -348,6 +348,24 @@ Execute BODY, and unwind connection-local variables."
`(with-connection-local-profiles (connection-local-get-profiles nil)
,@body)))
+;; assoc-delete-all missing from 26.1
+(if (fboundp 'assoc-delete-all)
+ (defalias 'org-assoc-delete-all 'assoc-delete-all)
+ ;; from compat/compat-27.el
+ (defun org-assoc-delete-all (key alist &optional test)
+ "Delete all matching key from alist, default test equal"
+ (unless test (setq test #'equal))
+ (while (and (consp (car alist))
+ (funcall test (caar alist) key))
+ (setq alist (cdr alist)))
+ (let ((tail alist) tail-cdr)
+ (while (setq tail-cdr (cdr tail))
+ (if (and (consp (car tail-cdr))
+ (funcall test (caar tail-cdr) key))
+ (setcdr tail (cdr tail-cdr))
+ (setq tail tail-cdr))))
+ alist))
+
\f
;;; Emacs < 26.1 compatibility
diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 82c31144a..229957fb0 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -1216,7 +1216,7 @@ Remove expired sessions timestamps."
Remove current sessions from `org-persist-gc-lock-file'."
(let* ((file (org-file-name-concat org-persist-directory
org-persist-gc-lock-file))
(alist (when (file-exists-p file)
(org-persist--read-elisp-file file))))
- (setq alist (assoc-delete-all before-init-time alist))
+ (setq alist (org-assoc-delete-all before-init-time alist))
(org-persist--write-elisp-file file alist)
;; Only GC orphan files when there are no active sessions.
(not alist)))
base-commit: 80ce6152ba915b7c53d239f2b030f7afb8e70e8e
--
2.20.1
[-- Attachment #2: 0001-assoc-delete-all-missing-from-26.1.patch --]
[-- Type: text/x-patch, Size: 2209 bytes --]
From 48c84e876018a9f2f7c818c2b9fa179e47ac45b9 Mon Sep 17 00:00:00 2001
From: Justin Vallon <JustinVallon@gmail.com>
Date: Thu, 28 Dec 2023 17:16:45 -0500
Subject: [PATCH] assoc-delete-all missing from 26.1
* lisp/org-compat: add org-assoc-delete-all from compat/compat-27.el
* lisp/org-persist: use org-assoc-delete-all
---
lisp/org-compat.el | 18 ++++++++++++++++++
lisp/org-persist.el | 2 +-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 8b1f16355..6fcea1837 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -348,6 +348,24 @@ Execute BODY, and unwind connection-local variables."
`(with-connection-local-profiles (connection-local-get-profiles nil)
,@body)))
+;; assoc-delete-all missing from 26.1
+(if (fboundp 'assoc-delete-all)
+ (defalias 'org-assoc-delete-all 'assoc-delete-all)
+ ;; from compat/compat-27.el
+ (defun org-assoc-delete-all (key alist &optional test)
+ "Delete all matching key from alist, default test equal"
+ (unless test (setq test #'equal))
+ (while (and (consp (car alist))
+ (funcall test (caar alist) key))
+ (setq alist (cdr alist)))
+ (let ((tail alist) tail-cdr)
+ (while (setq tail-cdr (cdr tail))
+ (if (and (consp (car tail-cdr))
+ (funcall test (caar tail-cdr) key))
+ (setcdr tail (cdr tail-cdr))
+ (setq tail tail-cdr))))
+ alist))
+
\f
;;; Emacs < 26.1 compatibility
diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 82c31144a..229957fb0 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -1216,7 +1216,7 @@ Remove expired sessions timestamps."
Remove current sessions from `org-persist-gc-lock-file'."
(let* ((file (org-file-name-concat org-persist-directory org-persist-gc-lock-file))
(alist (when (file-exists-p file) (org-persist--read-elisp-file file))))
- (setq alist (assoc-delete-all before-init-time alist))
+ (setq alist (org-assoc-delete-all before-init-time alist))
(org-persist--write-elisp-file file alist)
;; Only GC orphan files when there are no active sessions.
(not alist)))
base-commit: 80ce6152ba915b7c53d239f2b030f7afb8e70e8e
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] assoc-delete-all missing from 26.1
2023-12-28 22:29 [PATCH] assoc-delete-all missing from 26.1 Justin
@ 2023-12-28 23:04 ` Ihor Radchenko
0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2023-12-28 23:04 UTC (permalink / raw)
To: Justin; +Cc: emacs-orgmode
Justin <justinvallon@gmail.com> writes:
> From 48c84e876018a9f2f7c818c2b9fa179e47ac45b9 Mon Sep 17 00:00:00 2001
> From: Justin Vallon <JustinVallon@gmail.com>
> Date: Thu, 28 Dec 2023 17:16:45 -0500
> Subject: [PATCH] assoc-delete-all missing from 26.1
>
> * lisp/org-compat: add org-assoc-delete-all from compat/compat-27.el
> * lisp/org-persist: use org-assoc-delete-all
Thanks for the patch, but be informed that we no longer support Emacs 26.
See https://orgmode.org/worg/org-maintenance.html#emacs-compatibility
Some newly added functionality (like DnD support) is already not
compatible with Emacs 26 and older.
I still applied your patch because it is trivial.
Applied, onto main, amending the commit message and adding TINYCHANGE
cookie (see
https://orgmode.org/worg/org-contribute.html#commit-messages)
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=684aff8ee
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-28 23:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-28 22:29 [PATCH] assoc-delete-all missing from 26.1 Justin
2023-12-28 23:04 ` Ihor Radchenko
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).