]> code.delx.au - gnu-emacs-elpa/commitdiff
multishell - multishell-list "clone"; small edits
authorKen Manheimer <ken.manheimer@gmail.com>
Mon, 1 Feb 2016 06:18:41 +0000 (01:18 -0500)
committerKen Manheimer <ken.manheimer@gmail.com>
Mon, 1 Feb 2016 06:18:41 +0000 (01:18 -0500)
Use "Directory" insetad of "Path" in multishell-list header.

multishell-list-clone-entry makes history even more useful.

multishell-list.el
multishell.el

index f17878c121792105bc9493590b550199a91a3ae4..b4ebe47bc2d371f0e40b97ba3c2c47da4c54d3eb 100644 (file)
@@ -75,6 +75,31 @@ supplemented by our own when buffer is inactive.)"
       (revert-buffer)
       (goto-char where))))
 
       (revert-buffer)
       (goto-char where))))
 
+(defun multishell-list-clone-entry (&optional arg)
+  "Create a new list entry based on editing the current one.
+
+You will be left in the list at the entry, not yet launched.
+
+Providing a universal argument will also open the new shell.
+
+The already existing current entry is left untouched."
+  (interactive "P")
+  (let* ((prototype (tabulated-list-get-id))
+         (name (multishell-name-from-entry prototype))
+         (new (multishell-read-unbracketed-entry
+               (format "Clone new shell spec from %s: " name)
+               prototype
+               'no-record))
+         (new-name (multishell-name-from-entry new))
+         (new-path (cadr (multishell-split-entry new))))
+    (when (not (string= new prototype))
+      (multishell-register-name-to-path new-name new-path)
+      (revert-buffer)
+      (goto-char (point-min))
+      (re-search-forward (format "^ . \\b%s\\b"
+                                 (regexp-quote new-name)))
+      (beginning-of-line))))
+
 (defun multishell-list-placeholder (value default)
   "Return VALUE if non-empty string, else DEFAULT."
   (if (or (not value) (string= value ""))
 (defun multishell-list-placeholder (value default)
   "Return VALUE if non-empty string, else DEFAULT."
   (if (or (not value) (string= value ""))
@@ -85,7 +110,7 @@ supplemented by our own when buffer is inactive.)"
 (defconst multishell-list-absent-buffer-flag "x")
 
 (defun multishell-list-entries ()
 (defconst multishell-list-absent-buffer-flag "x")
 
 (defun multishell-list-entries ()
-  "Generate multishell name/path entries list for tabulated-list."
+  "Generate multishell name/path-spec entries list for tabulated-list."
   (let ((recency 0))
     (mapcar #'(lambda (entry)
                 (setq recency (1+ recency))
   (let ((recency 0))
     (mapcar #'(lambda (entry)
                 (setq recency (1+ recency))
@@ -100,11 +125,11 @@ supplemented by our own when buffer is inactive.)"
                                       multishell-list-active-buffer-flag)
                                      (t multishell-list-inactive-buffer-flag)))
                        (rest (cadr splat))
                                       multishell-list-active-buffer-flag)
                                      (t multishell-list-inactive-buffer-flag)))
                        (rest (cadr splat))
-                       (path (or (file-remote-p rest 'localname)
-                                 rest))
+                       (dir (or (file-remote-p rest 'localname)
+                                rest))
                        (hops (and (file-remote-p rest 'localname)
                                   (substring
                        (hops (and (file-remote-p rest 'localname)
                                   (substring
-                                   rest 0 (- (length rest) (length path))))))
+                                   rest 0 (- (length rest) (length dir))))))
                   (when (not name)
                     (setq name (multishell-name-from-entry entry)))
                   (list entry
                   (when (not name)
                     (setq name (multishell-name-from-entry entry)))
                   (list entry
@@ -112,7 +137,7 @@ supplemented by our own when buffer is inactive.)"
                                 status
                                 name
                                 (multishell-list-placeholder hops "-")
                                 status
                                 name
                                 (multishell-list-placeholder hops "-")
-                                (multishell-list-placeholder path "~")))))
+                                (multishell-list-placeholder dir "~")))))
             (multishell-all-entries))))
 
 (defun compare-strings-as-numbers (a b)
             (multishell-all-entries))))
 
 (defun compare-strings-as-numbers (a b)
@@ -122,6 +147,7 @@ supplemented by our own when buffer is inactive.)"
 
 (defvar multishell-list-mode-map
   (let ((map (make-sparse-keymap)))
 
 (defvar multishell-list-mode-map
   (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "c") 'multishell-list-clone-entry)
     (define-key map (kbd "d") 'multishell-list-delete)
     (define-key map (kbd "\C-k") 'multishell-list-delete)
     (define-key map (kbd "k") 'multishell-list-delete)
     (define-key map (kbd "d") 'multishell-list-delete)
     (define-key map (kbd "\C-k") 'multishell-list-delete)
     (define-key map (kbd "k") 'multishell-list-delete)
@@ -141,7 +167,7 @@ supplemented by our own when buffer is inactive.)"
          ("! " 1 t :pad-right 1)
          ("Name" 15 t)
          ("Hops" 30 t)
          ("! " 1 t :pad-right 1)
          ("Name" 15 t)
          ("Hops" 30 t)
-         ("Path" 30 t)]
+         ("Directory" 30 t)]
         tabulated-list-sort-key '("#" . t)
         tabulated-list-entries #'multishell-list-entries)
   (tabulated-list-init-header))
         tabulated-list-sort-key '("#" . t)
         tabulated-list-entries #'multishell-list-entries)
   (tabulated-list-init-header))
index 5342cfc6a931d9541a9b072327aa88242d81a86b..f746c57570a4cf1d687989d427f567af6f1055ef 100644 (file)
 ;;       no-record option to avoid this when needed.
 ;;   - Implement simple edit-in-place multishell-replace-entry and use in
 ;;     multishell-list-edit-entry.
 ;;       no-record option to avoid this when needed.
 ;;   - Implement simple edit-in-place multishell-replace-entry and use in
 ;;     multishell-list-edit-entry.
-;;   - Remove now (hopefully) unnecessary multishell-list-revert-buffer-kludge.
+;;   - Remove now unnecessary multishell-list-revert-buffer-kludge.
+;;   - Rectify byte compiler offenses, and other fixes - thanks to Stefan
+;;     Monnier for pointing out many of the corrections.
+;;   - Avoid directly calling tramp functions unnecessarily.
 ;; * 2016-01-30 1.1.1 Ken Manheimer:
 ;;   - shake out initial multishell-list glitches:
 ;;     - (Offer to) delete shell buffer, if present, when deleting entry.
 ;; * 2016-01-30 1.1.1 Ken Manheimer:
 ;;   - shake out initial multishell-list glitches:
 ;;     - (Offer to) delete shell buffer, if present, when deleting entry.
@@ -230,13 +233,11 @@ current-window behavior.)"
   "Maintain shell's current directory in its multishell history entry.
 
 When set, the history entry for shells started with explicit
   "Maintain shell's current directory in its multishell history entry.
 
 When set, the history entry for shells started with explicit
-paths will track the shell's current working directory. (Explicit
-paths will not be added to local shells started without one,
-however.)
+paths will track the shell's current working directory.
 
 If `savehist-save-minibuffer-history' is enabled, the current
 
 If `savehist-save-minibuffer-history' is enabled, the current
-working directory of shells \(that were started with an explicit
-path) will be conveyed between emacs sessions."
+working directory of shells will be conveyed between emacs
+sessions."
  :type 'boolean)
 
 (defvar multishell-history nil
  :type 'boolean)
 
 (defvar multishell-history nil