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

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

[nongnu] elpa/undo-fu-session 1dd26609fb: Account for derived modes when


From: ELPA Syncer
Subject: [nongnu] elpa/undo-fu-session 1dd26609fb: Account for derived modes when matching *-incompatible-major-modes
Date: Thu, 7 Dec 2023 16:00:42 -0500 (EST)

branch: elpa/undo-fu-session
commit 1dd26609fb8db83738912583bb5d6b491e6f31e1
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Account for derived modes when matching *-incompatible-major-modes
    
    Suggested #8.
---
 changelog.rst      |  1 +
 readme.rst         |  3 +++
 undo-fu-session.el | 18 +++++++++++++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/changelog.rst b/changelog.rst
index 90697977c0..27a69cd6cb 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -5,6 +5,7 @@ Change Log
 
 - In development
 
+  - Support derived major-modes when checking 
``undo-fu-session-incompatible-major-modes``.
   - Add ``undo-fu-session-temp-directories`` so additional directories can be 
considered temporary.
 
 - Version 0.6 (2023-05-20)
diff --git a/readme.rst b/readme.rst
index 95f255dca2..1264bd5afe 100644
--- a/readme.rst
+++ b/readme.rst
@@ -103,6 +103,9 @@ With exceptions added for cases where undo-session should 
not be stored.
    List of regexps or functions for matching file names to ignore 
saving/recovering undo session.
 ``undo-fu-session-incompatible-major-modes`` (``nil``)
    List of major-modes in which saving undo session should not be performed.
+
+   This matches derived modes so you may include a mode that other modes are 
derived from
+   to avoid having to explicitly list all modes.
 ``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``)
diff --git a/undo-fu-session.el b/undo-fu-session.el
index e11531438d..a06eccee6c 100755
--- a/undo-fu-session.el
+++ b/undo-fu-session.el
@@ -499,6 +499,21 @@ Argument PENDING-LIST an `pending-undo-list' compatible 
list."
                 (funcall matcher filename)))
           (throw 'found t))))))
 
+(defun undo-fu-session--match-major-mode (mode test-modes)
+  "Return t if MODE match any item in TEST-MODES."
+  (declare (side-effect-free error-free))
+  (let ((found nil))
+    (while mode
+      (setq mode
+            (cond
+             ((memq mode test-modes)
+              (setq found t)
+              ;; Clear to break early.
+              nil)
+             (t
+              (get mode 'derived-mode-parent)))))
+    found))
+
 (defun undo-fu-session--temp-file-check (filename)
   "Return t if FILENAME is in a temporary directory."
   (declare (side-effect-free error-free))
@@ -548,7 +563,8 @@ Argument PENDING-LIST an `pending-undo-list' compatible 
list."
       nil)
      ((and test-files (undo-fu-session--match-file-name filename test-files))
       nil)
-     ((and test-modes (memq (buffer-local-value 'major-mode buffer) 
test-modes))
+     ((and test-modes
+           (undo-fu-session--match-major-mode (buffer-local-value 'major-mode 
buffer) test-modes))
       nil)
      (t
       t))))



reply via email to

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