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

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

[elpa] externals/detached 776f4e4521 5/5: Improve detached list narrow f


From: ELPA Syncer
Subject: [elpa] externals/detached 776f4e4521 5/5: Improve detached list narrow functionality
Date: Fri, 23 Sep 2022 05:57:30 -0400 (EDT)

branch: externals/detached
commit 776f4e45216ed61cf82885dc7332e3954e369dd1
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>

    Improve detached list narrow functionality
    
    Introduce a keybinding to remove narrow criteria one after
    another. Also make criterias be persistent. Instead of killing the
    detached list buffer it gets burried so that when detached list
    sessions are called a second time it resumes with the same narrow
    criterias.
---
 CHANGELOG.org    |  1 +
 detached-list.el | 46 +++++++++++++++++++++++++++++++---------------
 2 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 389156535a..406ae67b96 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -7,6 +7,7 @@
 - Use =display-buffer= in =detached-list= in order for users to more easily 
customize the display of the buffer.
 - Add concept of =filters= to quickly apply a set of narrow criteria.
 - Speed up initialization of sessions.
+- Narrow criteria are persistent and applied when resuming detached list 
sessions.
 
 * Version 0.9.1 (2022-09-22)
 
diff --git a/detached-list.el b/detached-list.el
index d001477803..deb9ddc754 100644
--- a/detached-list.el
+++ b/detached-list.el
@@ -88,18 +88,24 @@ detached list implements."
 
 ;;;; Commands
 
-(defun detached-list-quit-dwim ()
-  "Quit DWIM command."
+(defun detached-list-quit ()
+  "Quit command."
+  (interactive)
+  (if (= (length (window-list)) 1)
+      (bury-buffer)
+    (bury-buffer)
+    (delete-window)))
+
+(defun detached-list-remove-narrow-criterion ()
+  "Remove narrow criterion."
   (interactive)
   (if detached-list--filters
       (detached-list-update-narrowing
        (cdr detached-list--filters))
-    (if (> (length (window-list)) 1)
-        (kill-buffer-and-window)
-      (kill-current-buffer))))
+    (message "No criterion to remove")))
 
 (defun detached-list-widen ()
-  "Remove narrowing restrictions."
+  "Remove all narrowing restrictions."
   (interactive)
   (detached-list-update-narrowing nil))
 
@@ -225,6 +231,7 @@ Optionally SUPPRESS-OUTPUT."
   (interactive)
   (when-let* ((filter-name (completing-read "Select filter: " 
detached-list-filters))
               (filter (alist-get filter-name detached-list-filters nil nil 
#'string=)))
+    (setq detached-list--filters nil)
     (seq-do (lambda (it) (apply it)) filter)))
 
 (defun detached-list-narrow-origin (origin)
@@ -371,14 +378,22 @@ If prefix-argument is provided unmark instead of mark."
 (defun detached-list-sessions ()
   "Open list of `detached'."
   (interactive)
-  (let* ((buffer (detached-list--get-buffer))
-         (window (display-buffer buffer detached-list-display-buffer-action)))
-    (with-selected-window window
-      (detached-list-mode)
-      (setq tabulated-list-entries
-            (seq-map #'detached-list--get-entry
-                     (detached-list--get-filtered-sessions)))
-      (tabulated-list-print t))))
+  (if-let* ((existing-buffer
+             (seq-find (lambda (buffer)
+                         (with-current-buffer buffer
+                           (eq major-mode 'detached-list-mode)))
+                       (buffer-list)))
+            (window (display-buffer existing-buffer 
detached-list-display-buffer-action)))
+      (with-selected-window window
+        (detached-list--revert-sessions))
+    (let* ((buffer (detached-list--get-buffer))
+           (window (display-buffer buffer 
detached-list-display-buffer-action)))
+      (with-selected-window window
+        (detached-list-mode)
+        (setq tabulated-list-entries
+              (seq-map #'detached-list--get-entry
+                       (detached-list--get-filtered-sessions)))
+        (tabulated-list-print t)))))
 
 (defun detached-list-narrow-sessions (filters)
   "Narrow session(s) based on FILTERS."
@@ -540,7 +555,7 @@ If prefix-argument is provided unmark instead of mark."
     (define-key map (kbd "n r") #'detached-list-narrow-remote)
     (define-key map (kbd "n s") #'detached-list-narrow-success)
     (define-key map (kbd "n %") #'detached-list-narrow-regexp)
-    (define-key map (kbd "q") #'detached-list-quit-dwim)
+    (define-key map (kbd "q") #'detached-list-quit)
     (define-key map (kbd "r") #'detached-list-rerun-session)
     (define-key map (kbd "s") #'imenu)
     (define-key map (kbd "t") #'detached-list-toggle-mark-session)
@@ -554,6 +569,7 @@ If prefix-argument is provided unmark instead of mark."
     (define-key map (kbd "=") #'detached-list-diff-marked-sessions)
     (define-key map (kbd "-") #'detached-list-widen)
     (define-key map (kbd "!") #'detached-shell-command)
+    (define-key map (kbd "<backspace>") 
#'detached-list-remove-narrow-criterion)
     (define-key map (kbd "<return>") #'detached-list-open-session)
     map)
   "Keymap used in `detached-list-mode'.")



reply via email to

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