]> code.delx.au - gnu-emacs-elpa/commitdiff
multishell - merge 1.1.1
authorKen Manheimer <ken.manheimer@gmail.com>
Sat, 30 Jan 2016 23:24:50 +0000 (18:24 -0500)
committerKen Manheimer <ken.manheimer@gmail.com>
Sat, 30 Jan 2016 23:24:50 +0000 (18:24 -0500)
1  2 
packages/multishell/multishell-list.el
packages/multishell/multishell.el

index ae72f9217a205ab4718eb1558d5f6ab79e671b2a,df4731e717408364c33d33f59bedf101c905ee5d..df4731e717408364c33d33f59bedf101c905ee5d
@@@ -3,27 -3,46 +3,46 @@@
  ;; Copyright (C) 2016 Free Software Foundation, Inc. and Ken Manheimer
  
  ;; Author: Ken Manheimer <ken.manheimer@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)))
             (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."
                     (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)
    (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))
                         (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)))
                                  status
                                  name
                                  (multishell-list-placeholder hops "-")
-                                 (multishell-list-placeholder path ":")))))
+                                 (multishell-list-placeholder path "~")))))
              (multishell-all-entries))))
  
  (defun compare-strings-as-numbers (a b)
      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)
  
index 7aa4b462d47d22fec776e81fdbf3b76ef5851fb9,283be374a6b20522af1817781073df2e3f1c24d6..283be374a6b20522af1817781073df2e3f1c24d6
@@@ -3,7 -3,7 +3,7 @@@
  ;; Copyright (C) 1999-2016 Free Software Foundation, Inc. and Ken Manheimer
  
  ;; Author: Ken Manheimer <ken.manheimer@gmail.com>
- ;; Version: 1.0.9
+ ;; Version: 1.1.1
  ;; Created: 1999 -- first public availability
  ;; Keywords: processes
  ;; URL: https://github.com/kenmanheimer/EmacsMultishell
  ;;
  ;; 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.
  ;;
  ;; 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?
  (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")