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.") ...@@ -425,19 +425,30 @@ contains expressions rather than strings.")
(defvar minibuffer-history-search-history nil) (defvar minibuffer-history-search-history nil)
(mapcar (mapcar
(function (lambda (key-and-command) (lambda (key-and-command)
(mapcar (mapcar
(function (lambda (keymap) (lambda (keymap-and-completionp)
(define-key (symbol-value keymap) ;; Arg is (KEYMAP-SYMBOL . COMPLETION-MAP-P).
(car key-and-command) ;; If the cdr of KEY-AND-COMMAND (the command) is a cons,
(cdr key-and-command)))) ;; its car is used if COMPLETION-MAP-P is nil, its cdr if it is t.
'(minibuffer-local-map (define-key (symbol-value (car keymap-and-completionp))
minibuffer-local-ns-map (car key-and-command)
minibuffer-local-completion-map (let ((command (cdr key-and-command)))
minibuffer-local-must-match-map (if (consp command)
read-expression-map)))) (if (cdr keymap-and-completionp)
'(("\en" . next-history-element) ([next] . next-history-element) (cdr command)
("\ep" . previous-history-element) ([prior] . previous-history-element) (car command))
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) ("\er" . previous-matching-history-element)
("\es" . next-matching-history-element))) ("\es" . next-matching-history-element)))
...@@ -520,6 +531,18 @@ If N is negative, find the previous or Nth previous match." ...@@ -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." "Inserts the previous element of the minibuffer history into the minibuffer."
(interactive "p") (interactive "p")
(next-history-element (- n))) (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)))
n))
(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) (defun goto-line (arg)
"Goto line ARG, counting from line 1 at beginning of buffer." "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