summaryrefslogtreecommitdiff
path: root/lisp/simple.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1992-07-26 19:54:20 +0000
committerRichard M. Stallman <rms@gnu.org>1992-07-26 19:54:20 +0000
commite91f80c43a104201ba7b709934523158d519ec5f (patch)
tree803a15e7ff3e4a0377e619aa992602237218095c /lisp/simple.el
parent526148036b5ac6df341680f0de7fafc3022db986 (diff)
downloademacs-e91f80c43a104201ba7b709934523158d519ec5f.tar.gz
*** empty log message ***
Diffstat (limited to 'lisp/simple.el')
-rw-r--r--lisp/simple.el95
1 files changed, 70 insertions, 25 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 0ed38887103..2da71888eda 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -350,27 +350,6 @@ the minibuffer, then read and evaluate the result."
(setq command-history (cons command command-history)))
(eval command)))
-;; (defvar repeat-complex-command nil)
-
-(defvar minibuffer-history nil)
-(defvar minibuffer-history-sexp-flag nil)
-(setq minibuffer-history-variable 'minibuffer-history)
-(setq minibuffer-history-position nil)
-
-(define-key minibuffer-local-map "\en" 'next-history-element)
-(define-key minibuffer-local-ns-map "\en" 'next-history-element)
-(define-key minibuffer-local-ns-map "\en" 'next-history-element)
-(define-key minibuffer-local-completion-map "\en" 'next-history-element)
-(define-key minibuffer-local-completion-map "\en" 'next-history-element)
-(define-key minibuffer-local-must-match-map "\en" 'next-history-element)
-
-(define-key minibuffer-local-map "\ep" 'previous-history-element)
-(define-key minibuffer-local-ns-map "\ep" 'previous-history-element)
-(define-key minibuffer-local-ns-map "\ep" 'previous-history-element)
-(define-key minibuffer-local-completion-map "\ep" 'previous-history-element)
-(define-key minibuffer-local-completion-map "\ep" 'previous-history-element)
-(define-key minibuffer-local-must-match-map "\ep" 'previous-history-element)
-
(defun repeat-complex-command (arg)
"Edit and re-evaluate last complex command, or ARGth from last.
A complex command is one which used the minibuffer.
@@ -384,7 +363,6 @@ to get different commands to edit and resubmit."
(let ((elt (nth (1- arg) command-history))
(minibuffer-history-position arg)
(minibuffer-history-sexp-flag t)
- (repeat-complex-command-flag t)
newcmd)
(if elt
(let ((minibuffer-history-variable ' command-history))
@@ -400,6 +378,75 @@ to get different commands to edit and resubmit."
(setq command-history (cons newcmd command-history)))
(eval newcmd))
(ding))))
+
+(defvar minibuffer-history nil)
+(defvar minibuffer-history-sexp-flag nil)
+(setq minibuffer-history-variable 'minibuffer-history)
+(setq minibuffer-history-position nil)
+
+(define-key minibuffer-local-map "\en" 'next-history-element)
+(define-key minibuffer-local-ns-map "\en" 'next-history-element)
+(define-key minibuffer-local-ns-map "\en" 'next-history-element)
+(define-key minibuffer-local-completion-map "\en" 'next-history-element)
+(define-key minibuffer-local-completion-map "\en" 'next-history-element)
+(define-key minibuffer-local-must-match-map "\en" 'next-history-element)
+
+(define-key minibuffer-local-map "\ep" 'previous-history-element)
+(define-key minibuffer-local-ns-map "\ep" 'previous-history-element)
+(define-key minibuffer-local-ns-map "\ep" 'previous-history-element)
+(define-key minibuffer-local-completion-map "\ep" 'previous-history-element)
+(define-key minibuffer-local-completion-map "\ep" 'previous-history-element)
+(define-key minibuffer-local-must-match-map "\ep" 'previous-history-element)
+
+(define-key minibuffer-local-map "\er" 'previous-matching-history-element)
+(define-key minibuffer-local-ns-map "\er" 'previous-matching-history-element)
+(define-key minibuffer-local-ns-map "\er" 'previous-matching-history-element)
+(define-key minibuffer-local-completion-map "\er"
+ 'previous-matching-history-element)
+(define-key minibuffer-local-completion-map "\er"
+ 'previous-matching-history-element)
+(define-key minibuffer-local-must-match-map "\er"
+ 'previous-matching-history-element)
+
+(define-key minibuffer-local-map "\es" 'next-matching-history-element)
+(define-key minibuffer-local-ns-map "\es" 'next-matching-history-element)
+(define-key minibuffer-local-ns-map "\es" 'next-matching-history-element)
+(define-key minibuffer-local-completion-map "\es"
+ 'next-matching-history-element)
+(define-key minibuffer-local-completion-map "\es"
+ 'next-matching-history-element)
+(define-key minibuffer-local-must-match-map "\es"
+ 'next-matching-history-element)
+
+(put 'previous-matching-history-element 'enable-recursive-minibuffers t)
+(defun previous-matching-history-element (regexp n)
+ (interactive "sPrevious element matching (regexp): \np")
+ (let ((history (symbol-value minibuffer-history-variable))
+ (pos minibuffer-history-position))
+ (while (/= n 0)
+ (setq prevpos pos)
+ (setq pos (min (max 1 (+ pos (if (< n 0) -1 1))) (length history)))
+ (if (= pos prevpos)
+ (error (if (= pos 1)
+ "No following item in minibuffer history"
+ "No preceding item in minibuffer history")))
+ (if (string-match regexp
+ (if minibuffer-history-sexp-flag
+ (prin1-to-string (nth (1- pos) history))
+ (nth (1- pos) history)))
+ (setq n (+ n (if (< n 0) -1 1)))))
+ (setq minibuffer-history-position pos)
+ (erase-buffer)
+ (let ((elt (nth (1- pos) history)))
+ (insert (if minibuffer-history-sexp-flag
+ (prin1-to-string elt)
+ elt)))
+ (goto-char (point-min))))
+
+(put 'next-matching-history-element 'enable-recursive-minibuffers t)
+(defun next-matching-history-element (regexp n)
+ (interactive "sNext element matching (regexp): \np")
+ (previous-matching-history-element regexp (- n)))
(defun next-history-element (n)
"Insert the next element of the minibuffer history into the minibuffer."
@@ -423,10 +470,8 @@ to get different commands to edit and resubmit."
(defun previous-history-element (n)
"Inserts the previous element of `command-history' into the minibuffer."
(interactive "p")
-;; (if repeat-complex-command-flag
(next-history-element (- n)))
-;; (repeat-complex-command 1)))
-
+
(defun goto-line (arg)
"Goto line ARG, counting from line 1 at beginning of buffer."
(interactive "NGoto line: ")