aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-10-01 15:01:52 +0200
committerLars Ingebrigtsen2019-10-01 15:01:57 +0200
commit4861328f2a0b95adfb36885db645f5a87ddda7ea (patch)
tree337bee0ef64629992dd92daae8e39abf91c59f13
parentcdc440f0b62362fd38e91e2099919d57fef06436 (diff)
downloademacs-4861328f2a0b95adfb36885db645f5a87ddda7ea.tar.gz
emacs-4861328f2a0b95adfb36885db645f5a87ddda7ea.zip
Allow 'M-<' in the minibuffer to behave more logically
* doc/lispref/minibuf.texi (Completion Commands) (Text from Minibuffer): Document it. * lisp/minibuffer.el (minibuffer-beginning-of-buffer): New command (bug#3447). (map): Bind it.
-rw-r--r--doc/lispref/minibuf.texi11
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/minibuffer.el36
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}
1248or @code{minibuffer-local-must-match-map}. 1251or @code{minibuffer-local-must-match-map}.
1249@end defvar 1252@end defvar
1250 1253
1254@defvar minibuffer-beginning-of-buffer-movement
1255If non-@code{nil}, the @kbd{M-<} command will move to the end of the
1256prompt if point is after the end of the prompt. If point is at or
1257before the end of the prompt, move to the start of the buffer. If
1258this 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
diff --git a/etc/NEWS b/etc/NEWS
index 9a9e25bea90..ec40e5e2abe 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
622been introduced to allow controlling how the 'M-<' command works in
623the 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
622at the end of the active minibuffer. 628at 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.
2535If non-nil, the command will go to the end of the prompt (if
2536point is after the end of the prompt). If nil, it will behave
2537like 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.
3603This command behaves like `beginning-of-buffer', but if point is
3604after the end of the prompt, move to the end of the prompt.
3605Otherwise 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