aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath1993-01-25 00:45:01 +0000
committerRoland McGrath1993-01-25 00:45:01 +0000
commitd0678801de6f32bcf2541e7b78e1ade6d3c3045b (patch)
tree5f6032f518446961c4e7a36eb8b917e66993567d
parentc0ff3fabb8e366a08ecb24a8e3c51a9760640aac (diff)
downloademacs-d0678801de6f32bcf2541e7b78e1ade6d3c3045b.tar.gz
emacs-d0678801de6f32bcf2541e7b78e1ade6d3c3045b.zip
({next,previous}-complete-history-element): New functions.
Bind them to M-n/M-p and next/prior in minibuffer completion maps.
-rw-r--r--lisp/simple.el49
1 files changed, 36 insertions, 13 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 2d8ec3095f9..abd57753245 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -425,19 +425,30 @@ contains expressions rather than strings.")
425(defvar minibuffer-history-search-history nil) 425(defvar minibuffer-history-search-history nil)
426 426
427(mapcar 427(mapcar
428 (function (lambda (key-and-command) 428 (lambda (key-and-command)
429 (mapcar 429 (mapcar
430 (function (lambda (keymap) 430 (lambda (keymap-and-completionp)
431 (define-key (symbol-value keymap) 431 ;; Arg is (KEYMAP-SYMBOL . COMPLETION-MAP-P).
432 (car key-and-command) 432 ;; If the cdr of KEY-AND-COMMAND (the command) is a cons,
433 (cdr key-and-command)))) 433 ;; its car is used if COMPLETION-MAP-P is nil, its cdr if it is t.
434 '(minibuffer-local-map 434 (define-key (symbol-value (car keymap-and-completionp))
435 minibuffer-local-ns-map 435 (car key-and-command)
436 minibuffer-local-completion-map 436 (let ((command (cdr key-and-command)))
437 minibuffer-local-must-match-map 437 (if (consp command)
438 read-expression-map)))) 438 (if (cdr keymap-and-completionp)
439 '(("\en" . next-history-element) ([next] . next-history-element) 439 (cdr command)
440 ("\ep" . previous-history-element) ([prior] . previous-history-element) 440 (car command))
441 command))))
442 '((minibuffer-local-map . nil)
443 (minibuffer-local-ns-map . nil)
444 (minibuffer-local-completion-map . t)
445 (minibuffer-local-must-match-map . t)
446 (read-expression-map . nil))))
447 ;; In completion maps, use the completion-oriented history commands.
448 '(("\en" . (next-history-element . next-complete-history-element))
449 ([next] . (next-history-element . next-complete-history-element))
450 ("\ep" . (previous-history-element . previous-complete-history-element))
451 ([prior] . (previous-history-element . previous-complete-history-element))
441 ("\er" . previous-matching-history-element) 452 ("\er" . previous-matching-history-element)
442 ("\es" . next-matching-history-element))) 453 ("\es" . next-matching-history-element)))
443 454
@@ -520,6 +531,18 @@ If N is negative, find the previous or Nth previous match."
520 "Inserts the previous element of the minibuffer history into the minibuffer." 531 "Inserts the previous element of the minibuffer history into the minibuffer."
521 (interactive "p") 532 (interactive "p")
522 (next-history-element (- n))) 533 (next-history-element (- n)))
534
535(defun next-complete-history-element (n)
536 "\
537Get previous element of history which is a completion of minibuffer contents."
538 (interactive "p")
539 (next-matching-history-element (concat "^" (regexp-quote (buffer-string)))
540 n))
541
542(defun previous-complete-history-element (n)
543 "Get next element of history which is a completion of minibuffer contents."
544 (interactive "p")
545 (next-complete-history-element (- n)))
523 546
524(defun goto-line (arg) 547(defun goto-line (arg)
525 "Goto line ARG, counting from line 1 at beginning of buffer." 548 "Goto line ARG, counting from line 1 at beginning of buffer."