X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/6cbf0825f805b6c6588e6a600dbd2c6839127d26..7b6604880039245e326921b68b689e52e2b618d1:/multishell.el diff --git a/multishell.el b/multishell.el index 8d19a0510..3043ad7d0 100644 --- a/multishell.el +++ b/multishell.el @@ -1,9 +1,9 @@ -;;; multishell.el --- facilitate multiple local and remote shell buffers +;;; multishell.el --- Easily use multiple shell buffers, local and remote. ;; Copyright (C) 1999-2016 Free Software Foundation, Inc. ;; Author: Ken Manheimer -;; Version: 1.1.3 +;; Version: 1.1.4 ;; Created: 1999 -- first public availability ;; Keywords: processes ;; URL: https://github.com/kenmanheimer/EmacsMultishell @@ -59,6 +59,8 @@ ;; ;; Change Log: ;; +;; * 2016-02-10 1.1.4 Ken Manheimer: +;; - hookup multishell-list as completion help buffer. ;; * 2016-02-09 1.1.3 Ken Manheimer: ;; multishell-list: ;; - add some handy operations, like cloning new entry from existing @@ -267,6 +269,10 @@ one emacs session to be resumed at the next, customize `savehist-additional-variables' to include the `multishell-primary-name'.") +(defvar multishell-completing-read nil + "Internal use, conveying whether or not we're in the midst of a multishell +completing-read.") + ;; Multiple entries happen because completion also adds name to history. (defun multishell-register-name-to-path (name path) "Add or replace entry associating NAME with PATH in `multishell-history'. @@ -428,11 +434,19 @@ customize the savehist group to activate savehist." (let ((token '(token))) (if (window-minibuffer-p) - (throw 'multishell-do-list token) - (if (equal token - (catch 'multishell-do-list - (multishell-pop-to-shell-worker arg name here))) - (multishell-list))))) + (throw 'multishell-minibuffer-exit token) + (let ((got (catch 'multishell-minibuffer-exit + (multishell-pop-to-shell-worker arg name here)))) + ;; Handle catch or plain fall-through - see cond comments for protocol. + (cond + ;; Caught token from recursive invocation in minibuffer: + ((equal token got) (multishell-list)) + ;; Caught specifaction of multishell args, eg from multishell-list: + ((listp got) (multishell-pop-to-shell-worker (nth 2 got) + (nth 0 got) + (nth 1 got))) + ;; Regular fallthrough - just relay the result: + (t got)))))) (defun multishell-pop-to-shell-worker (&optional arg name here) "Do real work of `multishell-pop-to-shell', which see." @@ -616,7 +630,14 @@ Input and completion can include associated path, if any. Return what's provided, if anything, else nil." (let* ((was-multishell-history multishell-history) (candidates (multishell-all-entries 'active-duplicated)) - (got (completing-read prompt + (multishell-completing-read t) + (got + ;; Use `cl-letf' to dynamically bind multishell-list to + ;; display-completion-list, so multishell-list is used when doing + ;; minibuffer-completion-help. + (cl-letf (((symbol-function 'display-completion-list) + #'multishell-list)) + (completing-read prompt ;; COLLECTION: (reverse candidates) ;; PREDICATE: @@ -626,7 +647,7 @@ Return what's provided, if anything, else nil." ;; INITIAL-INPUT initial ;; HIST: - 'multishell-history))) + 'multishell-history)))) (when no-record (setq multishell-history was-multishell-history)) (if (not (string= got "")) @@ -685,7 +706,7 @@ and path nil if none is resolved." (when (and (derived-mode-p 'shell-mode) (file-remote-p path)) ;; Returning to disconnected remote shell - do some tidying. - ;; (Prevents the "Args out of range" failure when reconnecting.) + ;; Prevents an "Args out of range" failure when reconnecting. (tramp-cleanup-connection (tramp-dissect-file-name default-directory 'noexpand) 'keep-debug 'keep-password))