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

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

[elpa] externals/detached 66bc2811fb 08/10: Add possibility to toggle in


From: ELPA Syncer
Subject: [elpa] externals/detached 66bc2811fb 08/10: Add possibility to toggle initial-mode when rerun
Date: Thu, 27 Oct 2022 02:57:38 -0400 (EDT)

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

    Add possibility to toggle initial-mode when rerun
    
    This patch makes it convenient to toggle the initial-mode of a session
    when it is being rerun. Previously the user could only avoid attaching
    to a session, but this change can also revert that decision.
---
 detached-list.el | 22 ++++++++++++++--------
 detached.el      |  5 ++++-
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/detached-list.el b/detached-list.el
index 1dda53fe43..6d71959ccc 100644
--- a/detached-list.el
+++ b/detached-list.el
@@ -213,19 +213,25 @@ Optionally DELETE the session if prefix-argument is 
provided."
          detached-list-open-session-display-buffer-action))
     (detached-view-dwim session)))
 
-(defun detached-list-rerun-session (session &optional suppress-output)
+(defun detached-list-rerun-session (session &optional toggle-suppress-output)
   "Rerun SESSION at point.
 
-Optionally SUPPRESS-OUTPUT."
+Optionally TOGGLE-SUPPRESS-OUTPUT."
   (interactive
    (list (tabulated-list-get-id)
          current-prefix-arg))
-  (when (eq 'create-and-attach (detached--session-initial-mode session))
-    (when-let ((single-window (> (length (window-list)) 1))
-               (buffer (current-buffer)))
-      (delete-window (get-buffer-window))
-      (bury-buffer buffer)))
-  (detached-rerun-session session suppress-output))
+  (let ((detached-session-mode
+         (if toggle-suppress-output
+             (if (eq 'create (detached--session-initial-mode session))
+                 'create-and-attach
+               'create)
+           (detached--session-initial-mode session))))
+    (unless (eq detached-session-mode 'create)
+      (when-let ((single-window (> (length (window-list)) 1))
+                 (buffer (current-buffer)))
+        (delete-window (get-buffer-window))
+        (bury-buffer buffer)))
+    (detached-rerun-session session)))
 
 (defun detached-list-diff-marked-sessions ()
   "Diff two sessions."
diff --git a/detached.el b/detached.el
index 1a9539a3c7..e27b6a255f 100644
--- a/detached.el
+++ b/detached.el
@@ -407,6 +407,8 @@ Optionally SUPPRESS-OUTPUT if prefix-argument is provided."
   (let* ((detached-session-origin (or detached-session-origin 'shell-command))
          (detached-session-action (or detached-session-action
                                       detached-shell-command-session-action))
+         (detached-session-mode (or detached-session-mode
+                                 (if suppress-output 'create 
'create-and-attach)))
          (detached--current-session (detached-create-session command)))
     (detached-start-session command suppress-output)))
 
@@ -464,7 +466,8 @@ The session is compiled by opening its output and enabling
   (when (detached-valid-session session)
     (let* ((default-directory
              (detached--session-working-directory session))
-           (detached-session-mode (detached--session-initial-mode session))
+           (detached-session-mode (or detached-session-mode
+                                      (detached--session-initial-mode 
session)))
            (detached-session-action (detached--session-action session))
            (command (detached--session-command session)))
       (if suppress-output



reply via email to

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