Mercurial > emacs
comparison lisp/chistory.el @ 9626:e928e72d3342
(repeat-matching-complex-command): Fix check for empty pattern. Simplify.
(default-command-history-filter-garbage): Fix doc string.
(list-command-history-filter, list-command-history-max): Likewise.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 20 Oct 1994 20:01:41 +0000 |
parents | 5c9d9b33f249 |
children | 83f275dcd93a |
comparison
equal
deleted
inserted
replaced
9625:6ee76b67cbfa | 9626:e928e72d3342 |
---|---|
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
23 | 23 |
24 ;;; Commentary: | 24 ;;; Commentary: |
25 | 25 |
26 ;; This really has nothing to do with list-command-history per se, but | 26 ;; This really has nothing to do with list-command-history per se, but |
27 ;; its a nice alternative to C-x ESC (repeat-complex-command) and | 27 ;; its a nice alternative to C-x ESC ESC (repeat-complex-command) and |
28 ;; functions as a lister if given no pattern. It's not important | 28 ;; functions as a lister if given no pattern. It's not important |
29 ;; enough to warrant a file of its own. | 29 ;; enough to warrant a file of its own. |
30 | 30 |
31 ;;; Code: | 31 ;;; Code: |
32 | 32 |
37 a form for evaluation. If PATTERN is empty (or nil), every form in the | 37 a form for evaluation. If PATTERN is empty (or nil), every form in the |
38 command history is offered. The form is placed in the minibuffer for | 38 command history is offered. The form is placed in the minibuffer for |
39 editing and the result is evaluated." | 39 editing and the result is evaluated." |
40 (interactive "sRedo Command (regexp): ") | 40 (interactive "sRedo Command (regexp): ") |
41 (if pattern | 41 (if pattern |
42 (if (equal (setq pattern | 42 (if (string-match "[^ \t]" pattern) |
43 (substring pattern | 43 (setq pattern (substring pattern (match-beginning 0))) |
44 (or (string-match "[ \t]*[^ \t]" pattern) | 44 (setq pattern nil))) |
45 (length pattern)))) | |
46 "") | |
47 (setq pattern nil))) | |
48 (let ((history command-history) | 45 (let ((history command-history) |
49 (temp) | 46 (temp) |
50 (what)) | 47 (what)) |
51 (while (and history (not what)) | 48 (while (and history (not what)) |
52 (setq temp (car history)) | 49 (setq temp (car history)) |
53 (if (and (or (not pattern) (string-match pattern (symbol-name (car temp)))) | 50 (if (and (or (not pattern) (string-match pattern (symbol-name (car temp)))) |
54 (y-or-n-p (format "Redo %s? " (setq temp (prin1-to-string temp))))) | 51 (y-or-n-p (format "Redo %S? " temp))) |
55 (setq what (car history)) | 52 (setq what (car history)) |
56 (setq history (cdr history)))) | 53 (setq history (cdr history)))) |
57 (if (not what) | 54 (if (not what) |
58 (error "Command history exhausted") | 55 (error "Command history exhausted") |
59 ;; Try to remove any useless command history element for this command. | 56 ;; Try to remove any useless command history element for this command. |
63 | 60 |
64 (defvar default-command-history-filter-garbage | 61 (defvar default-command-history-filter-garbage |
65 '(command-history-mode | 62 '(command-history-mode |
66 list-command-history | 63 list-command-history |
67 electric-command-history) | 64 electric-command-history) |
68 "*A list of symbols. If `default-list-command-history-filter' is | 65 "*A list of symbols to be ignored by `default-command-history-filter'. |
69 given a list whose car is an element of this list, then it will return | 66 It that function is given a list whose car is an element of this list, |
70 non-nil (indicating the list should be discarded from the history). | 67 then it will return non-nil (indicating the list should be discarded from |
68 the history). | |
71 Initially, all commands related to the command history are discarded.") | 69 Initially, all commands related to the command history are discarded.") |
72 | 70 |
73 (defvar list-command-history-filter 'default-command-history-filter | 71 (defvar list-command-history-filter 'default-command-history-filter |
74 "If non-nil, should be the name of a function of one argument. | 72 "Predicate to test which commands should be excluded from the history listing. |
73 If non-nil, should be the name of a function of one argument. | |
75 It is passed each element of the command history when | 74 It is passed each element of the command history when |
76 \\[list-command-history] is called. If the filter returns non-nil for | 75 \\[list-command-history] is called. If the filter returns non-nil for |
77 some element, that element is excluded from the history listing. The | 76 some element, that element is excluded from the history listing. The |
78 default filter removes commands associated with the command-history.") | 77 default filter removes commands associated with the command-history.") |
79 | 78 |
82 from the command history." | 81 from the command history." |
83 (or (not (consp frob)) | 82 (or (not (consp frob)) |
84 (memq (car frob) default-command-history-filter-garbage))) | 83 (memq (car frob) default-command-history-filter-garbage))) |
85 | 84 |
86 (defvar list-command-history-max 32 | 85 (defvar list-command-history-max 32 |
87 "*If non-nil, should be a positive number which specifies the maximum | 86 "*If non-nil, maximum length of the listing produced by `list-command-history'.") |
88 length of the Command History listing produced by `list-command-history'.") | |
89 | 87 |
90 ;;;###autoload | 88 ;;;###autoload |
91 (defun list-command-history () | 89 (defun list-command-history () |
92 "List history of commands typed to minibuffer. | 90 "List history of commands typed to minibuffer. |
93 The number of commands listed is controlled by `list-command-history-max'. | 91 The number of commands listed is controlled by `list-command-history-max'. |