Function: last-completion
last-completion is an interactive and byte-compiled function defined
in simple.el.gz.
Signature
(last-completion)
Documentation
Move to the last item in the completions buffer.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun last-completion ()
"Move to the last item in the completions buffer."
(interactive)
;; Move to the last item in horizontal or one-column format.
(goto-char (previous-single-property-change
(point-max) 'mouse-face nil (point-min)))
;; Move to the start of the item.
(unless (get-text-property (point) 'mouse-face)
(when-let* ((pos (previous-single-property-change (point) 'mouse-face)))
(goto-char pos)))
;; In vertical format the last item is in the last column even if its
;; line number is less than that of the last item in earlier columns.
(when (eq completions-format 'vertical)
(let ((pt (point))
(col (current-column))
(last-col (progn
(first-completion)
(goto-char (pos-eol))
(goto-char (previous-single-property-change
(point) 'mouse-face))
(current-column))))
(if (zerop last-col)
;; If there is only one column of completions, the last
;; completion in vertical format is the same as in horizontal
;; format, so go there now.
(goto-char pt)
;; Otherwise, we set `pt' to the beginning of first item in last
;; column here because if the last column contains only one
;; item, `pt' will not be set below.)
(setq pt (point))
;; If all columns contain the same number of items, `col' (which
;; specifies the column of the last item in horizontal format)
;; equals `last-col', so the test must be with `>=', not `>'.
(when (>= last-col col)
(while (= (current-column) last-col)
(forward-line)
(unless (eobp)
(goto-char (pos-eol))
(move-to-column last-col)
(when (= (current-column) last-col)
(setq pt (point))))))
(goto-char pt)))))