changeset 1811:3e4f8b1da4e9

({next,previous}-complete-history-element): New functions. Bind them to M-n/M-p and next/prior in minibuffer completion maps.
author Roland McGrath <roland@gnu.org>
date Mon, 25 Jan 1993 00:45:01 +0000
parents bf618128d973
children 32248d533b4b
files lisp/simple.el
diffstat 1 files changed, 36 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/simple.el	Fri Jan 22 02:47:12 1993 +0000
+++ b/lisp/simple.el	Mon Jan 25 00:45:01 1993 +0000
@@ -425,19 +425,30 @@
 (defvar minibuffer-history-search-history nil)
 
 (mapcar
- (function (lambda (key-and-command)
-	     (mapcar
-	      (function (lambda (keymap)
-			  (define-key (symbol-value keymap)
-			    (car key-and-command)
-			    (cdr key-and-command))))
-	      '(minibuffer-local-map
-		minibuffer-local-ns-map
-		minibuffer-local-completion-map
-		minibuffer-local-must-match-map
-		read-expression-map))))
- '(("\en" . next-history-element) ([next] . next-history-element)
-   ("\ep" . previous-history-element) ([prior] . previous-history-element)
+ (lambda (key-and-command)
+   (mapcar
+    (lambda (keymap-and-completionp)
+      ;; Arg is (KEYMAP-SYMBOL . COMPLETION-MAP-P).
+      ;; 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)
+	(let ((command (cdr key-and-command)))
+	  (if (consp command)
+	      (if (cdr keymap-and-completionp)
+		  (cdr command)
+		(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)
    ("\es" . next-matching-history-element)))
 
@@ -520,6 +531,18 @@
   "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)))
+				 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)
   "Goto line ARG, counting from line 1 at beginning of buffer."