aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-12-15 02:09:18 +0100
committerLars Ingebrigtsen2021-12-15 02:09:18 +0100
commit95534948d70daaf3e5abf63273b08c52eb3d7f0e (patch)
tree6398c0e9b3a668596f30d21965dfdbf16d1d87db
parentd37212aba7f4dea0421b5514a960b17f62e30d09 (diff)
downloademacs-95534948d70daaf3e5abf63273b08c52eb3d7f0e.tar.gz
emacs-95534948d70daaf3e5abf63273b08c52eb3d7f0e.zip
Use a less hacky value for the unbound value
-rw-r--r--lisp/emacs-lisp/multisession.el11
1 files changed, 6 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/multisession.el b/lisp/emacs-lisp/multisession.el
index a15f40ca04d..7eda0127b9a 100644
--- a/lisp/emacs-lisp/multisession.el
+++ b/lisp/emacs-lisp/multisession.el
@@ -57,6 +57,8 @@ DOC should be a doc string, and ARGS are keywords as applicable to
57 ,@args) 57 ,@args)
58 ,@(list doc))) 58 ,@(list doc)))
59 59
60(defconst multisession--unbound (make-symbol "unbound"))
61
60(cl-defstruct (multisession 62(cl-defstruct (multisession
61 (:constructor nil) 63 (:constructor nil)
62 (:constructor multisession--create) 64 (:constructor multisession--create)
@@ -66,8 +68,7 @@ DOC should be a doc string, and ARGS are keywords as applicable to
66 (initial-value nil) 68 (initial-value nil)
67 package 69 package
68 (synchronized nil) 70 (synchronized nil)
69 ;; We need an "impossible" value for the unbound case. 71 (cached-value multisession--unbound)
70 (cached-value (make-marker))
71 (cached-sequence 0)) 72 (cached-sequence 0))
72 73
73(cl-defun make-multisession (&key key initial-value package synchronized) 74(cl-defun make-multisession (&key key initial-value package synchronized)
@@ -88,7 +89,7 @@ DOC should be a doc string, and ARGS are keywords as applicable to
88 (if (null user-init-file) 89 (if (null user-init-file)
89 ;; If we don't have storage, then just return the value from the 90 ;; If we don't have storage, then just return the value from the
90 ;; object. 91 ;; object.
91 (if (markerp (multisession--cached-value object)) 92 (if (eq (multisession--cached-value object) multisession--unbound)
92 (multisession--initial-value object) 93 (multisession--initial-value object)
93 (multisession--cached-value object)) 94 (multisession--cached-value object))
94 ;; We have storage, so we update from storage. 95 ;; We have storage, so we update from storage.
@@ -144,7 +145,7 @@ DOC should be a doc string, and ARGS are keywords as applicable to
144 (symbol-name (multisession--key object))))) 145 (symbol-name (multisession--key object)))))
145 (cond 146 (cond
146 ;; We have no value yet; check the database. 147 ;; We have no value yet; check the database.
147 ((markerp (multisession--cached-value object)) 148 ((eq (multisession--cached-value object) multisession--unbound)
148 (let ((stored 149 (let ((stored
149 (car 150 (car
150 (sqlite-select 151 (sqlite-select
@@ -253,7 +254,7 @@ DOC should be a doc string, and ARGS are keywords as applicable to
253 (let ((file (multisession--object-file-name object))) 254 (let ((file (multisession--object-file-name object)))
254 (cond 255 (cond
255 ;; We have no value yet; see whether it's stored. 256 ;; We have no value yet; see whether it's stored.
256 ((markerp (multisession--cached-value object)) 257 ((eq (multisession--cached-value object) multisession--unbound)
257 (if (file-exists-p file) 258 (if (file-exists-p file)
258 (multisession--update-file-value file object) 259 (multisession--update-file-value file object)
259 ;; Nope; return the initial value. 260 ;; Nope; return the initial value.