branch: externals/dtache commit f34f5b8a244fbe9d8c52a693705a0c62a04e4183 Author: Niklas Eklund <niklas.ekl...@posteo.net> Commit: Niklas Eklund <niklas.ekl...@posteo.net>
Harmonize function names This patch tries to harmonize the function names. It renames some of the commands so that they are easier to grasp and more similar to their non-dtache counterparts. --- CHANELOG.org | 3 +- README.org | 22 ++++---- documentation/demo_v02.org | 2 +- dtache-eshell.el | 2 +- dtache-shell.el | 2 +- dtache.el | 126 +++++++++++++++++++++++++++++---------------- 6 files changed, 98 insertions(+), 59 deletions(-) diff --git a/CHANELOG.org b/CHANELOG.org index 84f2fe0fdb..f34c0223c0 100644 --- a/CHANELOG.org +++ b/CHANELOG.org @@ -4,8 +4,9 @@ * Development +- The commands for launching sessions are now renamed to resemble the non dtache commands. The commands are =dtache-shell-command=, =dtache-shell-send-input=, =dtache-eshell-send-input=, =dtache-compile=. - Add action value to a session. This value is set to dtache-session-action which is a property list optionally specifying attach, view and run properties. These properties are then used in dwim commands to improve their functionality. -- Add a generic detach command, =dtache-detach-dwim=. This command is supposed to be used to detach from sessions in all supported modes. +- Add a generic detach command, =dtache-detach=. 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 5e1111904b..810df0f641 100644 --- a/README.org +++ b/README.org @@ -60,7 +60,7 @@ A minimal configuration for =dtache=. :hook (after-init . dtache-setup) :bind (([remap async-shell-command] . dtache-shell-command) :map dtache-shell-mode-map - ("C-c C-q" . dtache-detach-dwim))) + ("C-c C-q" . dtache-detach))) #+end_src * Commands @@ -71,14 +71,14 @@ There are tree different ways to create a dtache session. | Function | Description | |--------------------------------+-------------------------------| | =dtache-shell-command= | Called from M-x | -| =dtache-shell-create-session= | Called from inside M-x shell | -| =dtache-eshell-create-session= | Called from inside eshell | +| =dtache-shell-send-input= | Called from inside M-x shell | +| =dtache-eshell-send-input= | Called from inside eshell | | =dtache-compile= | Called from M-x | | =dtache-start-session= | Called from within a function | 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-dwim=. +To detach from a =dtache= session you should use the univeral =dtache-detach=. ** Interacting with a session @@ -121,7 +121,7 @@ A =use-package= configuration of the =dtache-shell= extension, which provides th (use-package dtache-shell :hook (after-init . dtache-shell-setup) :bind (:map dtache-shell-mode-map - (("<S-return>" . dtache-shell-create-session) + (("<S-return>" . dtache-shell-send-input) ("<C-return>" . dtache-shell-attach))) :config (setq dtache-shell-history-file "~/.bash_history")) @@ -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-dwim | Detach from a session | +| dtache-detach | Detach from a session | ** Dtache-eshell @@ -143,18 +143,18 @@ A =use-package= configuration of the =dtache-eshell= extension, which provides t (use-package dtache-eshell :hook (after-init . dtache-eshell-setup) :bind (:map dtache-eshell-mode-map - (("<S-return>" . dtache-eshell-create-session) + (("<S-return>" . dtache-eshell-send-input) ("<C-return>" . dtache-eshell-attach) - ("C-c C-q" . dtache-detach-dwim)))) + ("C-c C-q" . dtache-detach)))) #+end_src A minor mode named =dtache-eshell-mode= is provided, and will be enabled in =eshell=. The commands that are implemented are: | Command | Description | |------------------------------+-----------------------| -| dtache-eshell-create-session | Create a session | +| dtache-eshell-send-input | Create a session | | dtache-eshell-attach | Attach to a session | -| dtache-detach-dwim | Detach from a session | +| dtache-detach | 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-dwim))) + ("C-c C-q" . dtache-detach))) #+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/documentation/demo_v02.org b/documentation/demo_v02.org index 8241b48d36..87615c13aa 100644 --- a/documentation/demo_v02.org +++ b/documentation/demo_v02.org @@ -122,7 +122,7 @@ The package adds support for integration with =M-x shell=. :hook (after-init . dtache-shell-setup) :general (:keymaps 'dtache-shell-mode-map - "<S-return>" #'dtache-shell-create-session + "<S-return>" #'dtache-shell-send-input "<C-return>" #'dtache-shell-attach) :config (setq dtache-shell-history-file "~/.bash_history")) diff --git a/dtache-eshell.el b/dtache-eshell.el index 662e7fa0bf..20d7c7294e 100644 --- a/dtache-eshell.el +++ b/dtache-eshell.el @@ -62,7 +62,7 @@ ;;;; Commands ;;;###autoload -(defun dtache-eshell-create-session (&optional detach) +(defun dtache-eshell-send-input (&optional detach) "Create a session and attach to it. If prefix-argument directly DETACH from the session." diff --git a/dtache-shell.el b/dtache-shell.el index a226a8895e..e8278602ad 100644 --- a/dtache-shell.el +++ b/dtache-shell.el @@ -56,7 +56,7 @@ ;;;; Commands ;;;###autoload -(defun dtache-shell-create-session (&optional detach) +(defun dtache-shell-send-input (&optional detach) "Create a session and attach to it unless DETACH." (interactive "P") (let* ((dtache-session-origin 'shell) diff --git a/dtache.el b/dtache.el index 84f0944b95..a531e9884b 100644 --- a/dtache.el +++ b/dtache.el @@ -55,35 +55,38 @@ ;;;;; Customizable -(defvar dtache-session-directory (expand-file-name "dtache" (temporary-file-directory)) - "The directory to store `dtache' sessions.") -(defvar dtache-db-directory user-emacs-directory - "The directory to store `dtache' database.") -(defvar dtache-dtach-program "dtach" - "The name of the `dtach' program.") -(defvar dtache-shell-program "bash" - "Shell to run the dtach command in.") -(defvar dtache-env nil - "The name of the `dtache' program.") -(defvar dtache-max-command-length 90 - "Maximum length of displayed command.") -(defvar dtache-redirect-only-regexps '() - "Regexps for commands that should be run with redirect only.") -(defvar dtache-tail-interval 2 - "Interval in seconds for the update rate when tailing a session.") -(defvar dtache-notification-function #'dtache-inactive-session-notification - "Variable to specify notification function when a session becomes inactive.") -(defvar dtache-compile-hooks nil - "Hooks to run when compiling a session.") -(defvar dtache-metadata-annotators-alist nil - "An alist of annotators for metadata.") -(defvar dtache-timer-configuration '(:seconds 10 :repeat 60 :function run-with-timer) - "A property list defining how often to run a timer.") -(defvar dtache-shell-command-action '(:attach dtache-shell-command-attach :view dtache-view-dwim :run dtache-shell-command) - "Actions for a session created with `dtache-shell-command'.") - -(defvar dtache-annotation-format - `((:width 3 :function dtache--active-str :face dtache-active-face) +(defcustom dtache-session-directory (expand-file-name "dtache" (temporary-file-directory)) + "The directory to store `dtache' sessions." + :type 'string + :group 'dtache) + +(defcustom dtache-db-directory user-emacs-directory + "The directory to store `dtache' database." + :type 'string + :group 'dtache) + +(defcustom dtache-dtach-program "dtach" + "The name of the `dtach' program." + :type 'string + :group 'dtache) + +(defcustom dtache-shell-program "bash" + "Shell to run the dtach command in." + :type 'string + :group 'dtache) + +(defcustom dtache-timer-configuration '(:seconds 10 :repeat 60 :function run-with-timer) + "A property list defining how often to run a timer." + :type 'plist + :group 'dtache) + +(defcustom dtache-env nil + "The name of the `dtache' program." + :type 'string + :group 'dtache) + +(defcustom dtache-annotation-format + '((:width 3 :function dtache--active-str :face dtache-active-face) (:width 3 :function dtache--status-str :face dtache-failure-face) (:width 10 :function dtache--session-host :face dtache-host-face) (:width 40 :function dtache--working-dir-str :face dtache-working-dir-face) @@ -91,7 +94,55 @@ (:width 10 :function dtache--duration-str :face dtache-duration-face) (:width 8 :function dtache--size-str :face dtache-size-face) (:width 12 :function dtache--creation-str :face dtache-creation-face)) - "The format of the annotations.") + "The format of the annotations." + :type '(repeat symbol) + :group 'dtache) + +(defcustom dtache-max-command-length 90 + "Maximum length of displayed command." + :type 'integer + :group 'dtache) + +(defcustom dtache-tail-interval 2 + "Interval in seconds for the update rate when tailing a session." + :type 'integer + :group 'dtache) + +(defcustom dtache-shell-command-action + '(:attach dtache-shell-command-attach + :view dtache-view-dwim + :run dtache-shell-command) + "Actions for a session created with `dtache-shell-command'." + :group 'dtache + :type 'plist) + +(defcustom dtache-redirect-only-regexps nil + "Regexps for commands that should be run with redirect only." + :type '(repeat (regexp :format "%v")) + :group 'dtache) + +(defcustom dtache-notification-function #'dtache-inactive-session-notification + "Variable to specify notification function when a session becomes inactive." + :type 'function + :group 'dtache) + +;;;;; Public + +(defvar dtache-enabled nil) +(defvar dtache-session-mode nil + "Mode of operation for session. +Valid values are: create, new and attach") +(defvar dtache-session-origin nil + "Variable to specify the origin of the session.") +(defvar dtache-session-action nil + "A property list of actions for a session.") +(defvar dtache-shell-command-history nil + "History of commands run with `dtache-shell-command'.") + +(defvar dtache-compile-hooks nil + "Hooks to run when compiling a session.") +(defvar dtache-metadata-annotators-alist nil + "An alist of annotators for metadata.") (defvar dtache-action-map (let ((map (make-sparse-keymap))) @@ -107,19 +158,6 @@ (define-key map "=" #'dtache-diff-session) map)) -;;;;; Internal - -(defvar dtache-enabled nil) -(defvar dtache-session-mode nil - "Mode of operation for session. -Valid values are: create, new and attach") -(defvar dtache-session-origin nil - "Variable to specify the origin of the session.") -(defvar dtache-session-action nil - "A property list of actions for a session.") -(defvar dtache-shell-command-history nil - "History of commands run with `dtache-shell-command'.") - ;;;;; Faces (defgroup dtache-faces nil @@ -379,7 +417,7 @@ Optionally SUPPRESS-OUTPUT." (ediff-buffers buffer1 buffer2)))) ;;;###autoload -(defun dtache-detach-dwim () +(defun dtache-detach () "Detach from current session. This command is only activated if `dtache--buffer-session' is set and