- (with-current-buffer standard-output
- (goto-char (point-max))
- (if (null completions)
- (insert "There are no possible completions of what you have typed.")
-
- (insert "Possible completions are:\n")
- (let ((last (last completions)))
- ;; Get the base-size from the tail of the list.
- (set (make-local-variable 'completion-base-size) (or (cdr last) 0))
- (setcdr last nil)) ;Make completions a properly nil-terminated list.
- (completion--insert-strings completions))))
+ (let ((mainbuf (current-buffer)))
+ (with-current-buffer standard-output
+ (goto-char (point-max))
+ (if (null completions)
+ (insert "There are no possible completions of what you have typed.")
+ (insert "Possible completions are:\n")
+ (let ((last (last completions)))
+ ;; Set base-size from the tail of the list.
+ (set (make-local-variable 'completion-base-size)
+ (or (cdr last)
+ (and (minibufferp mainbuf) 0)))
+ (setcdr last nil)) ; Make completions a properly nil-terminated list.
+ (completion--insert-strings completions)))))