Commit d0678801 authored by Roland McGrath's avatar Roland McGrath
Browse files

({next,previous}-complete-history-element): New functions.

Bind them to M-n/M-p and next/prior in minibuffer completion maps.
parent c0ff3fab
......@@ -425,19 +425,30 @@ contains expressions rather than strings.")
(defvar minibuffer-history-search-history nil)
(function (lambda (key-and-command)
(lambda (key-and-command)
(function (lambda (keymap)
(define-key (symbol-value keymap)
(lambda (keymap-and-completionp)
;; If the cdr of KEY-AND-COMMAND (the command) is a cons,
;; its car is used if COMPLETION-MAP-P is nil, its cdr if it is t.
(define-key (symbol-value (car keymap-and-completionp))
(car key-and-command)
(cdr key-and-command))))
'(("\en" . next-history-element) ([next] . next-history-element)
("\ep" . previous-history-element) ([prior] . previous-history-element)
(let ((command (cdr key-and-command)))
(if (consp command)
(if (cdr keymap-and-completionp)
(cdr command)
(car command))
'((minibuffer-local-map . nil)
(minibuffer-local-ns-map . nil)
(minibuffer-local-completion-map . t)
(minibuffer-local-must-match-map . t)
(read-expression-map . nil))))
;; In completion maps, use the completion-oriented history commands.
'(("\en" . (next-history-element . next-complete-history-element))
([next] . (next-history-element . next-complete-history-element))
("\ep" . (previous-history-element . previous-complete-history-element))
([prior] . (previous-history-element . previous-complete-history-element))
("\er" . previous-matching-history-element)
("\es" . next-matching-history-element)))
......@@ -520,6 +531,18 @@ If N is negative, find the previous or Nth previous match."
"Inserts the previous element of the minibuffer history into the minibuffer."
(interactive "p")
(next-history-element (- n)))
(defun next-complete-history-element (n)
Get previous element of history which is a completion of minibuffer contents."
(interactive "p")
(next-matching-history-element (concat "^" (regexp-quote (buffer-string)))
(defun previous-complete-history-element (n)
"Get next element of history which is a completion of minibuffer contents."
(interactive "p")
(next-complete-history-element (- n)))
(defun goto-line (arg)
"Goto line ARG, counting from line 1 at beginning of buffer."
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment