- (goto-char (point-min))
- (re-search-forward (format "^ . \\b%s\\b"
- (regexp-quote new-name)))
- (beginning-of-line))))
+ (multishell-list-goto-item-by-entry new)
+ (when arg
+ (multishell-list-dispatch-selected new-name t)))))
+
+(defun multishell-list-mouse-select (event)
+ "Select the shell whose line is clicked."
+ (interactive "e")
+ (select-window (posn-window (event-end event)))
+ (let ((entry (tabulated-list-get-id (posn-point (event-end event)))))
+ (multishell-list-dispatch-selected entry nil)))
+
+(defun multishell-list-dispatch-selected (entry pop &optional set-primary)
+ "Go to multishell ENTRY, popping to window if POP is non-nil.
+
+Optional arg SET-PRIMARY non-nil sets `multishell-primary-name' to entry.
+
+Provide for concluding minibuffer interaction if we're in completing mode."
+ (let ((set-primary-as-arg (and set-primary '(16))))
+ (if multishell-completing-read
+ ;; In multishell completing-read, arrange to conclude minibuffer input:
+ (throw 'multishell-minibuffer-exit (list entry pop set-primary-as-arg))
+ (multishell-pop-to-shell set-primary-as-arg entry (not pop)))))