Function: pcomplete-show-completions

pcomplete-show-completions is a byte-compiled function defined in pcomplete.el.gz.

Signature

(pcomplete-show-completions COMPLETIONS)

Documentation

List in help buffer sorted COMPLETIONS.

Typing SPC flushes the help buffer.

Source Code

;; Defined in /usr/src/emacs/lisp/pcomplete.el.gz
(defun pcomplete-show-completions (completions)
  "List in help buffer sorted COMPLETIONS.
Typing SPC flushes the help buffer."
  (when pcomplete-window-restore-timer
    (cancel-timer pcomplete-window-restore-timer)
    (setq pcomplete-window-restore-timer nil))
  (unless pcomplete-last-window-config
    (setq pcomplete-last-window-config (current-window-configuration)))
  (with-output-to-temp-buffer "*Completions*"
    (display-completion-list completions))
  (minibuffer-message "Hit space to flush")
  (let (event)
    (prog1
        (catch 'done
          (while (with-current-buffer "*Completions*"
                   (setq event (read-event)))
            (cond
             ((eq event ?\s)
              (set-window-configuration pcomplete-last-window-config)
              (setq pcomplete-last-window-config nil)
              (throw 'done nil))
             ((or (eq event 'tab)
                  ;; Needed on a terminal
                  (eq event 9))
              (let ((win (or (minibuffer--completions-visible)
                             (display-buffer "*Completions*"
                                             'not-this-window))))
                (with-selected-window win
                  (if (pos-visible-in-window-p (point-max))
                      (goto-char (point-min))
                    (scroll-up))))
              (message ""))
             (t
              (push event unread-command-events)
              (throw 'done nil)))))
      (if (and pcomplete-last-window-config
               pcomplete-restore-window-delay)
          (setq pcomplete-window-restore-timer
                (run-with-timer pcomplete-restore-window-delay nil
                                #'pcomplete-restore-windows))))))