@item @key{RET}
@code{exit-minibuffer}
+@item @key{M-<}
+@code{minibuffer-beginning-of-buffer}
+
@item @kbd{C-g}
@code{abort-recursive-edit}
or @code{minibuffer-local-must-match-map}.
@end defvar
+@defvar minibuffer-beginning-of-buffer-movement
+If non-@code{nil}, the @kbd{M-<} command will move to the end of the
+prompt if point is after the end of the prompt. If point is at or
+before the end of the prompt, move to the start of the buffer. If
+this variable is @code{nil}, the command behaves like
+@code{beginning-of-buffer}.
+@end defvar
+
@node High-Level Completion
@subsection High-Level Completion Functions
** Minibuffer
++++
+*** A new variable, 'minibuffer-beginning-of-buffer-movement', has
+been introduced to allow controlling how the 'M-<' command works in
+the minibuffer. If non-nil, point will move to the end of the prompt
+(if point is after the end of the prompt).
+
---
*** Minibuffer now uses 'minibuffer-message' to display error messages
at the end of the active minibuffer.
(let ((map minibuffer-local-map))
(define-key map "\C-g" 'abort-recursive-edit)
+ (define-key map "\M-<" 'minibuffer-beginning-of-buffer)
(define-key map "\r" 'exit-minibuffer)
(define-key map "\n" 'exit-minibuffer))
`set-visited-file-name'."
:type 'boolean)
+(defcustom minibuffer-beginning-of-buffer-movement nil
+ "Control how the `M-<' command in the minibuffer behaves.
+If non-nil, the command will go to the end of the prompt (if
+point is after the end of the prompt). If nil, it will behave
+like the `beginning-of-buffer' command."
+ :version "27.1"
+ :type 'boolean)
+
;; Not always defined, but only called if next-read-file-uses-dialog-p says so.
(declare-function x-file-dialog "xfns.c"
(prompt dir &optional default-filename mustmatch only-dir-p))
(when file-name-at-point
(insert file-name-at-point))))
+(defun minibuffer-beginning-of-buffer (&optional arg)
+ "Move to the logical beginning of the minibuffer.
+This command behaves like `beginning-of-buffer', but if point is
+after the end of the prompt, move to the end of the prompt.
+Otherwise move to the start of the buffer."
+ (declare (interactive-only "use `(goto-char (point-min))' instead."))
+ (interactive "^P")
+ (when (or (consp arg)
+ (region-active-p))
+ (push-mark))
+ (goto-char (cond
+ ;; We want to go N/10th of the way from the beginning.
+ ((and arg (not (consp arg)))
+ (+ (point-min) 1
+ (/ (* (- (point-max) (point-min))
+ (prefix-numeric-value arg))
+ 10)))
+ ;; Go to the start of the buffer.
+ ((or (null minibuffer-beginning-of-buffer-movement)
+ (<= (point) (minibuffer-prompt-end)))
+ (point-min))
+ ;; Go to the end of the minibuffer.
+ (t
+ (minibuffer-prompt-end))))
+ (when (and arg (not (consp arg)))
+ (forward-line 1)))
+
(provide 'minibuffer)
;;; minibuffer.el ends here