-(defun multishell-read-bare-shell-buffer-name (prompt default)
- "PROMPT for shell buffer name, sans asterisks. Indicate DEFAULT in prompt.
-
-Return the supplied name, if provided, else return nil."
- (let* ((candidates
- (append
- ;; Plain shell buffer names appended with names from name/path hist:
- (remq nil
- (mapcar (lambda (buffer)
- (let* ((name (multishell-unbracket-asterisks
- (buffer-name buffer))))
- (and (buffer-live-p buffer)
- (with-current-buffer buffer
- ;; Shell mode buffers.
- (and (derived-mode-p 'shell-mode)
- (comint-check-proc (current-buffer))))
- name)))
- (buffer-list)))
- multishell-history))
+(defun multishell-all-entries (&optional active-duplicated)
+ "Return multishell history, with active buffers listed first.
+
+Optional ACTIVE-DUPLICATED will return a copy of
+`multishell-history' with unbracketed names of active buffers,
+sans paths, appended to the list, so they have short and long
+completions."
+ ;; Reorder so active lead present lead historical entries:
+ (let (active-entries active-names present past splat name buffer)
+ (dolist (entry multishell-history)
+ (setq splat (multishell-split-entry entry)
+ name (car splat)
+ buffer (and name (get-buffer (multishell-bracket name))))
+ (if (buffer-live-p buffer)
+ (if (comint-check-proc buffer)
+ (setq active-entries (push entry active-entries)
+ active-names (push name active-names))
+ (setq present (push entry present)))
+ (setq past (push entry past))))
+ ;; Reverse present and past lists
+ (setq multishell-history (append (reverse active-entries)
+ (reverse present)
+ (reverse past)))
+ (if active-duplicated
+ (append multishell-history active-names)
+ multishell-history)))
+
+(defun multishell-read-unbracketed-entry (prompt &optional initial no-record)
+ "PROMPT for shell buffer name, sans asterisks.
+
+Optional INITIAL is preliminary value to be edited.
+
+Optional NO-RECORD prevents changes to `multishell-history'
+across the activity.
+
+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))