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

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

[elpa] externals/persist f7f1db9: Do not use concat for filenames


From: Phillip Lord
Subject: [elpa] externals/persist f7f1db9: Do not use concat for filenames
Date: Tue, 2 Jul 2019 17:15:28 -0400 (EDT)

branch: externals/persist
commit f7f1db9bb9da485d17783b6bf33111f1daca942e
Author: Phillip Lord <address@hidden>
Commit: Phillip Lord <address@hidden>

    Do not use concat for filenames
---
 persist.el            | 28 ++++++++++++++++------------
 test/persist-tests.el |  5 +++--
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/persist.el b/persist.el
index 7292f4a..c057389 100644
--- a/persist.el
+++ b/persist.el
@@ -41,7 +41,7 @@
 
 ;;; Code:
 (defvar persist--directory-location
-  (concat user-emacs-directory "persist")
+  (locate-user-emacs-file "persist")
   "The location of persist directory.")
 
 (defvar persist--symbols nil
@@ -56,11 +56,17 @@ variable is not set to the value.")
 
 (defun persist--file-location (symbol)
   "Return the file name at which SYMBOL does or will persist."
-  (concat
+  (expand-file-name
+   (symbol-name symbol)
    (or (get symbol 'persist-location)
-       persist--directory-location)
-   "/"
-   (symbol-name symbol)))
+       persist--directory-location)))
+
+(defun persist--defvar-1 (symbol location)
+  "Set symbol up for persistance."
+  (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.
@@ -84,18 +90,16 @@ DOCSTRING need to be given."
      (defvar ,symbol ,initvalue ,docstring)
      ;; Access initvalue through its symbol because the defvar form
      ;; has to stay at first level within a progn
-     (persist-location ',symbol ,location)
-     (persist-symbol ',symbol (symbol-value ',symbol))
-     (persist-load ',symbol)
+     (persist--defvar-1 ',symbol ,location)
      ',symbol))
 
 (defun persist-location (symbol directory)
   "Set the directory for persisting the value of symbol.
 
-This does force the loading of value from this directory, so to
-persist a variable, you will normally need to call `persist-load'
-to load a previously saved location."
-  (put symbol 'persist-location directory))
+This does not force the loading of value from this directory, so
+to persist a variable, you will normally need to call
+`persist-load' to load a previously saved location."
+  (put symbol 'persist-location (expand-file-name directory)))
 
 (defun persist-symbol (symbol &optional initvalue)
   "Make SYMBOL a persistant variable.
diff --git a/test/persist-tests.el b/test/persist-tests.el
index 6429ed2..2e06dc6 100644
--- a/test/persist-tests.el
+++ b/test/persist-tests.el
@@ -80,8 +80,9 @@
      (persist-symbol sym 10)
      (persist-location sym "./persist-defined-location")
      (should
-      (equal (concat "./persist-defined-location/"
-                     (symbol-name sym))
+      (equal (expand-file-name
+              (symbol-name sym)
+              "./persist-defined-location/")
              (persist--file-location sym)))
      (persist-save sym)
      (should t)



reply via email to

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