diff options
| -rw-r--r-- | doc/lispref/minibuf.texi | 11 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 36 |
3 files changed, 53 insertions, 0 deletions
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index cfea336a9e5..a9d6e83cf85 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi | |||
| @@ -333,6 +333,9 @@ default, it makes the following bindings: | |||
| 333 | @item @key{RET} | 333 | @item @key{RET} |
| 334 | @code{exit-minibuffer} | 334 | @code{exit-minibuffer} |
| 335 | 335 | ||
| 336 | @item @key{M-<} | ||
| 337 | @code{minibuffer-beginning-of-buffer} | ||
| 338 | |||
| 336 | @item @kbd{C-g} | 339 | @item @kbd{C-g} |
| 337 | @code{abort-recursive-edit} | 340 | @code{abort-recursive-edit} |
| 338 | 341 | ||
| @@ -1248,6 +1251,14 @@ combines this keymap with either @code{minibuffer-local-completion-map} | |||
| 1248 | or @code{minibuffer-local-must-match-map}. | 1251 | or @code{minibuffer-local-must-match-map}. |
| 1249 | @end defvar | 1252 | @end defvar |
| 1250 | 1253 | ||
| 1254 | @defvar minibuffer-beginning-of-buffer-movement | ||
| 1255 | If non-@code{nil}, the @kbd{M-<} command will move to the end of the | ||
| 1256 | prompt if point is after the end of the prompt. If point is at or | ||
| 1257 | before the end of the prompt, move to the start of the buffer. If | ||
| 1258 | this variable is @code{nil}, the command behaves like | ||
| 1259 | @code{beginning-of-buffer}. | ||
| 1260 | @end defvar | ||
| 1261 | |||
| 1251 | 1262 | ||
| 1252 | @node High-Level Completion | 1263 | @node High-Level Completion |
| 1253 | @subsection High-Level Completion Functions | 1264 | @subsection High-Level Completion Functions |
| @@ -617,6 +617,12 @@ list the contents of such directories when completing file names. | |||
| 617 | 617 | ||
| 618 | ** Minibuffer | 618 | ** Minibuffer |
| 619 | 619 | ||
| 620 | +++ | ||
| 621 | *** A new variable, 'minibuffer-beginning-of-buffer-movement', has | ||
| 622 | been introduced to allow controlling how the 'M-<' command works in | ||
| 623 | the minibuffer. If non-nil, point will move to the end of the prompt | ||
| 624 | (if point is after the end of the prompt). | ||
| 625 | |||
| 620 | --- | 626 | --- |
| 621 | *** Minibuffer now uses 'minibuffer-message' to display error messages | 627 | *** Minibuffer now uses 'minibuffer-message' to display error messages |
| 622 | at the end of the active minibuffer. | 628 | at the end of the active minibuffer. |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 3fa637f2acd..7227e83f878 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -2233,6 +2233,7 @@ The completion method is determined by `completion-at-point-functions'." | |||
| 2233 | 2233 | ||
| 2234 | (let ((map minibuffer-local-map)) | 2234 | (let ((map minibuffer-local-map)) |
| 2235 | (define-key map "\C-g" 'abort-recursive-edit) | 2235 | (define-key map "\C-g" 'abort-recursive-edit) |
| 2236 | (define-key map "\M-<" 'minibuffer-beginning-of-buffer) | ||
| 2236 | (define-key map "\r" 'exit-minibuffer) | 2237 | (define-key map "\r" 'exit-minibuffer) |
| 2237 | (define-key map "\n" 'exit-minibuffer)) | 2238 | (define-key map "\n" 'exit-minibuffer)) |
| 2238 | 2239 | ||
| @@ -2529,6 +2530,14 @@ such as making the current buffer visit no file in the case of | |||
| 2529 | `set-visited-file-name'." | 2530 | `set-visited-file-name'." |
| 2530 | :type 'boolean) | 2531 | :type 'boolean) |
| 2531 | 2532 | ||
| 2533 | (defcustom minibuffer-beginning-of-buffer-movement nil | ||
| 2534 | "Control how the `M-<' command in the minibuffer behaves. | ||
| 2535 | If non-nil, the command will go to the end of the prompt (if | ||
| 2536 | point is after the end of the prompt). If nil, it will behave | ||
| 2537 | like the `beginning-of-buffer' command." | ||
| 2538 | :version "27.1" | ||
| 2539 | :type 'boolean) | ||
| 2540 | |||
| 2532 | ;; Not always defined, but only called if next-read-file-uses-dialog-p says so. | 2541 | ;; Not always defined, but only called if next-read-file-uses-dialog-p says so. |
| 2533 | (declare-function x-file-dialog "xfns.c" | 2542 | (declare-function x-file-dialog "xfns.c" |
| 2534 | (prompt dir &optional default-filename mustmatch only-dir-p)) | 2543 | (prompt dir &optional default-filename mustmatch only-dir-p)) |
| @@ -3589,6 +3598,33 @@ See `completing-read' for the meaning of the arguments." | |||
| 3589 | (when file-name-at-point | 3598 | (when file-name-at-point |
| 3590 | (insert file-name-at-point)))) | 3599 | (insert file-name-at-point)))) |
| 3591 | 3600 | ||
| 3601 | (defun minibuffer-beginning-of-buffer (&optional arg) | ||
| 3602 | "Move to the logical beginning of the minibuffer. | ||
| 3603 | This command behaves like `beginning-of-buffer', but if point is | ||
| 3604 | after the end of the prompt, move to the end of the prompt. | ||
| 3605 | Otherwise move to the start of the buffer." | ||
| 3606 | (declare (interactive-only "use `(goto-char (point-min))' instead.")) | ||
| 3607 | (interactive "^P") | ||
| 3608 | (when (or (consp arg) | ||
| 3609 | (region-active-p)) | ||
| 3610 | (push-mark)) | ||
| 3611 | (goto-char (cond | ||
| 3612 | ;; We want to go N/10th of the way from the beginning. | ||
| 3613 | ((and arg (not (consp arg))) | ||
| 3614 | (+ (point-min) 1 | ||
| 3615 | (/ (* (- (point-max) (point-min)) | ||
| 3616 | (prefix-numeric-value arg)) | ||
| 3617 | 10))) | ||
| 3618 | ;; Go to the start of the buffer. | ||
| 3619 | ((or (null minibuffer-beginning-of-buffer-movement) | ||
| 3620 | (<= (point) (minibuffer-prompt-end))) | ||
| 3621 | (point-min)) | ||
| 3622 | ;; Go to the end of the minibuffer. | ||
| 3623 | (t | ||
| 3624 | (minibuffer-prompt-end)))) | ||
| 3625 | (when (and arg (not (consp arg))) | ||
| 3626 | (forward-line 1))) | ||
| 3627 | |||
| 3592 | (provide 'minibuffer) | 3628 | (provide 'minibuffer) |
| 3593 | 3629 | ||
| 3594 | ;;; minibuffer.el ends here | 3630 | ;;; minibuffer.el ends here |