[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dtache 182ab7ccc6 064/158: Add integration with consult
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dtache 182ab7ccc6 064/158: Add integration with consult |
Date: |
Wed, 19 Jan 2022 18:57:58 -0500 (EST) |
branch: externals/dtache
commit 182ab7ccc6807879add58ab8b336e62087fcb967
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Add integration with consult
This patch adds the dtache-consult.el library which provides the
integration with consult. The package implements a command
dtache-consult-session which is supposed to be used as a replacement
for dtache-open-session.
The package also implements different session sources which the users
can use to narrow the list of sessions with.
---
CHANELOG.org | 1 +
README.org | 25 ++++++--
dtache-consult.el | 183 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
dtache.el | 6 +-
4 files changed, 210 insertions(+), 5 deletions(-)
diff --git a/CHANELOG.org b/CHANELOG.org
index 679db88233..357527d8e6 100644
--- a/CHANELOG.org
+++ b/CHANELOG.org
@@ -4,6 +4,7 @@
* Development
+- Add integration with the =consult= package through =dtache-consult.el=.
- Add support for =eshell= through the =dtache-eshell= package.
- macOS (monitor) support is added to the package.
diff --git a/README.org b/README.org
index 1b57eb930d..fac719e004 100644
--- a/README.org
+++ b/README.org
@@ -154,6 +154,27 @@ These are commands that the package provides and which the
user is expected to b
To detach from a session simply use =C-c C-c=.
+** Consult
+
+A =use-package= configuration of the =dtache-consult= package. This package
provides the integration with the [[https://github.com/minad/consult][consult]]
package.
+
+#+begin_src elisp
+ (use-package dtache-consult
+ :commands dtache-consult-session)
+#+end_src
+
+This package provides the =dtache-consult-session= command which is a
replacement for =dtache-open-session=. The difference is that the consult
command provides multiple session sources, which is defined in the
=dtache-consult-sources= variable. Users can customize which sources to use, as
well as use individual sources in other =consult= commands, such as
=consult-buffer=. The users can also narrow the list of sessions by entering a
key. The list of supported keys are:
+
+| Type | Key |
+|-----------------------+-----|
+| Active sessions | a |
+| Inactive sessions | i |
+| Successful sessions | s |
+| Failed sessions | f |
+| Local host sessions | l |
+| Remote host sessions | r |
+| Current host sessions | c |
+
** Embark
The user have the possibility to integrate =dtache= with the package
[[https://github.com/oantolin/embark/][embark]]. The =dtache-action-map= can be
reused for this purpose, so the user doesn't need to bind it to any key.
Instead the user simply adds the following to their =dtache= configuration in
order to get embark actions for =dtache-open-session=.
@@ -163,10 +184,6 @@ The user have the possibility to integrate =dtache= with
the package [[https://g
(add-to-list 'embark-keymap-alist '(dtache . embark-dtache-map))
#+end_src
-** Consult
-
-The [[https://gitlab.com/niklaseklund/consult-dtache][consult-dtache]] package
provides the integration of =dtache=
[[https://github.com/minad/consult][consult]]. The benefit of using this
package is that the user has the ability to narrow the list of sessions based
on different criterion. Since this package has external dependencies it is
provided in its own repository.
-
** Alert
By default =dtache= uses the echo area to notify the user when a session has
finished. An alternative is to utilize the
[[https://github.com/jwiegley/alert][alert]] package to get a system
notification instead.
diff --git a/dtache-consult.el b/dtache-consult.el
new file mode 100644
index 0000000000..8fc33488ae
--- /dev/null
+++ b/dtache-consult.el
@@ -0,0 +1,183 @@
+;;; dtache-consult.el --- Dtache interface using Consult multi sources -*-
lexical-binding: t -*-
+
+;; Copyright (C) 2021-2022 Niklas Eklund
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This package integrates `dtache' with `consult'[1]. The package
+;; provides a command `dtache-consult-session' which provides multiple session
sources.
+;;
+;; [1] https://github.com/minad/consult
+
+;;; Code:
+
+;;;; Requirements
+
+(require 'dtache)
+
+(declare-function consult--multi "consult")
+
+;;;; Variables
+
+(defcustom dtache-consult-sources
+ '(dtache-consult--source-session
+ dtache-consult--source-active-session
+ dtache-consult--source-inactive-session
+ dtache-consult--source-success-session
+ dtache-consult--source-failure-session
+ dtache-consult--source-local-session
+ dtache-consult--source-remote-session
+ dtache-consult--source-current-session)
+ "Sources used by `dtache-consult-session'.
+
+See `consult-multi' for a description of the source values."
+ :type '(repeat symbol)
+ :group 'dtache)
+
+(defvar dtache-consult--source-session
+ `(:category dtache
+ :annotate dtache-session-annotation
+ :action (lambda (x) (dtache-open-session (dtache--decode-session x)))
+ :items
+ ,(lambda ()
+ (seq-map #'car (dtache-session-candidates (dtache-get-sessions)))))
+ "All `dtache' sessions as a source for `consult'.")
+
+(defvar dtache-consult--source-active-session
+ `(:narrow (?a . "Active")
+ :hidden t
+ :category dtache
+ :annotate dtache-session-annotation
+ :action (lambda (x) (dtache-open-session (dtache--decode-session x)))
+ :items
+ ,(lambda ()
+ (mapcar #'car
+ (seq-filter
+ (lambda (x)
+ (dtache--session-active (cdr x)))
+ (dtache-session-candidates (dtache-get-sessions))))))
+ "Active `dtache' sessions as a source for `consult'.")
+
+(defvar dtache-consult--source-inactive-session
+ `(:narrow (?i . "Inactive")
+ :hidden t
+ :category dtache
+ :annotate dtache-session-annotation
+ :action (lambda (x) (dtache-open-session (dtache--decode-session x)))
+ :items
+ ,(lambda ()
+ (mapcar #'car
+ (seq-remove
+ (lambda (x)
+ (dtache--session-active (cdr x)))
+ (dtache-session-candidates (dtache-get-sessions))))))
+ "Inactive `dtache' sessions as a source for `consult'.")
+
+(defvar dtache-consult--source-failure-session
+ `(:narrow (?f . "Failure")
+ :hidden t
+ :category dtache
+ :annotate dtache-session-annotation
+ :action (lambda (x) (dtache-open-session (dtache--decode-session x)))
+ :items
+ ,(lambda ()
+ (mapcar #'car
+ (seq-filter
+ (lambda (x)
+ (eq 'failure (dtache--session-status (cdr x))))
+ (dtache-session-candidates (dtache-get-sessions))))))
+ "Failed `dtache' sessions as a source for `consult'.")
+
+(defvar dtache-consult--source-success-session
+ `(:narrow (?s . "Success")
+ :hidden t
+ :category dtache
+ :annotate dtache-session-annotation
+ :action (lambda (x) (dtache-open-session (dtache--decode-session x)))
+ :items
+ ,(lambda ()
+ (mapcar #'car
+ (seq-filter
+ (lambda (x)
+ (eq 'success (dtache--session-status (cdr x))))
+ (dtache-session-candidates (dtache-get-sessions))))))
+ "Successful `dtache' sessions as a source for `consult'.")
+
+(defvar dtache-consult--source-local-session
+ `(:narrow (?l . "Local Host")
+ :hidden t
+ :category dtache
+ :annotate dtache-session-annotation
+ :action (lambda (x) (dtache-open-session (dtache--decode-session x)))
+ :items
+ ,(lambda ()
+ (let ((host "localhost"))
+ (mapcar #'car
+ (seq-filter
+ (lambda (x)
+ (string= (dtache--session-host (cdr x)) host))
+ (dtache-session-candidates (dtache-get-sessions))))))
+ "Local host `dtache' sessions as a source for `consult'."))
+
+(defvar dtache-consult--source-remote-session
+ `(:narrow (?r . "Remote Host")
+ :hidden t
+ :category dtache
+ :annotate dtache-session-annotation
+ :action (lambda (x) (dtache-open-session (dtache--decode-session x)))
+ :items
+ ,(lambda ()
+ (let ((host "localhost"))
+ (mapcar #'car
+ (seq-remove
+ (lambda (x)
+ (string= (dtache--session-host (cdr x)) host))
+ (dtache-session-candidates (dtache-get-sessions)))))))
+ "Remote host `dtache' sessions as a source for `consult'.")
+
+(defvar dtache-consult--source-current-session
+ `(:narrow (?c . "Current Host")
+ :hidden t
+ :category dtache
+ :annotate dtache-session-annotation
+ :action (lambda (x) (dtache-open-session (dtache--decode-session x)))
+ :items
+ ,(lambda ()
+ (let ((host (dtache--host)))
+ (mapcar #'car (seq-filter
+ (lambda (x)
+ (string= (dtache--session-host (cdr x)) host))
+ (dtache-session-candidates (dtache-get-sessions)))))))
+ "Current host `dtache' sessions as a source for `consult'.")
+
+;;;; Commands
+
+;;;###autoload
+(defun dtache-consult-session ()
+ "Enhanced `dtache-open-session' command."
+ (interactive)
+ (unless (require 'consult nil 'noerror)
+ (error "Install Consult to use dtache-consult"))
+ (consult--multi dtache-consult-sources
+ :prompt "Select session: "
+ :require-match t
+ :sort nil))
+
+(provide 'dtache-consult)
+
+;;; dtache-consult.el ends here
diff --git a/dtache.el b/dtache.el
index 59921bc642..04b255ae2c 100644
--- a/dtache.el
+++ b/dtache.el
@@ -622,7 +622,7 @@ Optionally make the path LOCAL to host."
metadata
(complete-with-action action candidates string
predicate))))
(cand (completing-read "Select session: " collection nil t)))
- (cdr (assoc cand candidates))))
+ (dtache--decode-session cand)))
;;;; Support functions
@@ -742,6 +742,10 @@ Optionally make the path LOCAL to host."
'(:seconds 0.5 :repeat 0.5 :function run-with-idle-timer)))
(dtache--session-timer-monitor session)))
+(defun dtache--decode-session (item)
+ "Return the session assicated with ITEM."
+ (cdr (assoc item dtache--session-candidates)))
+
;;;;; Database
(defun dtache--db-initialize ()
- [elpa] externals/dtache db230154e4 016/158: Merge develop branch into master, (continued)
- [elpa] externals/dtache db230154e4 016/158: Merge develop branch into master, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 2a38a9b538 030/158: Robustify against failures in configuration, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 115de6c1a2 022/158: Add default value for dtache-max-command-length, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 09d378e50a 024/158: Fix read-only problematic, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 4e99fc9daa 049/158: Deprecate dtache-list-sessions, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache cb1762ffc2 052/158: Add presentation about dtache version 0.2, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 5d9c8aa54f 053/158: Add macOS support, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 01a27b4dc2 056/158: Update README with reference to consult-dtache, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache b75af1b9a7 059/158: Update notification setup, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache b47bc3be09 061/158: Update copyright years, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 182ab7ccc6 064/158: Add integration with consult,
ELPA Syncer <=
- [elpa] externals/dtache ea6d8ae426 068/158: Add missing autoloads, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache e2efe466e0 076/158: Improve error handling with dtache-valid-session, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 79f1d905a9 078/158: Add example of how to enhance a command with dtach, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache dae6db33db 083/158: Fix various minor problems, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 52e839ff4a 007/158: Update README with links, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 7e8727f3a2 020/158: Add TODO to investigate unknown inactive sessions, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache b94baaeecd 021/158: Fix bug in setup notification, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 763246bffe 026/158: Remove explicit dependency on dtache-env, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 087e8f4c73 019/158: Update README, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache d574161815 042/158: Simplify buffer handling, ELPA Syncer, 2022/01/19