branch: externals/denote
commit c0438cd2d6ae5864511e15c4fc9925a0f4b73789
Author: Protesilaos Stavrou <i...@protesilaos.com>
Commit: Protesilaos Stavrou <i...@protesilaos.com>

    Simplify denote-dired-mode-in-directories (tweak 21f1c98)
    
    Thanks to leinfink for the feedback in the comments of pull request
    190 on the GitHub mirror: <https://github.com/protesilaos/denote/pull/191>.
---
 denote.el | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/denote.el b/denote.el
index 1538a1e24d..e9dc910de2 100644
--- a/denote.el
+++ b/denote.el
@@ -2875,27 +2875,15 @@ Add this function to `dired-mode-hook'.
 
 If `denote-dired-include-subdirectories' is non-nil, also enable
 it in all subdirectories."
-  (cl-labels ((partial-paths (dir)
-                ;; e.g '("/home/", "/home/docs/", "/home/docs/stuff/")
-               (let* ((path-elements (split-string dir "/" t)))
-                 (collect-paths
-                  (cons (concat "/" (car path-elements))
-                        (cdr path-elements))
-                  nil)))
-             (collect-paths (path-elements coll)
-               (if path-elements
-                   (collect-paths
-                    (cdr path-elements)
-                    (cons (concat (car coll) (car path-elements) "/")
-                          coll))
-                 coll)))
-    (let ((cur-path (file-truename default-directory)))
-      (when (seq-intersection
-            (if denote-dired-include-subdirectories
-                (partial-paths cur-path)
-              (list cur-path))
-            (denote-dired--modes-dirs-as-dirs))
-       (denote-dired-mode 1)))))
+  (when-let ((dirs (denote-dired--modes-dirs-as-dirs))
+             ;; Also include subdirs
+             ((or (member (file-truename default-directory) dirs)
+                  (and denote-dired-include-subdirectories
+                       (seq-some
+                        (lambda (dir)
+                          (string-prefix-p dir (file-truename 
default-directory)))
+                        dirs)))))
+    (denote-dired-mode 1)))
 
 ;;;; The linking facility
 

Reply via email to