branch: master commit 2d1062d1876e4413b95d003720fee25df77e5975 Merge: 19862ff 0bb7575 Author: Ken Manheimer <ken.manhei...@gmail.com> Commit: Ken Manheimer <ken.manhei...@gmail.com>
multishell - merge 1.1.1 --- packages/multishell/multishell-list.el | 91 +++++++++++++++++++++++--------- packages/multishell/multishell.el | 20 ++++++- 2 files changed, 83 insertions(+), 28 deletions(-) diff --git a/packages/multishell/multishell-list.el b/packages/multishell/multishell-list.el index ae72f92..df4731e 100644 --- a/packages/multishell/multishell-list.el +++ b/packages/multishell/multishell-list.el @@ -3,27 +3,46 @@ ;; Copyright (C) 2016 Free Software Foundation, Inc. and Ken Manheimer ;; Author: Ken Manheimer <ken.manhei...@gmail.com> -;; Version: 1.0.9 +;; Version: 1.1.1 ;; Created: 2016 -- first public availability ;; Keywords: processes ;; URL: https://github.com/kenmanheimer/EmacsMultishell +;; See multishell.el for commentary, change log, etc. + (require 'tabulated-list) (defun multishell-list-open-pop () "Pop to current entry's shell, and refresh the listing buffer." (interactive) - (multishell-pop-to-shell nil (tabulated-list-get-id))) + (let ((list-buffer (current-buffer))) + (multishell-pop-to-shell nil (tabulated-list-get-id)) + (with-current-buffer list-buffer + (revert-buffer)))) +(defun multishell-list-open-as-default () + "Pop to current entry's shell, and set as the default shell." + (interactive) + (let ((list-buffer (current-buffer))) + (message "%s <==" (multishell-name-from-entry (tabulated-list-get-id))) + (multishell-pop-to-shell '(16) (tabulated-list-get-id)) + (with-current-buffer list-buffer + (revert-buffer)))) (defun multishell-list-open-here () "Switch to current entry's shell buffer." (interactive) - (multishell-pop-to-shell nil (tabulated-list-get-id) 'here)) + (let ((list-buffer (current-buffer))) + (multishell-pop-to-shell nil (tabulated-list-get-id) 'here) + (with-current-buffer list-buffer + ;; In case they use switch-to-buffer or whatever to return. + (revert-buffer)))) (defun multishell-list-delete () - "Remove current environment variable value." + "Remove current shell entry, and prompt for buffer-removal if present. + +\(We depend on intrinsic confirmation prompts for active buffers, +supplemented by our own when buffer is inactive.)" (interactive) - (let* ((where (save-excursion (beginning-of-line) (point))) - (entry (tabulated-list-get-id)) + (let* ((entry (tabulated-list-get-id)) (name (multishell-name-from-entry entry)) (name-bracketed (multishell-bracket name)) (buffer (get-buffer name-bracketed))) @@ -33,10 +52,7 @@ (or (comint-check-proc (current-buffer)) (y-or-n-p (format "Kill buffer %s? " name-bracketed))) (kill-buffer name-bracketed))) - (revert-buffer) - (if (not tabulated-list-sort-key) - (revert-buffer)) - (goto-char where))) + (tabulated-list-delete-entry))) (defun multishell-list-edit-entry () "Edit the value of current shell entry." @@ -48,13 +64,17 @@ (format "Edit shell spec for %s: " name) nil entry)) - (revised-pair (when revised (multishell-split-entry revised)))) - (when revised-pair + (revised-path (and revised (cadr (multishell-split-entry revised)))) + (revised-name (multishell-name-from-entry revised)) + buffer) + (when (not (string= revised entry)) (multishell-delete-history-name name) - (multishell-register-name-to-path (car revised-pair) (cadr revised-pair)) + (when (and (not (string= name revised-name)) + (setq buffer (get-buffer (multishell-bracket name)))) + (with-current-buffer buffer + (rename-buffer (multishell-bracket revised-name)))) + (multishell-register-name-to-path revised-name revised-path) (revert-buffer) - (if (not tabulated-list-sort-key) - (revert-buffer)) (goto-char where)))) (defun multishell-list-placeholder (value default) @@ -62,6 +82,10 @@ (if (or (not value) (string= value "")) default value)) +(defconst multishell-list-active-buffer-flag "+") +(defconst multishell-list-inactive-buffer-flag ".") +(defconst multishell-list-absent-buffer-flag "x") + (defun multishell-list-entries () "Generate multishell name/path entries list for tabulated-list." (let ((recency 0)) @@ -72,9 +96,11 @@ (buffer (and name (get-buffer (multishell-bracket name)))) - (status (cond ((not buffer) "x") - ((comint-check-proc buffer) "+") - (t "."))) + (status (cond ((not buffer) + multishell-list-absent-buffer-flag) + ((comint-check-proc buffer) + multishell-list-active-buffer-flag) + (t multishell-list-inactive-buffer-flag))) (rest (cadr splat)) (dissected (and rest (file-remote-p rest) (tramp-dissect-file-name rest t))) @@ -90,7 +116,7 @@ status name (multishell-list-placeholder hops "-") - (multishell-list-placeholder path ":"))))) + (multishell-list-placeholder path "~"))))) (multishell-all-entries)))) (defun compare-strings-as-numbers (a b) @@ -101,18 +127,33 @@ tabulated-list-mode "Shells" "Major mode for listing current and historically registered shells.. \\{multishell-list-mode-map\}" - (setq tabulated-list-format [("#" 0 compare-strings-as-numbers) - ("! " 1 t) - ("Name" 15 t) - ("Hops" 30 t) - ("Path" 30 t)] - tabulated-list-sort-key nil + (setq tabulated-list-format + [;; (name width sort '(:right-align nil :pad-right nil)) + ("#" 0 compare-strings-as-numbers :pad-right 1) + ("! " 1 t :pad-right 1) + ("Name" 15 t) + ("Hops" 30 t) + ("Path" 30 t)] + tabulated-list-sort-key '("#" . t) tabulated-list-entries #'multishell-list-entries) (tabulated-list-init-header)) +(defvar multishell-list-already-re-reverting nil + "Don't set - internal for `multishell-list-revert-buffer-kludge'.") +(defun multishell-list-revert-buffer-kludge () + "Double revert for kludge workaround of untable sorting." + (if (not multishell-list-already-re-reverting) + (let ((multishell-list-already-re-reverting t)) + (revert-buffer)))) +(add-hook 'tabulated-list-revert-hook 'multishell-list-revert-buffer-kludge) + (define-key multishell-list-mode-map (kbd "d") 'multishell-list-delete) +(define-key multishell-list-mode-map (kbd "\C-k") 'multishell-list-delete) +(define-key multishell-list-mode-map (kbd "k") 'multishell-list-delete) (define-key multishell-list-mode-map (kbd "e") 'multishell-list-edit-entry) (define-key multishell-list-mode-map (kbd "o") 'multishell-list-open-pop) +(define-key multishell-list-mode-map (kbd " ") 'multishell-list-open-pop) +(define-key multishell-list-mode-map (kbd "O") 'multishell-list-open-as-default) (define-key multishell-list-mode-map (kbd "<return>") 'multishell-list-open-here) diff --git a/packages/multishell/multishell.el b/packages/multishell/multishell.el index 7aa4b46..283be37 100644 --- a/packages/multishell/multishell.el +++ b/packages/multishell/multishell.el @@ -3,7 +3,7 @@ ;; Copyright (C) 1999-2016 Free Software Foundation, Inc. and Ken Manheimer ;; Author: Ken Manheimer <ken.manhei...@gmail.com> -;; Version: 1.0.9 +;; Version: 1.1.1 ;; Created: 1999 -- first public availability ;; Keywords: processes ;; URL: https://github.com/kenmanheimer/EmacsMultishell @@ -59,6 +59,13 @@ ;; ;; Change Log: ;; +;; * 2016-01-30 1.1.1 Ken Manheimer: +;; - shake out initial multishell-list glitches: +;; - (Offer to) delete shell buffer, if present, when deleting entry. +;; - Set recency (numeric rank) as initial sort field +;; - Recompute list on most operations that affect the order, and try to +;; preserve stability. (Kludgy solution, needs work.) +;; - Set version to 1.1.1 - multishell-list addition should have been 1.1.0. ;; * 2016-01-30 1.0.9 Ken Manheimer: ;; - Add multishell-list for managing the collection of current and ;; history-registered shells: edit, delete, and switch/pop to entries. @@ -108,13 +115,20 @@ ;; ;; TODO and Known Issues: ;; +;; * Add mouse actions - buttons - to multishell-list entries +;; - see buf-menu.el, eg Buffer-menu-mouse-select +;; * Resolve multishell-list sort glitches: +;; - Fix config so multishell-list-revert-buffer-kludge is not needed +;; - Make multishell-list-edit-entry in-place, so changed entries recency +;; doesn't change. +;; - Fill in kill-buffer prompting gaps, eg if default live-process +;; prompts are inhibited. ;; * Add custom shell launch prep actions ;; - for, eg, port knocking, interface activations ;; - shell commands to execute when shell name or path matches a regexp ;; - list of (regexp, which - name, path, or both, command) ;; * Adapt multishell-list facilities for all-completions ;; - See info on minibuffer-completion-help, display-completion-list -;; - implement markup for mouse selection ;; * Investigate whether we can recognize and provide for failed hops. ;; - Tramp doesn't provide useful reactions for any hop but the first ;; - Might be stuff we can do to detect and convey failures? @@ -129,7 +143,7 @@ (require 'savehist) (require 'multishell-list) -(defvar multishell-version "1.0.9") +(defvar multishell-version "1.1.1") (defun multishell-version (&optional here) "Return string describing the loaded multishell version." (interactive "P")