]> code.delx.au - gnu-emacs-elpa/commitdiff
multishell - integrate multishell-name-to-path-history, but -
authorKen Manheimer <ken.manheimer@gmail.com>
Thu, 14 Jan 2016 05:56:41 +0000 (00:56 -0500)
committerKen Manheimer <ken.manheimer@gmail.com>
Thu, 14 Jan 2016 05:56:41 +0000 (00:56 -0500)
i think we need to go with either multishell-buffer-name-history or
multishell-name-to-path-history, not both. Ideally we could just use the
latter.

multishell.el

index c564314e80b40c2464060070bf2f5d3485b6c408..562723d7e36509126908d1250873e7b4e411592d 100644 (file)
@@ -143,16 +143,18 @@ current-buffer behavior.)"
 
 Remove registration for NAME if PATH is nil (but not the empty string)."
   (if path
-      (let* ((it (cons name path))
-             (got (member it multishell-name-to-path-history)))
-        (if got
-            (setcdr it path)
-          (setq multishell-name-to-path-history
-                (cons (cons name path) multishell-name-to-path-history))))
-    (let ((it (assoc name multishell-name-to-path-history)))
-      (if it
-          (setq multishell-name-to-path-history
-                (delete it multishell-name-to-path-history))))))
+      (let* ((got (assoc name multishell-name-to-path-history)))
+        (cond ((or (not path)(string= path ""))
+               ;; Remove entry, if present:
+               (if got
+                   (setq multishell-name-to-path-history
+                         (delete got multishell-name-to-path-history))))
+              (got
+               ;; Replace the path of the existing entry:
+               (setcdr got path))
+              ;; Add a new entry:
+              (t (setq multishell-name-to-path-history
+                (cons (cons name path) multishell-name-to-path-history)))))))
 
 (defun multishell-pop-to-shell (&optional arg)
   "Easily navigate to and within multiple shell buffers, local and remote.
@@ -308,7 +310,8 @@ For example:
     (let ((process (get-buffer-process (current-buffer))))
       (if (and process (equal 'stop (process-status process)))
           (continue-process process)))
-    (multishell-register-name-to-path target-shell-buffer-name use-default-dir)
+    (multishell-register-name-to-path target-shell-buffer-name
+                                      use-default-dir)
     (when (or already-there
              (equal (current-buffer) from-buffer))
       (goto-char (point-max))
@@ -334,25 +337,29 @@ For example:
 
 Return the supplied name bracketed with the asterisks, or specified DEFAULT
 on empty input."
-  (let* ((candidates
+  (let* ((ntph multishell-name-to-path-history)
+         (candidates
           (append
            (remq nil
                  (mapcar (lambda (buffer)
                            (let* ((name (buffer-name buffer))
-                                  (ntph multishell-name-to-path-history)
-                                  (path (cdr (assoc name ntph))))
+                                  (already (assoc name ntph)))
                              (when (with-current-buffer buffer
-                                   (derived-mode-p 'shell-mode))
+                                     (derived-mode-p 'shell-mode))
                                ;; Shell mode buffers.
                                (setq name (if (> (length name) 2)
                                               ;; Strip asterisks.
                                               (substring name 1
                                                          (1- (length name)))
                                             name))
-                               (if path
-                                   (concat name path)
+                               (if already
+                                   nil
                                  name))))
-                         (buffer-list)))))
+                         (buffer-list)))
+           (mapcar #'(lambda (assoc)
+                      (concat (multishell-unbracket-asterisks (car assoc))
+                              (cdr assoc)))
+                   multishell-name-to-path-history)))
          (got (completing-read prompt
                                ;; COLLECTION:
                                candidates