diff options
| author | Jim Blandy | 1991-08-27 03:29:52 +0000 |
|---|---|---|
| committer | Jim Blandy | 1991-08-27 03:29:52 +0000 |
| commit | e2fbf49d35a6c6646fd88531eca71634726e50f4 (patch) | |
| tree | 838add015810ac5f8a1566d637ed6efb35ca5a46 | |
| parent | 349a7710a2006a3fd54f179f1535b54769506cc4 (diff) | |
| download | emacs-e2fbf49d35a6c6646fd88531eca71634726e50f4.tar.gz emacs-e2fbf49d35a6c6646fd88531eca71634726e50f4.zip | |
Initial revision
| -rw-r--r-- | lisp/abbrev.el | 289 | ||||
| -rw-r--r-- | lisp/chistory.el | 167 |
2 files changed, 456 insertions, 0 deletions
diff --git a/lisp/abbrev.el b/lisp/abbrev.el new file mode 100644 index 00000000000..9bd311290fb --- /dev/null +++ b/lisp/abbrev.el | |||
| @@ -0,0 +1,289 @@ | |||
| 1 | ;; Abbrev mode commands for Emacs | ||
| 2 | |||
| 3 | ;; Copyright (C) 1985-1991 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software; you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation; either version 1, or (at your option) | ||
| 10 | ;; any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs; see the file COPYING. If not, write to | ||
| 19 | ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | |||
| 21 | |||
| 22 | ;;;###autoload | ||
| 23 | (defconst only-global-abbrevs nil "\ | ||
| 24 | *t means user plans to use global abbrevs only. | ||
| 25 | Makes the commands to define mode-specific abbrevs define global ones instead.") | ||
| 26 | |||
| 27 | (defun abbrev-mode (arg) | ||
| 28 | "Toggle abbrev mode. | ||
| 29 | With arg, turn abbrev mode on iff arg is positive. | ||
| 30 | In abbrev mode, inserting an abbreviation causes it to expand | ||
| 31 | and be replaced by its expansion." | ||
| 32 | (interactive "P") | ||
| 33 | (setq abbrev-mode | ||
| 34 | (if (null arg) (not abbrev-mode) | ||
| 35 | (> (prefix-numeric-value arg) 0))) | ||
| 36 | (set-buffer-modified-p (buffer-modified-p))) ;No-op, but updates mode line. | ||
| 37 | |||
| 38 | (defvar edit-abbrevs-map nil | ||
| 39 | "Keymap used in edit-abbrevs.") | ||
| 40 | (if edit-abbrevs-map | ||
| 41 | nil | ||
| 42 | (setq edit-abbrevs-map (make-sparse-keymap)) | ||
| 43 | (define-key edit-abbrevs-map "\C-x\C-s" 'edit-abbrevs-redefine) | ||
| 44 | (define-key edit-abbrevs-map "\C-c\C-c" 'edit-abbrevs-redefine)) | ||
| 45 | |||
| 46 | (defun kill-all-abbrevs () | ||
| 47 | "Undefine all defined abbrevs." | ||
| 48 | (interactive) | ||
| 49 | (let ((tables abbrev-table-name-list)) | ||
| 50 | (while tables | ||
| 51 | (clear-abbrev-table (symbol-value (car tables))) | ||
| 52 | (setq tables (cdr tables))))) | ||
| 53 | |||
| 54 | (defun insert-abbrevs () | ||
| 55 | "Insert after point a description of all defined abbrevs. | ||
| 56 | Mark is set after the inserted text." | ||
| 57 | (interactive) | ||
| 58 | (push-mark | ||
| 59 | (save-excursion | ||
| 60 | (let ((tables abbrev-table-name-list)) | ||
| 61 | (while tables | ||
| 62 | (insert-abbrev-table-description (car tables) t) | ||
| 63 | (setq tables (cdr tables)))) | ||
| 64 | (point)))) | ||
| 65 | |||
| 66 | (defun list-abbrevs () | ||
| 67 | "Display a list of all defined abbrevs." | ||
| 68 | (interactive) | ||
| 69 | (display-buffer (prepare-abbrev-list-buffer))) | ||
| 70 | |||
| 71 | (defun prepare-abbrev-list-buffer () | ||
| 72 | (save-excursion | ||
| 73 | (set-buffer (get-buffer-create "*Abbrevs*")) | ||
| 74 | (erase-buffer) | ||
| 75 | (let ((tables abbrev-table-name-list)) | ||
| 76 | (while tables | ||
| 77 | (insert-abbrev-table-description (car tables) t) | ||
| 78 | (setq tables (cdr tables)))) | ||
| 79 | (goto-char (point-min)) | ||
| 80 | (set-buffer-modified-p nil) | ||
| 81 | (edit-abbrevs-mode)) | ||
| 82 | (get-buffer-create "*Abbrevs*")) | ||
| 83 | |||
| 84 | (defun edit-abbrevs-mode () | ||
| 85 | "Major mode for editing the list of abbrev definitions. | ||
| 86 | \\{edit-abbrevs-map}" | ||
| 87 | (interactive) | ||
| 88 | (setq major-mode 'edit-abbrevs-mode) | ||
| 89 | (setq mode-name "Edit-Abbrevs") | ||
| 90 | (use-local-map edit-abbrevs-map)) | ||
| 91 | |||
| 92 | (defun edit-abbrevs () | ||
| 93 | "Alter abbrev definitions by editing a list of them. | ||
| 94 | Selects a buffer containing a list of abbrev definitions. | ||
| 95 | You can edit them and type \\<edit-abbrevs-map>\\[edit-abbrevs-redefine] to redefine abbrevs | ||
| 96 | according to your editing. | ||
| 97 | Buffer contains a header line for each abbrev table, | ||
| 98 | which is the abbrev table name in parentheses. | ||
| 99 | This is followed by one line per abbrev in that table: | ||
| 100 | NAME USECOUNT EXPANSION HOOK | ||
| 101 | where NAME and EXPANSION are strings with quotes, | ||
| 102 | USECOUNT is an integer, and HOOK is any valid function | ||
| 103 | or may be omitted (it is usually omitted)." | ||
| 104 | (interactive) | ||
| 105 | (switch-to-buffer (prepare-abbrev-list-buffer))) | ||
| 106 | |||
| 107 | (defun edit-abbrevs-redefine () | ||
| 108 | "Redefine abbrevs according to current buffer contents." | ||
| 109 | (interactive) | ||
| 110 | (define-abbrevs t) | ||
| 111 | (set-buffer-modified-p nil)) | ||
| 112 | |||
| 113 | (defun define-abbrevs (&optional arg) | ||
| 114 | "Define abbrevs according to current visible buffer contents. | ||
| 115 | See documentation of `edit-abbrevs' for info on the format of the | ||
| 116 | text you must have in the buffer. | ||
| 117 | With argument, eliminate all abbrev definitions except | ||
| 118 | the ones defined from the buffer now." | ||
| 119 | (interactive "P") | ||
| 120 | (if arg (kill-all-abbrevs)) | ||
| 121 | (save-excursion | ||
| 122 | (goto-char (point-min)) | ||
| 123 | (while (and (not (eobp)) (re-search-forward "^(" nil t)) | ||
| 124 | (let* ((buf (current-buffer)) | ||
| 125 | (table (read buf)) | ||
| 126 | abbrevs) | ||
| 127 | (forward-line 1) | ||
| 128 | (while (progn (forward-line 1) | ||
| 129 | (not (eolp))) | ||
| 130 | (setq name (read buf) count (read buf) exp (read buf)) | ||
| 131 | (skip-chars-backward " \t\n\f") | ||
| 132 | (setq hook (if (not (eolp)) (read buf))) | ||
| 133 | (skip-chars-backward " \t\n\f") | ||
| 134 | (setq abbrevs (cons (list name exp hook count) abbrevs))) | ||
| 135 | (define-abbrev-table table abbrevs))))) | ||
| 136 | |||
| 137 | (defun read-abbrev-file (&optional file quietly) | ||
| 138 | "Read abbrev definitions from file written with `write-abbrev-file'. | ||
| 139 | Optional argument FILE is the name of the file to read; | ||
| 140 | it defaults to the value of `abbrev-file-name'. | ||
| 141 | Optional second argument QUIETLY non-nil means don't print anything." | ||
| 142 | (interactive "fRead abbrev file: ") | ||
| 143 | (load (if (and file (> (length file) 0)) file abbrev-file-name) | ||
| 144 | nil quietly) | ||
| 145 | (setq save-abbrevs t abbrevs-changed nil)) | ||
| 146 | |||
| 147 | (defun quietly-read-abbrev-file (&optional file) | ||
| 148 | "Read abbrev definitions from file written with write-abbrev-file. | ||
| 149 | Optional argument FILE is the name of the file to read; | ||
| 150 | it defaults to the value of `abbrev-file-name'. | ||
| 151 | Does not print anything." | ||
| 152 | ;(interactive "fRead abbrev file: ") | ||
| 153 | (read-abbrev-file file t)) | ||
| 154 | |||
| 155 | (defun write-abbrev-file (file) | ||
| 156 | "Write all abbrev definitions to file of Lisp code. | ||
| 157 | The file written can be loaded in another session to define the same abbrevs. | ||
| 158 | The argument FILE is the file name to write." | ||
| 159 | (interactive | ||
| 160 | (list | ||
| 161 | (read-file-name "Write abbrev file: " | ||
| 162 | (file-name-directory (expand-file-name abbrev-file-name)) | ||
| 163 | abbrev-file-name))) | ||
| 164 | (interactive "FWrite abbrev file: ") | ||
| 165 | (or (and file (> (length file) 0)) | ||
| 166 | (setq file abbrev-file-name)) | ||
| 167 | (save-excursion | ||
| 168 | (set-buffer (get-buffer-create " write-abbrev-file")) | ||
| 169 | (erase-buffer) | ||
| 170 | (let ((tables abbrev-table-name-list)) | ||
| 171 | (while tables | ||
| 172 | (insert-abbrev-table-description (car tables) nil) | ||
| 173 | (setq tables (cdr tables)))) | ||
| 174 | (write-region 1 (point-max) file) | ||
| 175 | (erase-buffer))) | ||
| 176 | |||
| 177 | (defun add-mode-abbrev (arg) | ||
| 178 | "Define mode-specific abbrev for last word(s) before point. | ||
| 179 | Argument is how many words before point form the expansion; | ||
| 180 | or zero means the region is the expansion. | ||
| 181 | A negative argument means to undefine the specified abbrev. | ||
| 182 | Reads the abbreviation in the minibuffer. | ||
| 183 | |||
| 184 | Don't use this function in a Lisp program; use `define-abbrev' instead." | ||
| 185 | (interactive "p") | ||
| 186 | (add-abbrev | ||
| 187 | (if only-global-abbrevs | ||
| 188 | global-abbrev-table | ||
| 189 | (or local-abbrev-table | ||
| 190 | (error "No per-mode abbrev table"))) | ||
| 191 | "Mode" arg)) | ||
| 192 | |||
| 193 | (defun add-global-abbrev (arg) | ||
| 194 | "Define global (all modes) abbrev for last word(s) before point. | ||
| 195 | The prefix argument specifies the number of words before point that form the | ||
| 196 | expansion; or zero means the region is the expansion. | ||
| 197 | A negative argument means to undefine the specified abbrev. | ||
| 198 | This command uses the minibuffer to read the abbreviation. | ||
| 199 | |||
| 200 | Don't use this function in a Lisp program; use `define-abbrev' instead." | ||
| 201 | (interactive "p") | ||
| 202 | (add-abbrev global-abbrev-table "Global" arg)) | ||
| 203 | |||
| 204 | (defun add-abbrev (table type arg) | ||
| 205 | (let ((exp (and (>= arg 0) | ||
| 206 | (buffer-substring | ||
| 207 | (point) | ||
| 208 | (if (= arg 0) (mark) | ||
| 209 | (save-excursion (forward-word (- arg)) (point)))))) | ||
| 210 | name) | ||
| 211 | (setq name | ||
| 212 | (read-string (format (if exp "%s abbrev for \"%s\": " | ||
| 213 | "Undefine %s abbrev: ") | ||
| 214 | type exp))) | ||
| 215 | (if (or (null exp) | ||
| 216 | (not (abbrev-expansion name table)) | ||
| 217 | (y-or-n-p (format "%s expands to \"%s\"; redefine? " | ||
| 218 | name (abbrev-expansion name table)))) | ||
| 219 | (define-abbrev table (downcase name) exp)))) | ||
| 220 | |||
| 221 | (defun inverse-add-mode-abbrev (arg) | ||
| 222 | "Define last word before point as a mode-specific abbrev. | ||
| 223 | With prefix argument N, defines the Nth word before point. | ||
| 224 | This command uses the minibuffer to read the expansion. | ||
| 225 | Expands the abbreviation after defining it." | ||
| 226 | (interactive "p") | ||
| 227 | (inverse-add-abbrev | ||
| 228 | (if only-global-abbrevs | ||
| 229 | global-abbrev-table | ||
| 230 | (or local-abbrev-table | ||
| 231 | (error "No per-mode abbrev table"))) | ||
| 232 | "Mode" arg)) | ||
| 233 | |||
| 234 | (defun inverse-add-global-abbrev (arg) | ||
| 235 | "Define last word before point as a global (mode-independent) abbrev. | ||
| 236 | With prefix argument N, defines the Nth word before point. | ||
| 237 | This command uses the minibuffer to read the expansion. | ||
| 238 | Expands the abbreviation after defining it." | ||
| 239 | (interactive "p") | ||
| 240 | (inverse-add-abbrev global-abbrev-table "Global" arg)) | ||
| 241 | |||
| 242 | (defun inverse-add-abbrev (table type arg) | ||
| 243 | (let (name nameloc exp) | ||
| 244 | (save-excursion | ||
| 245 | (forward-word (- arg)) | ||
| 246 | (setq name (buffer-substring (point) (progn (forward-word 1) | ||
| 247 | (setq nameloc (point)))))) | ||
| 248 | (setq exp (read-string (format "%s expansion for \"%s\": " | ||
| 249 | type name))) | ||
| 250 | (if (or (not (abbrev-expansion name table)) | ||
| 251 | (y-or-n-p (format "%s expands to \"%s\"; redefine? " | ||
| 252 | name (abbrev-expansion name table)))) | ||
| 253 | (progn | ||
| 254 | (define-abbrev table (downcase name) exp) | ||
| 255 | (save-excursion | ||
| 256 | (goto-char nameloc) | ||
| 257 | (expand-abbrev)))))) | ||
| 258 | |||
| 259 | (defun abbrev-prefix-mark (&optional arg) | ||
| 260 | "Mark current point as the beginning of an abbrev. | ||
| 261 | Abbrev to be expanded starts here rather than at beginning of word. | ||
| 262 | This way, you can expand an abbrev with a prefix: insert the prefix, | ||
| 263 | use this command, then insert the abbrev." | ||
| 264 | (interactive "P") | ||
| 265 | (or arg (expand-abbrev)) | ||
| 266 | (setq abbrev-start-location (point-marker) | ||
| 267 | abbrev-start-location-buffer (current-buffer)) | ||
| 268 | (insert "-")) | ||
| 269 | |||
| 270 | (defun expand-region-abbrevs (start end &optional noquery) | ||
| 271 | "For abbrev occurrence in the region, offer to expand it. | ||
| 272 | The user is asked to type y or n for each occurrence. | ||
| 273 | A prefix argument means don't query; expand all abbrevs. | ||
| 274 | If called from a Lisp program, arguments are START END &optional NOQUERY." | ||
| 275 | (interactive "r\nP") | ||
| 276 | (save-excursion | ||
| 277 | (goto-char start) | ||
| 278 | (let ((lim (- (point-max) end)) | ||
| 279 | pnt string) | ||
| 280 | (while (and (not (eobp)) | ||
| 281 | (progn (forward-word 1) | ||
| 282 | (<= (setq pnt (point)) (- (point-max) lim)))) | ||
| 283 | (if (abbrev-expansion | ||
| 284 | (setq string | ||
| 285 | (buffer-substring | ||
| 286 | (save-excursion (forward-word -1) (point)) | ||
| 287 | pnt))) | ||
| 288 | (if (or noquery (y-or-n-p (format "Expand `%s'? " string))) | ||
| 289 | (expand-abbrev))))))) | ||
diff --git a/lisp/chistory.el b/lisp/chistory.el new file mode 100644 index 00000000000..3a8bcb6d7c9 --- /dev/null +++ b/lisp/chistory.el | |||
| @@ -0,0 +1,167 @@ | |||
| 1 | ;; chistory -- List command history | ||
| 2 | ;; Copyright (C) 1985 Free Software Foundation, Inc. | ||
| 3 | ;; Principal author K. Shane Hartman | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software; you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation; either version 1, or (at your option) | ||
| 10 | ;; any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs; see the file COPYING. If not, write to | ||
| 19 | ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | |||
| 21 | |||
| 22 | (provide 'chistory) | ||
| 23 | |||
| 24 | ;; This really has nothing to do with list-command-history per se, but | ||
| 25 | ;; its a nice alternative to C-x ESC (repeat-complex-command) and | ||
| 26 | ;; functions as a lister if given no pattern. It's not important | ||
| 27 | ;; enough to warrant a file of its own. | ||
| 28 | |||
| 29 | ;;;###autoload | ||
| 30 | (defun repeat-matching-complex-command (&optional pattern) | ||
| 31 | "Edit and re-evaluate complex command with name matching PATTERN. | ||
| 32 | Matching occurrences are displayed, most recent first, until you select | ||
| 33 | a form for evaluation. If PATTERN is empty (or nil), every form in the | ||
| 34 | command history is offered. The form is placed in the minibuffer for | ||
| 35 | editing and the result is evaluated." | ||
| 36 | (interactive "sRedo Command (regexp): ") | ||
| 37 | (if pattern | ||
| 38 | (if (equal (setq pattern | ||
| 39 | (substring pattern | ||
| 40 | (or (string-match "[ \t]*[^ \t]" pattern) | ||
| 41 | (length pattern)))) | ||
| 42 | "") | ||
| 43 | (setq pattern nil))) | ||
| 44 | (let ((history command-history) | ||
| 45 | (temp) | ||
| 46 | (what)) | ||
| 47 | (while (and history (not what)) | ||
| 48 | (setq temp (car history)) | ||
| 49 | (if (and (or (not pattern) (string-match pattern (symbol-name (car temp)))) | ||
| 50 | (y-or-n-p (format "Redo %s? " (setq temp (prin1-to-string temp))))) | ||
| 51 | (setq what (car history)) | ||
| 52 | (setq history (cdr history)))) | ||
| 53 | (if (not what) | ||
| 54 | (error "Command history exhausted") | ||
| 55 | ;; Try to remove any useless command history element for this command. | ||
| 56 | (if (eq (car (car command-history)) 'repeat-matching-complex-command) | ||
| 57 | (setq command-history (cdr command-history))) | ||
| 58 | (edit-and-eval-command "Redo: " what)))) | ||
| 59 | |||
| 60 | (defvar default-command-history-filter-garbage | ||
| 61 | '(command-history-mode | ||
| 62 | list-command-history | ||
| 63 | electric-command-history) | ||
| 64 | "*A list of symbols. If `default-list-command-history-filter' is | ||
| 65 | given a list whose car is an element of this list, then it will return | ||
| 66 | non-nil (indicating the list should be discarded from the history). | ||
| 67 | Initially, all commands related to the command history are discarded.") | ||
| 68 | |||
| 69 | (defvar list-command-history-filter 'default-command-history-filter | ||
| 70 | "If non-nil, should be the name of a function of one argument. | ||
| 71 | It is passed each element of the command history when | ||
| 72 | \\[list-command-history] is called. If the filter returns non-nil for | ||
| 73 | some element, that element is excluded from the history listing. The | ||
| 74 | default filter removes commands associated with the command-history.") | ||
| 75 | |||
| 76 | (defun default-command-history-filter (frob) | ||
| 77 | "Filter commands matching `default-command-history-filter-garbage' list | ||
| 78 | from the command history." | ||
| 79 | (or (not (consp frob)) | ||
| 80 | (memq (car frob) default-command-history-filter-garbage))) | ||
| 81 | |||
| 82 | (defvar list-command-history-max 32 | ||
| 83 | "*If non-nil, should be a positive number which specifies the maximum | ||
| 84 | length of the Command History listing produced by `list-command-history'.") | ||
| 85 | |||
| 86 | ;;;###autoload | ||
| 87 | (defun list-command-history () | ||
| 88 | "List history of commands typed to minibuffer. | ||
| 89 | The number of commands listed is controlled by `list-command-history-max'. | ||
| 90 | Calls value of `list-command-history-filter' (if non-nil) on each history | ||
| 91 | element to judge if that element should be excluded from the list. | ||
| 92 | |||
| 93 | The buffer is left in Command History mode." | ||
| 94 | (interactive) | ||
| 95 | (with-output-to-temp-buffer | ||
| 96 | "*Command History*" | ||
| 97 | (let ((history command-history) | ||
| 98 | (buffer-read-only nil) | ||
| 99 | (count (or list-command-history-max -1))) | ||
| 100 | (while (and (/= count 0) history) | ||
| 101 | (if (and (boundp 'list-command-history-filter) | ||
| 102 | list-command-history-filter | ||
| 103 | (funcall list-command-history-filter (car history))) | ||
| 104 | nil | ||
| 105 | (setq count (1- count)) | ||
| 106 | (prin1 (car history)) | ||
| 107 | (terpri)) | ||
| 108 | (setq history (cdr history)))) | ||
| 109 | (save-excursion | ||
| 110 | (set-buffer "*Command History*") | ||
| 111 | (goto-char (point-min)) | ||
| 112 | (if (eobp) | ||
| 113 | (error "No command history") | ||
| 114 | (Command-history-setup))))) | ||
| 115 | |||
| 116 | (defun Command-history-setup (&optional majormode modename keymap) | ||
| 117 | (set-buffer "*Command History*") | ||
| 118 | (use-local-map (or keymap command-history-map)) | ||
| 119 | (lisp-mode-variables nil) | ||
| 120 | (set-syntax-table emacs-lisp-mode-syntax-table) | ||
| 121 | (setq buffer-read-only t) | ||
| 122 | (use-local-map (or keymap command-history-map)) | ||
| 123 | (setq major-mode (or majormode 'command-history-mode)) | ||
| 124 | (setq mode-name (or modename "Command History"))) | ||
| 125 | |||
| 126 | (defvar command-history-hook nil | ||
| 127 | "If non-nil, its value is called on entry to `command-history-mode'.") | ||
| 128 | |||
| 129 | (defvar command-history-map nil) | ||
| 130 | (if command-history-map | ||
| 131 | nil | ||
| 132 | (setq command-history-map | ||
| 133 | (nconc (make-sparse-keymap) shared-lisp-mode-map)) | ||
| 134 | (suppress-keymap command-history-map) | ||
| 135 | (define-key command-history-map "x" 'command-history-repeat) | ||
| 136 | (define-key command-history-map "\n" 'next-line) | ||
| 137 | (define-key command-history-map "\r" 'next-line) | ||
| 138 | (define-key command-history-map "\177" 'previous-line)) | ||
| 139 | |||
| 140 | (defun command-history-repeat () | ||
| 141 | "Repeat the command shown on the current line. | ||
| 142 | The buffer for that command is the previous current buffer." | ||
| 143 | (interactive) | ||
| 144 | (save-excursion | ||
| 145 | (eval (prog1 | ||
| 146 | (save-excursion | ||
| 147 | (beginning-of-line) | ||
| 148 | (read (current-buffer))) | ||
| 149 | (set-buffer | ||
| 150 | (cdr (buffer-list))))))) | ||
| 151 | |||
| 152 | ;;;###autoload | ||
| 153 | (defun command-history-mode () | ||
| 154 | "Major mode for examining commands from `command-history'. | ||
| 155 | The number of commands listed is controlled by `list-command-history-max'. | ||
| 156 | The command history is filtered by `list-command-history-filter' if non-nil. | ||
| 157 | Use \\<command-history-map>\\[command-history-repeat] to repeat the command on the current line. | ||
| 158 | |||
| 159 | Otherwise much like Emacs-Lisp Mode except that there is no self-insertion | ||
| 160 | and digits provide prefix arguments. Tab does not indent. | ||
| 161 | \\{command-history-map} | ||
| 162 | Calls the value of `command-history-hook' if that is non-nil. | ||
| 163 | The Command History listing is recomputed each time this mode is invoked." | ||
| 164 | (interactive) | ||
| 165 | (list-command-history) | ||
| 166 | (pop-to-buffer "*Command History*") | ||
| 167 | (run-hooks 'command-history-hook)) | ||