aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1992-07-26 19:54:20 +0000
committerRichard M. Stallman1992-07-26 19:54:20 +0000
commite91f80c43a104201ba7b709934523158d519ec5f (patch)
tree803a15e7ff3e4a0377e619aa992602237218095c
parent526148036b5ac6df341680f0de7fafc3022db986 (diff)
downloademacs-e91f80c43a104201ba7b709934523158d519ec5f.tar.gz
emacs-e91f80c43a104201ba7b709934523158d519ec5f.zip
*** empty log message ***
-rw-r--r--lisp/mail/rmail.el60
-rw-r--r--lisp/simple.el95
2 files changed, 115 insertions, 40 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index fa0c7db2d1c..ba2a9766411 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -261,6 +261,7 @@ Note: it means the file has no messages in it.\n\^_")))
261 (define-key rmail-mode-map "\e\C-m" 'rmail-retry-failure) 261 (define-key rmail-mode-map "\e\C-m" 'rmail-retry-failure)
262 (define-key rmail-mode-map "c" 'rmail-continue) 262 (define-key rmail-mode-map "c" 'rmail-continue)
263 (define-key rmail-mode-map "f" 'rmail-forward) 263 (define-key rmail-mode-map "f" 'rmail-forward)
264 (define-key rmail-mode-map "\er" 'rmail-search-backwards)
264 (define-key rmail-mode-map "\es" 'rmail-search) 265 (define-key rmail-mode-map "\es" 'rmail-search)
265 (define-key rmail-mode-map "<" 'rmail-first-message) 266 (define-key rmail-mode-map "<" 'rmail-first-message)
266 (define-key rmail-mode-map ">" 'rmail-last-message) 267 (define-key rmail-mode-map ">" 'rmail-last-message)
@@ -1108,11 +1109,11 @@ or forward if N is negative."
1108 (if (>= where (rmail-msgbeg high)) high low))) 1109 (if (>= where (rmail-msgbeg high)) high low)))
1109 1110
1110(defvar rmail-search-last-regexp nil) 1111(defvar rmail-search-last-regexp nil)
1111(defun rmail-search (regexp &optional reversep) 1112(defun rmail-search (regexp &optional n)
1112 "Show message containing next match for REGEXP. 1113 "Show message containing next match for REGEXP.
1113Search in reverse (earlier messages) with non-nil second arg REVERSEP. 1114Prefix argument gives repeat count; negative argument means search
1114Interactively, empty argument means use same regexp used last time, 1115backwards (through earlier messages).
1115and reverse search is specified by a negative numeric arg." 1116Interactively, empty argument means use same regexp used last time."
1116 (interactive 1117 (interactive
1117 (let* ((reversep (< (prefix-numeric-value current-prefix-arg) 0)) 1118 (let* ((reversep (< (prefix-numeric-value current-prefix-arg) 0))
1118 (prompt 1119 (prompt
@@ -1128,7 +1129,9 @@ and reverse search is specified by a negative numeric arg."
1128 (setq rmail-search-last-regexp regexp)) 1129 (setq rmail-search-last-regexp regexp))
1129 ((not rmail-search-last-regexp) 1130 ((not rmail-search-last-regexp)
1130 (error "No previous Rmail search string"))) 1131 (error "No previous Rmail search string")))
1131 (list rmail-search-last-regexp reversep))) 1132 (list rmail-search-last-regexp
1133 (prefix-numeric-value current-prefix-arg))))
1134 (or n (setq n 1))
1132 (message "%sRmail search for %s..." 1135 (message "%sRmail search for %s..."
1133 (if reversep "Reverse " "") 1136 (if reversep "Reverse " "")
1134 regexp) 1137 regexp)
@@ -1137,20 +1140,23 @@ and reverse search is specified by a negative numeric arg."
1137 (omax (point-max)) 1140 (omax (point-max))
1138 (opoint (point)) 1141 (opoint (point))
1139 win 1142 win
1143 (reversep (< n 0))
1140 (msg rmail-current-message)) 1144 (msg rmail-current-message))
1141 (unwind-protect 1145 (unwind-protect
1142 (progn 1146 (progn
1143 (widen) 1147 (widen)
1144 ;; Check messages one by one, advancing message number up or down 1148 (while (/= n 0)
1145 ;; but searching forward through each message. 1149 ;; Check messages one by one, advancing message number up or down
1146 (if reversep 1150 ;; but searching forward through each message.
1147 (while (and (null win) (> msg 1)) 1151 (if reversep
1148 (goto-char (rmail-msgbeg (setq msg (1- msg)))) 1152 (while (and (null win) (> msg 1))
1149 (setq win (re-search-forward 1153 (goto-char (rmail-msgbeg (setq msg (1- msg))))
1150 regexp (rmail-msgend msg) t))) 1154 (setq win (re-search-forward
1151 (while (and (null win) (< msg rmail-total-messages)) 1155 regexp (rmail-msgend msg) t)))
1152 (goto-char (rmail-msgbeg (setq msg (1+ msg)))) 1156 (while (and (null win) (< msg rmail-total-messages))
1153 (setq win (re-search-forward regexp (rmail-msgend msg) t))))) 1157 (goto-char (rmail-msgbeg (setq msg (1+ msg))))
1158 (setq win (re-search-forward regexp (rmail-msgend msg) t))))
1159 (setq n (+ n (if (< n 0) -1 1)))))
1154 (if win 1160 (if win
1155 (progn 1161 (progn
1156 ;; If this is a reverse search and we found a message, 1162 ;; If this is a reverse search and we found a message,
@@ -1171,6 +1177,30 @@ and reverse search is specified by a negative numeric arg."
1171 (ding) 1177 (ding)
1172 (message "Search failed: %s" regexp))))) 1178 (message "Search failed: %s" regexp)))))
1173 1179
1180(defun rmail-search-backwards (regexp &optional n)
1181 "Show message containing previous match for REGEXP.
1182Prefix argument gives repeat count; negative argument means search
1183forward (through later messages).
1184Interactively, empty argument means use same regexp used last time."
1185 (interactive
1186 (let* ((reversep (< (prefix-numeric-value current-prefix-arg) 0))
1187 (prompt
1188 (concat (if reversep "Reverse " "") "Rmail search (regexp): "))
1189 regexp)
1190 (if rmail-search-last-regexp
1191 (setq prompt (concat prompt
1192 "(default "
1193 rmail-search-last-regexp
1194 ") ")))
1195 (setq regexp (read-string prompt))
1196 (cond ((not (equal regexp ""))
1197 (setq rmail-search-last-regexp regexp))
1198 ((not rmail-search-last-regexp)
1199 (error "No previous Rmail search string")))
1200 (list rmail-search-last-regexp
1201 (prefix-numeric-value current-prefix-arg))))
1202 (rmail-search regexp (- (or n -1))))
1203
1174;; Show the first message which has the `unseen' attribute. 1204;; Show the first message which has the `unseen' attribute.
1175(defun rmail-first-unseen-message () 1205(defun rmail-first-unseen-message ()
1176 (let ((current 1) 1206 (let ((current 1)
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."
350 (setq command-history (cons command command-history))) 350 (setq command-history (cons command command-history)))
351 (eval command))) 351 (eval command)))
352 352
353;; (defvar repeat-complex-command nil)
354
355(defvar minibuffer-history nil)
356(defvar minibuffer-history-sexp-flag nil)
357(setq minibuffer-history-variable 'minibuffer-history)
358(setq minibuffer-history-position nil)
359
360(define-key minibuffer-local-map "\en" 'next-history-element)
361(define-key minibuffer-local-ns-map "\en" 'next-history-element)
362(define-key minibuffer-local-ns-map "\en" 'next-history-element)
363(define-key minibuffer-local-completion-map "\en" 'next-history-element)
364(define-key minibuffer-local-completion-map "\en" 'next-history-element)
365(define-key minibuffer-local-must-match-map "\en" 'next-history-element)
366
367(define-key minibuffer-local-map "\ep" 'previous-history-element)
368(define-key minibuffer-local-ns-map "\ep" 'previous-history-element)
369(define-key minibuffer-local-ns-map "\ep" 'previous-history-element)
370(define-key minibuffer-local-completion-map "\ep" 'previous-history-element)
371(define-key minibuffer-local-completion-map "\ep" 'previous-history-element)
372(define-key minibuffer-local-must-match-map "\ep" 'previous-history-element)
373
374(defun repeat-complex-command (arg) 353(defun repeat-complex-command (arg)
375 "Edit and re-evaluate last complex command, or ARGth from last. 354 "Edit and re-evaluate last complex command, or ARGth from last.
376A complex command is one which used the minibuffer. 355A complex command is one which used the minibuffer.
@@ -384,7 +363,6 @@ to get different commands to edit and resubmit."
384 (let ((elt (nth (1- arg) command-history)) 363 (let ((elt (nth (1- arg) command-history))
385 (minibuffer-history-position arg) 364 (minibuffer-history-position arg)
386 (minibuffer-history-sexp-flag t) 365 (minibuffer-history-sexp-flag t)
387 (repeat-complex-command-flag t)
388 newcmd) 366 newcmd)
389 (if elt 367 (if elt
390 (let ((minibuffer-history-variable ' command-history)) 368 (let ((minibuffer-history-variable ' command-history))
@@ -400,6 +378,75 @@ to get different commands to edit and resubmit."
400 (setq command-history (cons newcmd command-history))) 378 (setq command-history (cons newcmd command-history)))
401 (eval newcmd)) 379 (eval newcmd))
402 (ding)))) 380 (ding))))
381
382(defvar minibuffer-history nil)
383(defvar minibuffer-history-sexp-flag nil)
384(setq minibuffer-history-variable 'minibuffer-history)
385(setq minibuffer-history-position nil)
386
387(define-key minibuffer-local-map "\en" 'next-history-element)
388(define-key minibuffer-local-ns-map "\en" 'next-history-element)
389(define-key minibuffer-local-ns-map "\en" 'next-history-element)
390(define-key minibuffer-local-completion-map "\en" 'next-history-element)
391(define-key minibuffer-local-completion-map "\en" 'next-history-element)
392(define-key minibuffer-local-must-match-map "\en" 'next-history-element)
393
394(define-key minibuffer-local-map "\ep" 'previous-history-element)
395(define-key minibuffer-local-ns-map "\ep" 'previous-history-element)
396(define-key minibuffer-local-ns-map "\ep" 'previous-history-element)
397(define-key minibuffer-local-completion-map "\ep" 'previous-history-element)
398(define-key minibuffer-local-completion-map "\ep" 'previous-history-element)
399(define-key minibuffer-local-must-match-map "\ep" 'previous-history-element)
400
401(define-key minibuffer-local-map "\er" 'previous-matching-history-element)
402(define-key minibuffer-local-ns-map "\er" 'previous-matching-history-element)
403(define-key minibuffer-local-ns-map "\er" 'previous-matching-history-element)
404(define-key minibuffer-local-completion-map "\er"
405 'previous-matching-history-element)
406(define-key minibuffer-local-completion-map "\er"
407 'previous-matching-history-element)
408(define-key minibuffer-local-must-match-map "\er"
409 'previous-matching-history-element)
410
411(define-key minibuffer-local-map "\es" 'next-matching-history-element)
412(define-key minibuffer-local-ns-map "\es" 'next-matching-history-element)
413(define-key minibuffer-local-ns-map "\es" 'next-matching-history-element)
414(define-key minibuffer-local-completion-map "\es"
415 'next-matching-history-element)
416(define-key minibuffer-local-completion-map "\es"
417 'next-matching-history-element)
418(define-key minibuffer-local-must-match-map "\es"
419 'next-matching-history-element)
420
421(put 'previous-matching-history-element 'enable-recursive-minibuffers t)
422(defun previous-matching-history-element (regexp n)
423 (interactive "sPrevious element matching (regexp): \np")
424 (let ((history (symbol-value minibuffer-history-variable))
425 (pos minibuffer-history-position))
426 (while (/= n 0)
427 (setq prevpos pos)
428 (setq pos (min (max 1 (+ pos (if (< n 0) -1 1))) (length history)))
429 (if (= pos prevpos)
430 (error (if (= pos 1)
431 "No following item in minibuffer history"
432 "No preceding item in minibuffer history")))
433 (if (string-match regexp
434 (if minibuffer-history-sexp-flag
435 (prin1-to-string (nth (1- pos) history))
436 (nth (1- pos) history)))
437 (setq n (+ n (if (< n 0) -1 1)))))
438 (setq minibuffer-history-position pos)
439 (erase-buffer)
440 (let ((elt (nth (1- pos) history)))
441 (insert (if minibuffer-history-sexp-flag
442 (prin1-to-string elt)
443 elt)))
444 (goto-char (point-min))))
445
446(put 'next-matching-history-element 'enable-recursive-minibuffers t)
447(defun next-matching-history-element (regexp n)
448 (interactive "sNext element matching (regexp): \np")
449 (previous-matching-history-element regexp (- n)))
403 450
404(defun next-history-element (n) 451(defun next-history-element (n)
405 "Insert the next element of the minibuffer history into the minibuffer." 452 "Insert the next element of the minibuffer history into the minibuffer."
@@ -423,10 +470,8 @@ to get different commands to edit and resubmit."
423(defun previous-history-element (n) 470(defun previous-history-element (n)
424 "Inserts the previous element of `command-history' into the minibuffer." 471 "Inserts the previous element of `command-history' into the minibuffer."
425 (interactive "p") 472 (interactive "p")
426;; (if repeat-complex-command-flag
427 (next-history-element (- n))) 473 (next-history-element (- n)))
428;; (repeat-complex-command 1))) 474
429
430(defun goto-line (arg) 475(defun goto-line (arg)
431 "Goto line ARG, counting from line 1 at beginning of buffer." 476 "Goto line ARG, counting from line 1 at beginning of buffer."
432 (interactive "NGoto line: ") 477 (interactive "NGoto line: ")