branch: externals/detached commit 1ebd92f256adcaada60f9d1f2cf8e27121b4a645 Author: Niklas Eklund <niklas.ekl...@posteo.net> Commit: Niklas Eklund <niklas.ekl...@posteo.net>
Remove support for tailing sessions --- CHANGELOG.org | 1 + README.md | 2 - detached-compile.el | 2 +- detached-init.el | 2 - detached.el | 126 +++++++++++----------------------------------------- 5 files changed, 28 insertions(+), 105 deletions(-) diff --git a/CHANGELOG.org b/CHANGELOG.org index 28bfbf9d74..e7bc268a03 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -3,6 +3,7 @@ #+language: en * Development +- Remove tail command, favor using =attach= or =view=. - Improve support for Emacsen. The PID of all detached Emacsen are registered, this is done to be able to promote one Emacs to primary, which has the responsibility to update the database. - Add command to open a session's log file in =dired=. - Remove the need for =detached-shell-history-file=, the advice is updated to figure out the history file based on the shell program. diff --git a/README.md b/README.md index 62516c8d1f..2a2c67464c 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,6 @@ The package also provides additional commands to interact with a session. |-------------------------------------|---------------------------------------------| | detached-view-session (v) | View a session's output | | detached-attach-session (a) | Attach to a session | -| detached-tail-session (t) | Tail the output of an active session | | detached-diff-session (=) | Diff a session with another session | | detached-compile-session (c) | Open the session output in compilation mode | | detached-rerun-session (r) | Rerun a session | @@ -193,7 +192,6 @@ The package provides the following customizable variables. | detached-timer-configuration | Configuration of the timer that runs on remote hosts | | detached-annotation-format | A list of annotations that should be present in completion | | detached-command-format | A configuration for displaying a session command | -| detached-tail-interval | How often `detached.el` should refresh the output when tailing | | detached-nonattachable-commands | A list of commands that should be considered nonattachable | | detached-notification-function | Specifies which function to issue notifications with | | detached-detach-key | Specifies which keybinding to use to detach from a session | diff --git a/detached-compile.el b/detached-compile.el index d5d328cabc..0c737bf6d4 100644 --- a/detached-compile.el +++ b/detached-compile.el @@ -159,7 +159,7 @@ Optionally EDIT-COMMAND." ;;;###autoload (define-derived-mode detached-compilation-mode compilation-mode "Detached Compilation" - "Major mode for tailing `detached' logs." + "Major mode for `detached' compilation." (add-hook 'compilation-filter-hook #'detached-compile--compilation-eof-filter 0 t) (add-hook 'compilation-filter-hook #'detached-compile--compilation-detached-filter 0 t)) diff --git a/detached-init.el b/detached-init.el index 6576c918fc..aa9e3c9ea9 100644 --- a/detached-init.el +++ b/detached-init.el @@ -34,7 +34,6 @@ (declare-function detached-open-session-directory "detached") (declare-function detached-kill-session "detached") (declare-function detached-rerun-session "detached") -(declare-function detached-tail-session "detached") (declare-function detached-view-session "detached") (declare-function detached-copy-session-command "detached") (declare-function detached-copy-session "detached") @@ -82,7 +81,6 @@ (define-key map "f" #'detached-open-session-directory) (define-key map "k" #'detached-kill-session) (define-key map "r" #'detached-rerun-session) - (define-key map "t" #'detached-tail-session) (define-key map "v" #'detached-view-session) (define-key map "w" #'detached-copy-session-command) (define-key map "W" #'detached-copy-session) diff --git a/detached.el b/detached.el index 0c3cede012..f360413bf3 100644 --- a/detached.el +++ b/detached.el @@ -116,16 +116,6 @@ :type 'integer :group 'detached) -(defcustom detached-tail-interval 2 - "Interval in seconds for the update rate when tailing a session." - :type 'integer - :group 'detached) - -(defcustom detached-open-active-session-action 'attach - "How to open an active session, allowed values are `attach' and `tail'." - :type 'symbol - :group 'detached) - (defcustom detached-shell-command-session-action '(:attach detached-shell-command-attach-session :view detached-view-dwim @@ -331,10 +321,7 @@ Optionally SUPPRESS-OUTPUT if prefix-argument is provided." (list (detached-completing-read (detached-get-sessions)))) (when (detached-valid-session session) (if (eq 'active (detached--session-state session)) - (pcase detached-open-active-session-action - ('attach (detached-attach-session session)) - ('tail (detached-tail-session session)) - (_ (message "`detached-open-active-session-action' has an incorrect value"))) + (detached-attach-session session) (if-let ((view-fun (plist-get (detached--session-action session) :view))) (funcall view-fun session) (detached-view-dwim session))))) @@ -476,23 +463,6 @@ Optionally DELETE the session if prefix-argument is provided." (pop-to-buffer buffer-name)) (message "Detached can't find file: %s" file-path))))) -;;;###autoload -(defun detached-tail-session (session) - "Tail the SESSION." - (interactive - (list (detached-completing-read (detached-get-sessions)))) - (when (detached-valid-session session) - (if (eq 'active (detached--determine-session-state session)) - (let* ((file-path - (detached--session-file session 'log)) - (tramp-verbose 1)) - (when (file-exists-p file-path) - (find-file-other-window file-path) - (setq detached--buffer-session session) - (detached-tail-mode) - (goto-char (point-max)))) - (detached-view-session session)))) - ;;;###autoload (defun detached-diff-session (session1 session2) "Diff SESSION1 with SESSION2." @@ -540,33 +510,30 @@ active session. For sessions created with `detached-compile' or `detached-shell-command', the command will also kill the window." (interactive) (if (detached-session-p detached--buffer-session) - (if (eq major-mode 'detached-tail-mode) - (detached-quit-tail-session) - (if-let ((command-or-compile - (cond ((string-match detached--shell-command-buffer (buffer-name)) t) - ((string-match "\*detached-compilation" (buffer-name)) t) - ((eq major-mode 'detached-log-mode) t) - ((eq major-mode 'detached-tail-mode) t) - (t nil)))) - ;; `detached-shell-command' or `detached-compile' - (let ((kill-buffer-query-functions nil)) - (when-let ((process (get-buffer-process (current-buffer)))) - (comint-simple-send process detached--dtach-detach-character) - (message "[detached]")) - (setq detached--buffer-session nil) - (kill-buffer-and-window)) - (if (eq 'active (detached--determine-session-state detached--buffer-session)) - ;; `detached-eshell' - (if-let ((process (and (eq major-mode 'eshell-mode) - (detached-eshell-get-dtach-process)))) - (progn - (setq detached--buffer-session nil) - (process-send-string process detached--dtach-detach-character)) - ;; `detached-shell' - (let ((process (get-buffer-process (current-buffer)))) - (comint-simple-send process detached--dtach-detach-character) - (setq detached--buffer-session nil))) - (message "No active detached-session found in buffer.")))) + (if-let ((command-or-compile + (cond ((string-match detached--shell-command-buffer (buffer-name)) t) + ((string-match "\*detached-compilation" (buffer-name)) t) + ((eq major-mode 'detached-log-mode) t) + (t nil)))) + ;; `detached-shell-command' or `detached-compile' + (let ((kill-buffer-query-functions nil)) + (when-let ((process (get-buffer-process (current-buffer)))) + (comint-simple-send process detached--dtach-detach-character) + (message "[detached]")) + (setq detached--buffer-session nil) + (kill-buffer-and-window)) + (if (eq 'active (detached--determine-session-state detached--buffer-session)) + ;; `detached-eshell' + (if-let ((process (and (eq major-mode 'eshell-mode) + (detached-eshell-get-dtach-process)))) + (progn + (setq detached--buffer-session nil) + (process-send-string process detached--dtach-detach-character)) + ;; `detached-shell' + (let ((process (get-buffer-process (current-buffer)))) + (comint-simple-send process detached--dtach-detach-character) + (setq detached--buffer-session nil))) + (message "No active detached-session found in buffer."))) (message "No detached-session found in buffer."))) ;;;###autoload @@ -581,18 +548,6 @@ active session. For sessions created with `detached-compile' or (detached-get-sessions))))) (seq-do #'detached--db-remove-entry sessions))) -;;;###autoload -(defun detached-quit-tail-session () - "Quit `detached' tail session. - -The log can have been updated, but that is not done by the user but -rather the tail mode. To avoid a promtp `buffer-modified-p' is set to -nil before closing." - (interactive) - (set-buffer-modified-p nil) - (setq detached--buffer-session nil) - (kill-buffer-and-window)) - ;;;; Functions ;;;;; Session @@ -799,7 +754,7 @@ This function uses the `notifications' library." (detached-session-mode 'attach) (inhibit-message t)) (if (not (detached--session-attachable session)) - (detached-tail-session session) + (detached-view-session session) (cl-letf* (((symbol-function #'set-process-sentinel) #'ignore) (buffer (get-buffer-create detached--shell-command-buffer)) (default-directory (detached--session-working-directory session)) @@ -1232,11 +1187,6 @@ If SESSION is non-attachable fallback to a command that doesn't rely on tee." (let ((remote (file-remote-p default-directory))) `(,(if remote (file-remote-p default-directory 'host) (system-name)) . ,(if remote 'remote 'local)))) -(defun detached--ansi-color-tail () - "Apply `ansi-color' on tail output." - (let ((inhibit-read-only t)) - (ansi-color-apply-on-region auto-revert-tail-pos (point-max)))) - (defun detached--update-session-time (session &optional approximate) "Update SESSION's time property. @@ -1458,30 +1408,6 @@ If event is cased by an update to the `detached' database, re-initialize (ansi-color-apply-on-region (point-min) (point-max))) (read-only-mode t)) -(defvar detached-tail-mode-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd detached-detach-key) #'detached-detach-session) - map) - "Keymap for `detached-tail-mode'.") - -;;;###autoload -(define-derived-mode detached-tail-mode auto-revert-tail-mode "Detached Tail" - "Major mode to tail `detached' logs." - (setq-local auto-revert-interval detached-tail-interval) - (setq-local tramp-verbose 1) - (setq-local auto-revert-remote-files t) - (defvar revert-buffer-preserve-modes) - (setq-local revert-buffer-preserve-modes nil) - (auto-revert-set-timer) - (setq-local auto-revert-verbose nil) - (auto-revert-tail-mode) - (when detached-filter-ansi-sequences - (comint-carriage-motion (point-min) (point-max)) - (set-buffer-modified-p nil) - (add-hook 'after-revert-hook #'detached--ansi-color-tail nil t) - (ansi-color-apply-on-region (point-min) (point-max))) - (read-only-mode t)) - (provide 'detached) ;;; detached.el ends here