unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 3447@debbugs.gnu.org, user42@zip.com.au
Subject: bug#3447: suggest minibuffer M-< go to start of text
Date: Tue, 01 Oct 2019 13:58:22 +0200	[thread overview]
Message-ID: <877e5oad9d.fsf@gnus.org> (raw)
In-Reply-To: <83muemcgh7.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 30 Sep 2019 11:53:40 +0300")

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	other threads:[~2019-10-01 11:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-01 23:42 bug#3447: suggest minibuffer M-< go to start of text Kevin Ryde
2019-09-30  8:23 ` Lars Ingebrigtsen
2019-09-30  8:53   ` Eli Zaretskii
2019-10-01 11:58     ` Lars Ingebrigtsen [this message]
2019-10-01 12:28       ` Eli Zaretskii
2019-10-01 13:02         ` Lars Ingebrigtsen
2019-10-01 13:24           ` Eli Zaretskii
2019-11-12 22:04   ` Juri Linkov
2019-11-13  3:25     ` Lars Ingebrigtsen
2019-11-13 21:16       ` Juri Linkov
2019-11-14 13:44         ` Eli Zaretskii
2019-11-15  7:47           ` Lars Ingebrigtsen
2019-11-15  8:43             ` Eli Zaretskii
2019-11-23 12:51               ` Lars Ingebrigtsen
2019-11-16 20:15             ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877e5oad9d.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=3447@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=user42@zip.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).