]> code.delx.au - gnu-emacs-elpa/commitdiff
multishell - more shaking out of initial multishell-list glitches
authorKen Manheimer <ken.manheimer@gmail.com>
Sat, 30 Jan 2016 23:15:27 +0000 (18:15 -0500)
committerKen Manheimer <ken.manheimer@gmail.com>
Sat, 30 Jan 2016 23:15:27 +0000 (18:15 -0500)
multishell-list.el
multishell.el

index f80ed4bc39398b46f66e7358cc96965ca4843d40..63c6f120065313341073e4ec9b54dd5ddbca3912 100644 (file)
 (defun multishell-list-open-pop ()
   "Pop to current entry's shell, and refresh the listing buffer."
   (interactive)
 (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))
     (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)
       (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)))
     (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)
 (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.
       ;; 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.
 
 (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)
 \(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)))
          (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)))
            (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."
 
 (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))
   (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))
 (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))))
                        (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)))
                        (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))
 \\{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)]
          ("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))
 
         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)
 (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 "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)
 (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)
index 0ea7bfab4a34818c3229bc5e77ba37b75ee4c331..11e54bdae8192c3640da126416c083d30ea680a0 100644 (file)
 ;; Change Log:
 ;;
 ;; * 2016-01-30 1.0.10 Ken Manheimer:
 ;; 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
 ;;     - 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.
 ;; * 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.
 ;;
 ;; TODO and Known Issues:
 ;;
 ;;
 ;; 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
 ;; * 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
 ;;   - 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
 ;;   - 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?
 ;; * 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?