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

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

[elpa] externals/detached 8dfcdfe8c3 8/9: Add widen command


From: ELPA Syncer
Subject: [elpa] externals/detached 8dfcdfe8c3 8/9: Add widen command
Date: Thu, 22 Sep 2022 09:57:38 -0400 (EDT)

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

    Add widen command
    
    Widen will remove all narrowing restrictions in one go.
---
 detached-list.el | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/detached-list.el b/detached-list.el
index 5261dbbfea..80731e5b31 100644
--- a/detached-list.el
+++ b/detached-list.el
@@ -94,6 +94,11 @@ detached list implements."
         (kill-buffer-and-window)
       (kill-current-buffer))))
 
+(defun detached-list-widen ()
+  "Remove narrowing restrictions."
+  (interactive)
+  (detached-list-update-narrowing nil))
+
 (defun detached-list-detach-from-session (session)
   "Detach from SESSION at point."
   (interactive
@@ -152,7 +157,7 @@ Optionally SUPPRESS-OUTPUT."
   (interactive)
   (if (= (length detached-list--marked-sessions) 2)
       (apply #'detached-diff-session detached-list--marked-sessions)
-      (message "Mark two sessions")))
+    (message "Mark two sessions")))
 
 (defun detached-list-open-session ()
   "View session."
@@ -384,6 +389,20 @@ If prefix-argument is provided unmark instead of mark."
                      (detached-list--get-filtered-sessions)))
       (tabulated-list-print t))))
 
+(defun detached-list-update-narrowing (filters)
+  "Update narrowing with FILTERS."
+  (let* ((current-buffer (current-buffer))
+         (window (get-buffer-window current-buffer))
+         (new-buffer (detached-list--get-buffer filters)))
+    (with-current-buffer new-buffer
+      (set-window-buffer window new-buffer)
+      (kill-buffer current-buffer)
+      (detached-list-mode)
+      (setq detached-list--filters filters)
+      (setq tabulated-list-entries
+            (seq-map #'detached-list--get-entry
+                     (detached-list--get-filtered-sessions)))
+      (tabulated-list-print t))))
 
 ;;;; Support functions
 
@@ -527,6 +546,7 @@ If prefix-argument is provided unmark instead of mark."
     (define-key map (kbd "x") #'detached-list-detach-from-session)
     (define-key map (kbd "%") #'detached-list-mark-regexp)
     (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 "<return>") #'detached-list-open-session)
     map)



reply via email to

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