From: Ken Manheimer Date: Sat, 30 Jan 2016 23:15:27 +0000 (-0500) Subject: multishell - more shaking out of initial multishell-list glitches X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/07e631852b8778f3355c7f8ce4bf1fb8f7aad343 multishell - more shaking out of initial multishell-list glitches --- diff --git a/multishell-list.el b/multishell-list.el index f80ed4bc3..63c6f1200 100644 --- a/multishell-list.el +++ b/multishell-list.el @@ -13,26 +13,26 @@ (defun multishell-list-open-pop () "Pop to current entry's shell, and refresh the listing buffer." (interactive) - (let ((start-buffer (current-buffer))) + (let ((list-buffer (current-buffer))) (multishell-pop-to-shell nil (tabulated-list-get-id)) - (with-current-buffer start-buffer + (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 ((start-buffer (current-buffer))) + (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 start-buffer - (revert-buffer))) + (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) - (let ((start-buffer (current-buffer))) - (multishell-pop-to-shell nil (tabulated-list-get-id) 'here)) - (with-current-buffer start-buffer + (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))) + (revert-buffer)))) (defun multishell-list-delete () "Remove current shell entry, and prompt for buffer-removal if present. @@ -40,8 +40,7 @@ \(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))) @@ -51,8 +50,7 @@ supplemented by our own when buffer is inactive.)" (or (comint-check-proc (current-buffer)) (y-or-n-p (format "Kill buffer %s? " name-bracketed))) (kill-buffer name-bracketed))) - (revert-buffer) - (goto-char where))) + (tabulated-list-delete-entry))) (defun multishell-list-edit-entry () "Edit the value of current shell entry." @@ -82,6 +80,10 @@ supplemented by our own when buffer is inactive.)" (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)) @@ -92,9 +94,11 @@ supplemented by our own when buffer is inactive.)" (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))) @@ -123,12 +127,12 @@ supplemented by our own when buffer is inactive.)" \\{multishell-list-mode-map\}" (setq tabulated-list-format [;; (name width sort '(:right-align nil :pad-right nil)) - ("#" 0 compare-strings-as-numbers) - ("! " 1 t) + ("#" 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-sort-key '("#" . t) tabulated-list-entries #'multishell-list-entries) (tabulated-list-init-header)) @@ -142,8 +146,11 @@ supplemented by our own when buffer is inactive.)" (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 "") 'multishell-list-open-here) diff --git a/multishell.el b/multishell.el index 0ea7bfab4..11e54bdae 100644 --- a/multishell.el +++ b/multishell.el @@ -60,15 +60,11 @@ ;; Change Log: ;; ;; * 2016-01-30 1.0.10 Ken Manheimer: -;; - shake out some initial multishell-list glitches: -;; - Delete shell buffer, if present, when deleting an entry. -;; (Offer to) delete shell buffer, if present, when deleting an -;; entry. Rely on the default active-shell deletion prompting -;; for confirmation, supplementing with our own confirmation -;; for inactive shell buffers. +;; - 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 any operation that affects it, and try to -;; preserve stability. (Still needs work.) +;; - Recompute list on most operations that affect the order, and try to +;; preserve stability. (Kludgy solution, needs work.) ;; * 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. @@ -118,6 +114,8 @@ ;; ;; 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 @@ -130,7 +128,6 @@ ;; - 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?