[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dtache 82e5859d5a 098/158: Improve dtache-detach-sessio
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dtache 82e5859d5a 098/158: Improve dtache-detach-session |
Date: |
Wed, 19 Jan 2022 18:58:02 -0500 (EST) |
branch: externals/dtache
commit 82e5859d5a1abd1e91cd342dbb39fe72c9fb870f
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Improve dtache-detach-session
This patch renames dtache-detach-session to dtache-detach-dwim. It
also improves the function by making it possible to kill buffers with
non active sessions, as long as the buffers originate from
dtache-shell-command or dtache-compile.
---
CHANELOG.org | 2 +-
README.org | 12 ++++++------
dtache.el | 45 +++++++++++++++++++++++++--------------------
3 files changed, 32 insertions(+), 27 deletions(-)
diff --git a/CHANELOG.org b/CHANELOG.org
index 21b066228f..bbf7b42afa 100644
--- a/CHANELOG.org
+++ b/CHANELOG.org
@@ -5,7 +5,7 @@
* Development
- Add dtache-type-open-dispatch variable for users to customize how to open a
function which doesn't have an open function implemented. This together with
the new attach functions for shell-command/compile makes it possible to
seamlessly reattach to sessions started with shell-command/compile.
-- Add a generic detach command, =dtache-detach-session=. This command is
supposed to be used to detach from sessions in all supported modes.
+- Add a generic detach command, =dtache-detach-dwim=. This command is supposed
to be used to detach from sessions in all supported modes.
- Add =dtache-compile.el=. This library provides commands =dtache-compile= and
=dtache-compile-recompile= which are supposed to be used instead of
=compile=/=recompile=.
- Improve =dtache-shell-command=, the command is now very similar to
=async-shell-command= and can be considered a replacement of the latter.
- Add integration with the =consult= package through =dtache-consult.el=.
diff --git a/README.org b/README.org
index 7580439638..f0d6b93a12 100644
--- a/README.org
+++ b/README.org
@@ -60,7 +60,7 @@ A minimal configuration for =dtache=.
:hook (after-init . dtache-initialize)
:bind (([remap async-shell-command] . dtache-shell-command)
:map dtache-shell-mode-map
- ("C-c C-q" . dtache-detach-session)))
+ ("C-c C-q" . dtache-detach-dwim)))
#+end_src
* Commands
@@ -78,7 +78,7 @@ There are tree different ways to create a dtache session.
The =dtache-shell-command= is for the Emacs users that are accustomed to
running shell commands from =M-x shell-command= or =M-x async-shell-command=.
The =dtache-start-session= is supposed to be called from custom user functions,
or for other packages to integrate towards. The user can also choose to
override built in functions with it, for example =compile=. Lastly there is the
=dtache-shell-create-session= command which is supposed to be bound to a key.
It is a command that the user c [...]
-To detach from a =dtache= session you should use the univeral
=dtache-detach-session=.
+To detach from a =dtache= session you should use the univeral
=dtache-detach-dwim=.
** Interacting with a session
@@ -133,7 +133,7 @@ A minor mode named =dtache-shell-mode= is provided, and
will be enabled in =shel
|-----------------------+-----------------------|
| dtache-shell-create | Create a session |
| dtache-shell-attach | Attach to a session |
-| dtache-detach-session | Detach from a session |
+| dtache-detach-dwim | Detach from a session |
** Dtache-eshell
@@ -145,7 +145,7 @@ A =use-package= configuration of the =dtache-eshell=
extension, which provides t
:bind (:map dtache-eshell-mode-map
(("<S-return>" . dtache-eshell-create-session)
("<C-return>" . dtache-eshell-attach)
- ("C-c C-q" . dtache-detach-session))))
+ ("C-c C-q" . dtache-detach-dwim))))
#+end_src
A minor mode named =dtache-eshell-mode= is provided, and will be enabled in
=eshell=. The commands that are implemented are:
@@ -154,7 +154,7 @@ A minor mode named =dtache-eshell-mode= is provided, and
will be enabled in =esh
|------------------------------+-----------------------|
| dtache-eshell-create-session | Create a session |
| dtache-eshell-attach | Attach to a session |
-| dtache-detach-session | Detach from a session |
+| dtache-detach-dwim | Detach from a session |
In this [[https://niklaseklund.gitlab.io/blog/posts/dtache_eshell/][blog
post]] there are examples and more information about the extension.
@@ -168,7 +168,7 @@ A =use-package= configuration of the =dtache-compile=
extension, which provides
:bind (([remap compile] . dtache-compile)
([remap recompile] . dtache-compile-recompile)
:map dtache-compilation-mode-map
- ("C-c C-q" . dtache-detach-session)))
+ ("C-c C-q" . dtache-detach-dwim)))
#+end_src
The package implements the commands =dtache-compile= and
=dtache-compile-recompile=, which are thin wrappers around the original
=compile= and =recompile= commands. The users should be able to use the former
as replacements for the latter without noticing any difference except from the
possibility to =detach=.
diff --git a/dtache.el b/dtache.el
index bb754efbb9..108e710f0c 100644
--- a/dtache.el
+++ b/dtache.el
@@ -375,32 +375,37 @@ Optionally SUPPRESS-OUTPUT."
(ediff-buffers buffer1 buffer2))))
;;;###autoload
-(defun dtache-detach-session ()
+(defun dtache-detach-dwim ()
"Detach from current session.
This command is only activated if `dtache--buffer-session' is set and
`dtache--session-active-p' returns t."
(interactive)
(if (dtache-session-p dtache--buffer-session)
- (if (dtache--session-active-p dtache--buffer-session)
- (if-let ((process (and (eq major-mode 'eshell-mode)
- (dtache-eshell-get-dtach-process))))
- (progn
- (setq dtache--buffer-session nil)
- (process-send-string process dtache--dtach-detach-character))
- (let ((proc (get-buffer-process (current-buffer)))
- (input dtache--dtach-detach-character))
- (comint-simple-send proc input)
- (setq dtache--buffer-session nil)
- (when
- (cond ((string-match "\*Dtache Shell Command" (buffer-name))
t)
- ((string-match "\*dtache-compilation" (buffer-name)) t)
- (t nil))
- (let ((kill-buffer-query-functions nil))
- (kill-buffer-and-window)
- (message "[detached]")))))
- (setq dtache--buffer-session nil))
- (message "No `dtache-session' found in buffer.")))
+ (if-let ((command-or-compile
+ (cond ((string-match "\*Dtache Shell Command" (buffer-name)) t)
+ ((string-match "\*dtache-compilation" (buffer-name)) t)
+ (t nil))))
+ ;; `dtache-shell-command' or `dtache-compile'
+ (let ((kill-buffer-query-functions nil))
+ (when-let ((process (get-buffer-process (current-buffer))))
+ (comint-simple-send process dtache--dtach-detach-character))
+ (setq dtache--buffer-session nil)
+ (kill-buffer-and-window)
+ (message "[detached]"))
+ (if (dtache--session-active-p dtache--buffer-session)
+ ;; `dtache-eshell'
+ (if-let ((process (and (eq major-mode 'eshell-mode)
+ (dtache-eshell-get-dtach-process))))
+ (progn
+ (setq dtache--buffer-session nil)
+ (process-send-string process dtache--dtach-detach-character))
+ ;; `dtache-shell'
+ (let ((process (get-buffer-process (current-buffer))))
+ (comint-simple-send process dtache--dtach-detach-character)
+ (setq dtache--buffer-session nil)))
+ (message "No active dtache-session found in buffer.")))
+ (message "No dtache-session found in buffer.")))
;;;###autoload
(defun dtache-quit-tail-output ()
- [elpa] externals/dtache 8769db2acb 051/158: Fix error in dtache-shell-attach, (continued)
- [elpa] externals/dtache 8769db2acb 051/158: Fix error in dtache-shell-attach, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache a36e89486f 055/158: Add package dtache-eshell, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache eab014faad 050/158: Version 0.2, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 9a2f4a4d43 057/158: Introduce caching variable for candidates, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 02b93a3778 060/158: Minor cleanup, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache d693d4c386 065/158: Update README with links to blog posts, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 69b001d0e5 069/158: Make eshell-preoutput-filter-functions local, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache be23732c84 079/158: Update documentation in README, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 2e5a097da4 080/158: Implement dtache-compile-open, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache c09328ca1e 081/158: Add actions to a session, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 82e5859d5a 098/158: Improve dtache-detach-session,
ELPA Syncer <=
- [elpa] externals/dtache f73aa7ef98 089/158: Cleanup dtache-shell, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 71966f0d2f 099/158: Add run as an action property, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 5831137cf7 101/158: Rename dtache-initialize to dtache-setup, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 9746f4713c 106/158: Rename session-directory to log-directory, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache c6aece77d2 113/158: Enhance dtache-detach-dwim command, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache bf71be0eae 118/158: Change output-size to log-size, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache f77c57f608 120/158: Update duration part 2, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache c8a99aed35 123/158: Add version to the dtache database, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 4fa1c9e8a2 134/158: Simplify call to dtache--dtach-arg, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 3942dc6326 135/158: Remove unnecessary checks for dtache-session-mode, ELPA Syncer, 2022/01/19