update packages

This commit is contained in:
2025-06-22 17:08:08 +02:00
parent 54e5633369
commit 16a0a6db93
558 changed files with 68349 additions and 26568 deletions

View File

@@ -1,2 +1,2 @@
;; Generated package description from persist.el -*- no-byte-compile: t -*-
(define-package "persist" "0.5" "Persist Variables between Emacs Sessions" 'nil :commit "25d675307c03f720e592c3dc9a5a0ae8db0836eb" :url "https://elpa.gnu.org/packages/persist.html" :authors '(("Phillip Lord" . "phillip.lord@russet.org.uk")) :maintainer '("Phillip Lord" . "phillip.lord@russet.org.uk"))
(define-package "persist" "0.6.1" "Persist Variables between Emacs Sessions" '((emacs "26.1")) :commit "5ea8f32ef50ce2b444d6918e17eedce9f74629af" :url "https://elpa.gnu.org/packages/persist.html" :authors '(("Phillip Lord" . "phillip.lord@russet.org.uk")) :maintainer '("Joseph Turner" . "persist-el@breatheoutbreathe.in"))

View File

@@ -1,11 +1,12 @@
;;; persist.el --- Persist Variables between Emacs Sessions -*- lexical-binding: t -*-
;; Copyright (C) 2019 Free Software Foundation, Inc.
;; Copyright (C) 2019, 2024 Free Software Foundation, Inc.
;; Author: Phillip Lord <phillip.lord@russet.org.uk>
;; Maintainer: Phillip Lord <phillip.lord@russet.org.uk>
;; Maintainer: Joseph Turner <persist-el@breatheoutbreathe.in>
;; Package-Type: multi
;; Version: 0.5
;; Package-Requires: ((emacs "26.1"))
;; Version: 0.6.1
;; The contents of this file are subject to the GPL License, Version 3.0.
@@ -22,7 +23,7 @@
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
@@ -41,6 +42,7 @@
;; variables.
;;; Code:
(defvar persist--directory-location
(locate-user-emacs-file "persist")
"The location of persist directory.")
@@ -63,14 +65,14 @@ variable is not set to the value.")
persist--directory-location)))
(defun persist--defvar-1 (symbol location)
"Set symbol up for persistance."
"Set symbol up for persistence."
(when location
(persist-location symbol location))
(persist-symbol symbol (symbol-value symbol))
(persist-load symbol))
(defmacro persist-defvar (symbol initvalue docstring &optional location)
"Define SYMBOL as a persistant variable and return SYMBOL.
"Define SYMBOL as a persistent variable and return SYMBOL.
This form is nearly equivalent to `defvar', except that the
variable persists between Emacs sessions.
@@ -85,7 +87,9 @@ DOCSTRING need to be given."
;; Don't support 2-arity calls either because we are lazy and
;; because if you want to persist it, you want to doc it.
(declare (debug (symbolp form stringp &optional form)) (doc-string 3))
(declare (debug (symbolp form stringp &optional form))
(doc-string 3)
(indent defun))
;; Define inside progn so the byte compiler sees defvar
`(progn
(defvar ,symbol ,initvalue ,docstring)
@@ -103,7 +107,7 @@ to persist a variable, you will normally need to call
(put symbol 'persist-location (expand-file-name directory)))
(defun persist-symbol (symbol &optional initvalue)
"Make SYMBOL a persistant variable.
"Make SYMBOL a persistent variable.
If non-nil, INITVALUE is the value to which SYMBOL will be set if
`persist-reset' is called. Otherwise, the INITVALUE will be the
@@ -118,10 +122,10 @@ to load a previously saved location."
(let ((initvalue (or initvalue (symbol-value symbol))))
(add-to-list 'persist--symbols symbol)
(put symbol 'persist t)
(put symbol 'persist-default initvalue)))
(put symbol 'persist-default (persist-copy initvalue))))
(defun persist--persistant-p (symbol)
"Return non-nil if SYMBOL is a persistant variable."
"Return non-nil if SYMBOL is a persistent variable."
(get symbol 'persist))
(defun persist-save (symbol)
@@ -131,10 +135,10 @@ Normally, it should not be necessary to call this explicitly, as
variables persist automatically when Emacs exits."
(unless (persist--persistant-p symbol)
(error (format
"Symbol %s is not persistant" symbol)))
"Symbol %s is not persistent" symbol)))
(let ((symbol-file-loc (persist--file-location symbol)))
(if (equal (symbol-value symbol)
(persist-default symbol))
(if (persist-equal (symbol-value symbol)
(persist-default symbol))
(when (file-exists-p symbol-file-loc)
(delete-file symbol-file-loc))
(let ((dir-loc
@@ -158,8 +162,8 @@ variables persist automatically when Emacs exits."
(get symbol 'persist-default))
(defun persist-reset (symbol)
"Reset the value of SYMBOL to the default."
(set symbol (persist-default symbol)))
"Set the value of SYMBOL to a copy of the default."
(set symbol (persist-copy (persist-default symbol))))
(defun persist-load (symbol)
"Load the saved value of SYMBOL."
@@ -180,12 +184,66 @@ This does not remove any saved value of SYMBOL."
(remove symbol persist--symbols)))
(defun persist--save-all ()
"Save all persistant symbols."
"Save all persistent symbols."
(mapc 'persist-save persist--symbols))
;; Save on kill-emacs-hook anyway
(add-hook 'kill-emacs-hook
'persist--save-all)
(defun persist-equal (a b)
"Return non-nil when the values of A and B are equal.
A and B are compared using `equal' unless they are both hash
tables. In that case, the following are compared:
- hash table count
- hash table predicate
- values, using `persist-equal'"
(if (and (hash-table-p a) (hash-table-p b))
(and (= (hash-table-count a) (hash-table-count b))
(eq (hash-table-test a) (hash-table-test b))
(catch 'done
(maphash
(lambda (key a-value)
(unless (persist-equal a-value (gethash key b (not a-value)))
(throw 'done nil)))
a)
t))
(equal a b)))
(defun persist-copy-tree (tree &optional vectors-and-records)
"Make a copy of TREE.
If TREE is a cons cell, this recursively copies both its car and its cdr.
Contrast to `copy-sequence', which copies only along the cdrs.
With the second argument VECTORS-AND-RECORDS non-nil, this
traverses and copies vectors and records as well as conses."
(declare (side-effect-free error-free))
(if (consp tree)
(let (result)
(while (consp tree)
(let ((newcar (car tree)))
(if (or (consp (car tree))
(and vectors-and-records
(or (vectorp (car tree)) (recordp (car tree)))))
(setq newcar (persist-copy-tree (car tree) vectors-and-records)))
(push newcar result))
(setq tree (cdr tree)))
(nconc (nreverse result)
(if (and vectors-and-records (or (vectorp tree) (recordp tree)))
(persist-copy-tree tree vectors-and-records)
tree)))
(if (and vectors-and-records (or (vectorp tree) (recordp tree)))
(let ((i (length (setq tree (copy-sequence tree)))))
(while (>= (setq i (1- i)) 0)
(aset tree i (persist-copy-tree (aref tree i) vectors-and-records)))
tree)
tree)))
(defun persist-copy (obj)
"Return copy of OBJ."
(if (hash-table-p obj)
(copy-hash-table obj)
(persist-copy-tree obj t)))
(provide 'persist)
;;; persist.el ends here

View File

@@ -1,10 +1,10 @@
\input texinfo
@setfilename persist.info
@settitle persist persistant variables
@settitle persist persistent variables
@dircategory Emacs
@direntry
* Persist: (persist). Persistant variables for Emacs.
* Persist: (persist). Persistent variables for Emacs.
@end direntry
@copying
@@ -29,7 +29,7 @@ and modified without restriction.
@end copying
@titlepage
@title Persist -- Persistant Variables for Emacs
@title Persist -- Persistent Variables for Emacs
@author by Phillip Lord
@page
@insertcopying
@@ -38,9 +38,9 @@ and modified without restriction.
@contents
@node Top
@top Persist -- Persistant Variables for Emacs
@top Persist -- Persistent Variables for Emacs
Perist is a library for making variables persistant; that it, their
Persist is a library for making variables persistent; that it, their
state can be changed from the default and the new value will remain even
after Emacs has been closed and restarted.
@@ -68,7 +68,7 @@ not support the lower arity versions of @code{defvar}. Both an
(persist-defvar my-persistant-variable 10
"A variable of no purpose.
This variable is persistant between sessions")
This variable is persistent between sessions")
@end group
@end example
@@ -79,15 +79,15 @@ This variable is persistant between sessions")
@defmac persist-defvar (var initvalue docstring) body@dots{}
This macro is equivalent to @code{defvar} and can be used to make a
variable persistant.
variable persistent.
@end defmac
@defun persist-symbol (symbol &optional initvalue)
This function takes @code{symbol} for an existing, non-persistant variable
and makes it persistant. If @code{initvalue} is not given, then the
This function takes @code{symbol} for an existing, non-persistent variable
and makes it persistent. If @code{initvalue} is not given, then the
current value is used. For package developers, @code{persist-defvar}
would generally be prefered; this function might be useful for making
third-party variables persistant.
would generally be preferred; this function might be useful for making
third-party variables persistent.
@end defun
@example

View File

@@ -25,51 +25,57 @@
:type 'error
:exclude-subtypes t))
(ert-deftest test-persist-save ()
(with-local-temp-persist
(let ((sym (cl-gensym)))
;; precondition
(should-not (file-exists-p (persist--file-location sym)))
(set sym 10)
(persist-symbol sym 10)
(persist-save sym)
(should t)
(should-not (file-exists-p (persist--file-location sym)))
(set sym 20)
(persist-save sym)
(should (file-exists-p (persist--file-location sym)))
(should
(string-match-p
"20"
(with-temp-buffer
(insert-file-contents (persist--file-location sym))
(buffer-string))))
(set sym 10)
(persist-save sym)
(should-not (file-exists-p (persist--file-location sym)))
(should-error
(persist-save 'fred)))))
(defmacro persist-test-persist-save (init default change printed-changed)
"Test persisting symbols.
- symbol is not persisted when value is set to INIT and default
value is set to DEFAULT.
- symbol is persisted when value is changed according to CHANGE.
- persisted file contents match PRINTED-CHANGED.
- symbol is not persisted after value is set back to DEFAULT."
`(with-local-temp-persist
(let ((sym (cl-gensym)))
(should-not (file-exists-p (persist--file-location sym)))
(set sym ,init)
(persist-symbol sym ,default)
(persist-save sym)
(should t)
(should-not (file-exists-p (persist--file-location sym)))
,change
(persist-save sym)
(should (file-exists-p (persist--file-location sym)))
(should
(string-match-p
,printed-changed
(with-temp-buffer
(insert-file-contents (persist--file-location sym))
(buffer-string))))
(set sym ,default)
(persist-save sym)
(should-not (file-exists-p (persist--file-location sym))))))
(ert-deftest test-persist-save-non-number ()
"Test saving something that is not a number.
(ert-deftest test-persist-save-number ()
"Test saving number."
(persist-test-persist-save 1 1 (set sym 2) "2"))
`test-persist-save' missed "
(with-local-temp-persist
(let ((sym (cl-gensym)))
(set sym "fred")
(persist-symbol sym "fred")
(persist-save sym)
(should t)
(should-not (file-exists-p (persist--file-location sym)))
(set sym "george")
(persist-save sym)
(should (file-exists-p (persist--file-location sym)))
(should
(string-match-p
"george"
(with-temp-buffer
(insert-file-contents (persist--file-location sym))
(buffer-string)))))))
(ert-deftest test-persist-save-string ()
"Test saving string."
(persist-test-persist-save "foo" "foo" (set sym "bar") "bar"))
(ert-deftest test-persist-save-hash ()
"Test saving hash table."
(let* ((hash (make-hash-table))
(default (copy-hash-table hash)))
(persist-test-persist-save hash default
(puthash 'foo "bar" (symbol-value sym))
"#s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data (foo \"bar\"))")))
(ert-deftest test-persist-save-record ()
"Test saving record."
(let* ((rec (record 'foo 'a 'b))
(default (copy-sequence rec)))
(persist-test-persist-save rec default
(setf (aref (symbol-value sym) 2) 'quux)
"#s(foo a quux)")))
(ert-deftest test-persist-load ()
(with-local-temp-persist
@@ -128,3 +134,13 @@
(should-error
(persist-save 'fred)))
(delete-directory "./persist-defined-location" t)))
(ert-deftest test-persist-reset ()
"Symbol should be reset to a copy of the default."
(with-local-temp-persist
(persist-defvar persist--test-reset-variable (make-hash-table) "docstring")
(should-not (eq persist--test-reset-variable
(persist-default 'persist--test-reset-variable)))
(persist-reset 'persist--test-reset-variable)
(should-not (eq persist--test-reset-variable
(persist-default 'persist--test-reset-variable)))))