bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#3447: suggest minibuffer M-< go to start of text


From: Lars Ingebrigtsen
Subject: bug#3447: suggest minibuffer M-< go to start of text
Date: Tue, 01 Oct 2019 13:58:22 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

> As an opt-in behavior, please.  We can make it the default later, if
> there's enough demand.

I can do that, but after using this for a bit, it just seems like very
natural behaviour, which makes me wonder whether anybody really enjoys
the previous behaviour.  I mean, there's very little of use you can do
before the end of the minibuffer prompt.  The only use case I can see is
if you want to copy the entire buffer contents to the kill ring...
but...  how often is that done?

Perhaps we could just do the change below (calling it out in NEWS) and
see whether anybody complains?  And if they do, we'll introduce the
variable.

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 3fa637f2ac..20be32f307 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2233,6 +2233,7 @@ completion-help-at-point
 
 (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))
 
@@ -3589,6 +3590,32 @@ minibuffer-insert-file-name-at-point
     (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.
+              ((<= (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

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]