[Top][All Lists]

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

scratch/sqlite e14ba81 4/4: Document using make-multisession directly

From: Lars Ingebrigtsen
Subject: scratch/sqlite e14ba81 4/4: Document using make-multisession directly
Date: Tue, 14 Dec 2021 20:25:50 -0500 (EST)

branch: scratch/sqlite
commit e14ba814a6fb75b0c170896fbc7a3cc8b9d551e2
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Document using make-multisession directly
 doc/lispref/variables.texi                 | 20 ++++++++++++++++++++
 lisp/emacs-lisp/multisession.el            |  4 ++++
 test/lisp/emacs-lisp/multisession-tests.el |  7 +++++--
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index 23ad4bf..e6b7a65 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -2812,6 +2812,11 @@ variable @code{foo-var}, the current Emacs instance will 
retrieve that
 data when accessing the value.  If @var{synchronized} is @code{nil} or
 missing, this won't happen, and the variable in all Emacs sessions
 will be independent.
+@item :storage storage
+The storage method to use.  This can be either @code{sqlite} (on Emacs
+versions with SQLite support) or @code{files}.  If not given, this
+defaults to the value of the @code{multisession-storage} variable.
 @end table
 @end defmac
@@ -2848,6 +2853,21 @@ instances are updating the value at the same time, it's 
 which instance ``wins''.
 @end defun
+@defun make-multisession
+You can also make persistent values that aren't tied to a specific
+variable, but is tied to an explicit package and key.
+(setq foo (make-multisession :package "mail"
+                             :key "friends"))
+(setf (multisession-value foo) 'everybody)
+@end example
+This supports the same keywords as
+@code{define-multisession-variable}, but also supports a
+@code{:initial-value} keyword, which specifies the default value.
+@end defun
 @defopt multisession-storage
 This variable controls how the multisession variables are stored.  This
 value defaults to @code{files}, which means that the values are stored
diff --git a/lisp/emacs-lisp/multisession.el b/lisp/emacs-lisp/multisession.el
index 12f16db..6bb1c7d 100644
--- a/lisp/emacs-lisp/multisession.el
+++ b/lisp/emacs-lisp/multisession.el
@@ -83,6 +83,10 @@ DOC should be a doc string, and ARGS are keywords as 
applicable to
     (error "No package for the multisession object"))
   (unless key
     (error "No key for the multisession object"))
+  (unless (stringp package)
+    (error "The package has to be a string"))
+  (unless (stringp key)
+    (error "The key has to be a string"))
    :key key
    :synchronized synchronized
diff --git a/test/lisp/emacs-lisp/multisession-tests.el 
index 8994f02..0ad61b3 100644
--- a/test/lisp/emacs-lisp/multisession-tests.el
+++ b/test/lisp/emacs-lisp/multisession-tests.el
@@ -93,7 +93,9 @@
                                     (cl-incf (multisession-value bar))))))))
             (while (process-live-p proc)
               (ignore-error 'sqlite-locked-error
-                (cl-incf (multisession-value bar)))
+                (message "bar %s" (multisession-value bar))
+                ;;(cl-incf (multisession-value bar))
+                )
               (sleep-for 0.1))
             (message "bar ends up as %s" (multisession-value bar))
             (should (< (multisession-value bar) 1003)))
@@ -159,7 +161,8 @@
                             (dotimes (i 1000)
                               (cl-incf (multisession-value sbar))))))))
       (while (process-live-p proc)
-        (cl-incf (multisession-value sbar))
+        (message "sbar %s" (multisession-value sbar))
+        ;;(cl-incf (multisession-value sbar))
         (sleep-for 0.1))
       (message "sbar ends up as %s" (multisession-value sbar))
       (should (< (multisession-value sbar) 2000)))))

reply via email to

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