From 5c0fbcfc8aa6ee13fbd4ea1516f25c804bebcf8c Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 18 Nov 2014 23:33:42 +0200 Subject: [PATCH] Use and keys to move point in the multi-line minibuffer. * lisp/bindings.el (minibuffer-local-map): Rebind [down] from next-history-element to next-line-or-history-element, and [up] from previous-history-element to previous-line-or-history-element. * lisp/simple.el (next-line-or-history-element) (previous-line-or-history-element): New commands. http://lists.gnu.org/archive/html/emacs-devel/2014-11/msg00822.html --- etc/NEWS | 8 ++++++++ lisp/ChangeLog | 10 ++++++++++ lisp/bindings.el | 4 ++-- lisp/simple.el | 30 ++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 86e21c4b8fa..41b93242270 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -133,6 +133,14 @@ Unicode standards. * Changes in Specialized Modes and Packages in Emacs 25.1 +** Minibuffer + +*** You can use and keys to move point in the multi-line +minibuffer just as in an ordinary buffer. Only when point moves over +the bottom/top of the minibuffer it goes to the next/previous history +element. The new commands bound to and in the minibuffer: +`next-line-or-history-element' and `previous-line-or-history-element'. + ** Search and Replace *** Query-replace history is enhanced. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index adf82739b2e..6a6ff73b365 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2014-11-18 Juri Linkov + + * bindings.el (minibuffer-local-map): Rebind [down] from + next-history-element to next-line-or-history-element, and [up] + from previous-history-element to previous-line-or-history-element. + + * simple.el (next-line-or-history-element) + (previous-line-or-history-element): New commands. + http://lists.gnu.org/archive/html/emacs-devel/2014-11/msg00822.html + 2014-11-18 Leo Liu * emacs-lisp/nadvice.el (define-advice): New macro. diff --git a/lisp/bindings.el b/lisp/bindings.el index 110774082e0..789fdf00616 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -839,11 +839,11 @@ if `inhibit-field-text-motion' is non-nil." (let ((map minibuffer-local-map)) (define-key map "\en" 'next-history-element) (define-key map [next] 'next-history-element) - (define-key map [down] 'next-history-element) + (define-key map [down] 'next-line-or-history-element) (define-key map [XF86Forward] 'next-history-element) (define-key map "\ep" 'previous-history-element) (define-key map [prior] 'previous-history-element) - (define-key map [up] 'previous-history-element) + (define-key map [up] 'previous-line-or-history-element) (define-key map [XF86Back] 'previous-history-element) (define-key map "\es" 'next-matching-history-element) (define-key map "\er" 'previous-matching-history-element) diff --git a/lisp/simple.el b/lisp/simple.el index 031970ebb72..fda7040ccb8 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1984,6 +1984,36 @@ With argument N, it uses the Nth previous element." (or (zerop n) (goto-history-element (+ minibuffer-history-position n)))) +(defun next-line-or-history-element (&optional arg) + "Move cursor vertically down ARG lines, or to the next history element. +When point moves over the bottom line of multi-line minibuffer, puts ARGth +next element of the minibuffer history in the minibuffer." + (interactive "^p") + (or arg (setq arg 1)) + (let ((old-point (point))) + (condition-case nil + (next-line arg) + (end-of-buffer + ;; Restore old position since `line-move-visual' moves point to + ;; the end of the line when it fails to go to the next line. + (goto-char old-point) + (next-history-element arg))))) + +(defun previous-line-or-history-element (&optional arg) + "Move cursor vertically up ARG lines, or to the previous history element. +When point moves over the top line of multi-line minibuffer, puts ARGth +previous element of the minibuffer history in the minibuffer." + (interactive "^p") + (or arg (setq arg 1)) + (let ((old-point (point))) + (condition-case nil + (previous-line arg) + (beginning-of-buffer + ;; Restore old position since `line-move-visual' moves point to + ;; the beginning of the line when it fails to go to the previous line. + (goto-char old-point) + (previous-history-element arg))))) + (defun next-complete-history-element (n) "Get next history element which completes the minibuffer before the point. The contents of the minibuffer after the point are deleted, and replaced -- 2.39.5