branch: elpa/undo-fu-session
commit 834f551117b52e9f8aac7d6908d75c56cd9a2cd4
Author: Campbell Barton <ideasma...@gmail.com>
Commit: Campbell Barton <ideasma...@gmail.com>

    Add undo-fu-session-ignore-temp-files
---
 changelog.rst      |  4 ++++
 readme.rst         |  6 ++++--
 undo-fu-session.el | 24 +++++++++++++++---------
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/changelog.rst b/changelog.rst
index 34cbc57e30..90697977c0 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -3,6 +3,10 @@
 Change Log
 ##########
 
+- In development
+
+  - Add ``undo-fu-session-temp-directories`` so additional directories can be 
considered temporary.
+
 - Version 0.6 (2023-05-20)
 
   - Add ``undo-fu-session-ignore-temp-files`` to ignore files in temporary 
directories.
diff --git a/readme.rst b/readme.rst
index 451dc3f19a..e4189168c4 100644
--- a/readme.rst
+++ b/readme.rst
@@ -81,8 +81,10 @@ Customization
 ``undo-fu-session-ignore-encrypted-files`` (``t``)
    Ignore saving/recovering undo session for encrypted files (matching 
``epa-file-name-regexp``).
 ``undo-fu-session-ignore-temp-files`` (``t``)
-   Ignore saving/recovering undo session for files under 
``temporary-file-directory``
-   (as well as ``/tmp`` & ``/dev/shm/``).
+   Ignore saving/recovering undo session for files under
+   ``temporary-file-directory`` & ``undo-fu-session-temp-directories``.
+``undo-fu-session-temp-directories`` (``'("/tmp" "/dev/shm")``)
+   Directories to consider temporary when 
``undo-fu-session-ignore-temp-files`` is enabled.
 ``undo-fu-session-file-limit`` (``nil``)
    Number of files to store, nil to disable limiting entirely.
 
diff --git a/undo-fu-session.el b/undo-fu-session.el
index 30443466fc..097d217b62 100755
--- a/undo-fu-session.el
+++ b/undo-fu-session.el
@@ -68,6 +68,17 @@
   "Ignore temporary files for undo session."
   :type 'boolean)
 
+(defcustom undo-fu-session-temp-directories
+  (cond
+   ((memq system-type (list 'ms-dos 'windows-nt))
+    (list))
+   (t
+    (list "/tmp" "/dev/shm")))
+  "Temporary directories (must be absolute).
+
+Used by `undo-fu-session-ignore-temp-files' for directories to consider 
temporary."
+  :type '(repeat string))
+
 (defcustom undo-fu-session-compression 'gz
   "The type of compression to use or nil.
 
@@ -479,20 +490,15 @@ Argument PENDING-LIST an `pending-undo-list' compatible 
list."
 
 (defun undo-fu-session--temp-file-check (filename)
   "Return t if FILENAME is in a temporary directory."
-  (let ((temp-dirs (list))
+  ;; Even if this directory doesn't exist, the check is relatively harmless.
+  (let ((temp-dirs
+         (mapcar #'undo-fu-session--ensure-trailing-slash 
undo-fu-session-temp-directories))
         (is-temp nil))
+
     (when temporary-file-directory
       ;; Ensure a single slash so `string-prefix-p' can be used.
       (push (undo-fu-session--ensure-trailing-slash temporary-file-directory) 
temp-dirs))
 
-    ;; Even if this directory doesn't exist, the check is relatively harmless.
-    (cond
-     ((memq system-type (list 'ms-dos 'windows-nt))
-      nil)
-     (t
-      (push "/tmp/" temp-dirs)
-      (push "/dev/shm/" temp-dirs)))
-
     (setq temp-dirs (delete-dups temp-dirs))
 
     (when temp-dirs

Reply via email to