annotate lisp/chistory.el @ 81645:8fb0b13a76a7

(gud-common-init): Call string->strings instead of split-string.
author Nick Roberts <nickrob@snap.net.nz>
date Thu, 28 Jun 2007 01:33:18 +0000
parents e3694f1cb928
children 9355f9b7bbff 95d0cdf160ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1 ;;; chistory.el --- list command history
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
2
74439
ddcbd2c1b70d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68651
diff changeset
3 ;; Copyright (C) 1985, 2001, 2002, 2003, 2004, 2005,
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 74439
diff changeset
4 ;; 2006, 2007 Free Software Foundation, Inc.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
5
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
6 ;; Author: K. Shane Hartman
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
7 ;; Maintainer: FSF
45078
829beb9a6a4b Follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 33941
diff changeset
8 ;; Keywords: convenience
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;; any later version.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 9626
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62721
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62721
diff changeset
25 ;; Boston, MA 02110-1301, USA.
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
27 ;;; Commentary:
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 ;; This really has nothing to do with list-command-history per se, but
9626
e928e72d3342 (repeat-matching-complex-command): Fix check for empty pattern. Simplify.
Karl Heuer <kwzh@gnu.org>
parents: 2452
diff changeset
30 ;; its a nice alternative to C-x ESC ESC (repeat-complex-command) and
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 ;; functions as a lister if given no pattern. It's not important
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 ;; enough to warrant a file of its own.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
34 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
35
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
36 (defgroup chistory nil
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
37 "List command history."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
38 :group 'keyboard)
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
39
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 ;;;###autoload
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 (defun repeat-matching-complex-command (&optional pattern)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 "Edit and re-evaluate complex command with name matching PATTERN.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 Matching occurrences are displayed, most recent first, until you select
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 a form for evaluation. If PATTERN is empty (or nil), every form in the
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 command history is offered. The form is placed in the minibuffer for
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 editing and the result is evaluated."
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 (interactive "sRedo Command (regexp): ")
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 (if pattern
9626
e928e72d3342 (repeat-matching-complex-command): Fix check for empty pattern. Simplify.
Karl Heuer <kwzh@gnu.org>
parents: 2452
diff changeset
49 (if (string-match "[^ \t]" pattern)
e928e72d3342 (repeat-matching-complex-command): Fix check for empty pattern. Simplify.
Karl Heuer <kwzh@gnu.org>
parents: 2452
diff changeset
50 (setq pattern (substring pattern (match-beginning 0)))
e928e72d3342 (repeat-matching-complex-command): Fix check for empty pattern. Simplify.
Karl Heuer <kwzh@gnu.org>
parents: 2452
diff changeset
51 (setq pattern nil)))
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 (let ((history command-history)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 (temp)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 (what))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 (while (and history (not what))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 (setq temp (car history))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 (if (and (or (not pattern) (string-match pattern (symbol-name (car temp))))
9626
e928e72d3342 (repeat-matching-complex-command): Fix check for empty pattern. Simplify.
Karl Heuer <kwzh@gnu.org>
parents: 2452
diff changeset
58 (y-or-n-p (format "Redo %S? " temp)))
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 (setq what (car history))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 (setq history (cdr history))))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 (if (not what)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 (error "Command history exhausted")
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 ;; Try to remove any useless command history element for this command.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 (if (eq (car (car command-history)) 'repeat-matching-complex-command)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 (setq command-history (cdr command-history)))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 (edit-and-eval-command "Redo: " what))))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
68 (defcustom default-command-history-filter-garbage
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 '(command-history-mode
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 list-command-history
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 electric-command-history)
9626
e928e72d3342 (repeat-matching-complex-command): Fix check for empty pattern. Simplify.
Karl Heuer <kwzh@gnu.org>
parents: 2452
diff changeset
72 "*A list of symbols to be ignored by `default-command-history-filter'.
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
73 If that function is given a list whose car is an element of this list,
9626
e928e72d3342 (repeat-matching-complex-command): Fix check for empty pattern. Simplify.
Karl Heuer <kwzh@gnu.org>
parents: 2452
diff changeset
74 then it will return non-nil (indicating the list should be discarded from
e928e72d3342 (repeat-matching-complex-command): Fix check for empty pattern. Simplify.
Karl Heuer <kwzh@gnu.org>
parents: 2452
diff changeset
75 the history).
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
76 Initially, all commands related to the command history are discarded."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
77 :type '(repeat symbol)
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
78 :group 'chistory)
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 (defvar list-command-history-filter 'default-command-history-filter
9626
e928e72d3342 (repeat-matching-complex-command): Fix check for empty pattern. Simplify.
Karl Heuer <kwzh@gnu.org>
parents: 2452
diff changeset
81 "Predicate to test which commands should be excluded from the history listing.
e928e72d3342 (repeat-matching-complex-command): Fix check for empty pattern. Simplify.
Karl Heuer <kwzh@gnu.org>
parents: 2452
diff changeset
82 If non-nil, should be the name of a function of one argument.
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 It is passed each element of the command history when
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 \\[list-command-history] is called. If the filter returns non-nil for
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 some element, that element is excluded from the history listing. The
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 default filter removes commands associated with the command-history.")
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 (defun default-command-history-filter (frob)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 "Filter commands matching `default-command-history-filter-garbage' list
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 from the command history."
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 (or (not (consp frob))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 (memq (car frob) default-command-history-filter-garbage)))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
94 (defcustom list-command-history-max 32
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
95 "*If non-nil, maximum length of the listing produced by `list-command-history'."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
96 :type '(choice integer (const nil))
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
97 :group 'chistory)
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 ;;;###autoload
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 (defun list-command-history ()
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 "List history of commands typed to minibuffer.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 The number of commands listed is controlled by `list-command-history-max'.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 Calls value of `list-command-history-filter' (if non-nil) on each history
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 element to judge if that element should be excluded from the list.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 The buffer is left in Command History mode."
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 (interactive)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 (with-output-to-temp-buffer
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 "*Command History*"
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 (let ((history command-history)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 (buffer-read-only nil)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 (count (or list-command-history-max -1)))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 (while (and (/= count 0) history)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 (if (and (boundp 'list-command-history-filter)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 list-command-history-filter
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 (funcall list-command-history-filter (car history)))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 nil
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 (setq count (1- count))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 (prin1 (car history))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 (terpri))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 (setq history (cdr history))))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 (save-excursion
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 (set-buffer "*Command History*")
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 (goto-char (point-min))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 (if (eobp)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 (error "No command history")
27065
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
127 (command-history-mode)))))
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128
48915
36f7a48a9735 (command-history-map): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents: 48778
diff changeset
129 (defvar command-history-map nil)
36f7a48a9735 (command-history-map): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents: 48778
diff changeset
130 (unless command-history-map
36f7a48a9735 (command-history-map): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents: 48778
diff changeset
131 (setq command-history-map (make-sparse-keymap))
36f7a48a9735 (command-history-map): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents: 48778
diff changeset
132 (set-keymap-parent command-history-map lisp-mode-shared-map)
36f7a48a9735 (command-history-map): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents: 48778
diff changeset
133 (suppress-keymap command-history-map)
36f7a48a9735 (command-history-map): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents: 48778
diff changeset
134 (define-key command-history-map "x" 'command-history-repeat)
36f7a48a9735 (command-history-map): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents: 48778
diff changeset
135 (define-key command-history-map "\n" 'next-line)
36f7a48a9735 (command-history-map): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents: 48778
diff changeset
136 (define-key command-history-map "\r" 'next-line)
36f7a48a9735 (command-history-map): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents: 48778
diff changeset
137 (define-key command-history-map "\177" 'previous-line))
36f7a48a9735 (command-history-map): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents: 48778
diff changeset
138
27065
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
139 (defun command-history-mode ()
48778
d414c281a629 * ibuffer.el (ibuffer-mode): If `show-paren-mode' is enabled,
John Paul Wallington <jpw@pobox.com>
parents: 45078
diff changeset
140 "Major mode for listing and repeating recent commands.
d414c281a629 * ibuffer.el (ibuffer-mode): If `show-paren-mode' is enabled,
John Paul Wallington <jpw@pobox.com>
parents: 45078
diff changeset
141
d414c281a629 * ibuffer.el (ibuffer-mode): If `show-paren-mode' is enabled,
John Paul Wallington <jpw@pobox.com>
parents: 45078
diff changeset
142 Keybindings:
d414c281a629 * ibuffer.el (ibuffer-mode): If `show-paren-mode' is enabled,
John Paul Wallington <jpw@pobox.com>
parents: 45078
diff changeset
143 \\{command-history-map}"
d414c281a629 * ibuffer.el (ibuffer-mode): If `show-paren-mode' is enabled,
John Paul Wallington <jpw@pobox.com>
parents: 45078
diff changeset
144 (interactive)
27065
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
145 (Command-history-setup)
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
146 (setq major-mode 'command-history-mode)
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
147 (setq mode-name "Command History")
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
148 (use-local-map command-history-map)
62721
049538abf38f (command-history-mode): Use run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
149 (run-mode-hooks 'command-history-mode-hook))
27065
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
150
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
151 (defun Command-history-setup ()
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
152 (kill-all-local-variables)
33941
10c41fa2dafe (Command-history-setup): Remove extraneous `keymap'
Gerd Moellmann <gerd@gnu.org>
parents: 32367
diff changeset
153 (use-local-map command-history-map)
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 (lisp-mode-variables nil)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 (set-syntax-table emacs-lisp-mode-syntax-table)
27065
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
156 (setq buffer-read-only t))
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
158 (defcustom command-history-hook nil
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
159 "If non-nil, its value is called on entry to `command-history-mode'."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
160 :type 'hook
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
161 :group 'chistory)
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 (defun command-history-repeat ()
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 "Repeat the command shown on the current line.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 The buffer for that command is the previous current buffer."
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 (interactive)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 (save-excursion
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 (eval (prog1
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 (save-excursion
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 (beginning-of-line)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 (read (current-buffer)))
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 (set-buffer
2452
5c9d9b33f249 (repeat-history-command): Bug fix. Someone forgot a car.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 845
diff changeset
173 (car (cdr (buffer-list))))))))
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 ;;;###autoload
27065
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
176 (defun command-history ()
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
177 "Examine commands from `command-history' in a buffer.
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 The number of commands listed is controlled by `list-command-history-max'.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 The command history is filtered by `list-command-history-filter' if non-nil.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 Use \\<command-history-map>\\[command-history-repeat] to repeat the command on the current line.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 Otherwise much like Emacs-Lisp Mode except that there is no self-insertion
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 and digits provide prefix arguments. Tab does not indent.
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 \\{command-history-map}
27065
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
185
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
186 This command always recompiles the Command History listing
bd4ad2d321a7 (command-history): Renamed from command-history-mode.
Richard M. Stallman <rms@gnu.org>
parents: 21088
diff changeset
187 and runs the normal hook `command-history-hook'."
411
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 (interactive)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 (list-command-history)
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 (pop-to-buffer "*Command History*")
cb75ab565260 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 (run-hooks 'command-history-hook))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 411
diff changeset
192
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 411
diff changeset
193 (provide 'chistory)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 411
diff changeset
194
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 48915
diff changeset
195 ;;; arch-tag: c201a0cd-89f2-4d39-a532-4cb309391dbd
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
196 ;;; chistory.el ends here