annotate lisp/dired/gmhist-app.el @ 9:6f2bbbbbe05a

Added tag r19-15b5 for changeset 4b173ad71786
author cvs
date Mon, 13 Aug 2007 08:47:36 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;;; gmhist-app.el - applications of gmhist for some standard commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;;; Id: gmhist-app.el,v 4.16 1992/02/26 14:32:27 sk RelBeta
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;;; The following commands are redefined to get history:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;;; keep-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;;; flush-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;; how-many
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;; occur
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;;; => regexp-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;;; grep => grep-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;;; shell-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;; shell-command-on-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;; => shell-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;;; eval-expression => eval-expression-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;;; compile => compile-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;;; You probably want to establish this key binding in your ~/.emacs,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;;; it will make `M-x M-p' equivalent to `C-x ESC':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;;; (define-key esc-map "x" 'gmhist-execute-extended-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;;; (define-key esc-map "X" 'execute-extended-command) ; save old M-x command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;;; The second line is to save the old M-x command under M-X, just in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;;; case anything goes wrong.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (require 'gmhist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; gmhist modifications for replace.el (preloaded).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (mapcar '(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (gmhist-make-magic x 'regexp-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (if gmhist-emacs-19-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 '(keep-lines flush-lines how-many)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 '(keep-lines flush-lines how-many occur)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (if gmhist-emacs-19-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (gmhist-replace-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 'occur
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 '(gmhist-interactive "sList lines matching regexp: \nP"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 'regexp-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (gmhist-replace-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 'grep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 '(list (read-with-history-in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 'grep-history ; or 'regexp-history?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (concat "Run "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (substring grep-command 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (string-match "[\t ]+" grep-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 " (with args): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (gmhist-make-magic 'grep 'grep-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;; gmhist modification for simple.el (is preloaded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (if gmhist-emacs-19-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (gmhist-replace-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 'shell-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 '(gmhist-interactive "sShell command: \nP" 'shell-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (gmhist-replace-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 'shell-command-on-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 '(gmhist-interactive "r\nsShell command on region: \nP\np"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 'shell-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (gmhist-make-magic 'shell-command 'shell-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (gmhist-make-magic 'shell-command-on-region 'shell-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (gmhist-make-magic 'eval-expression)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;; gmhist modification for compile.el (autoloaded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; Often people make the variable compile-command buffer-local.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; Instead of compile-command, you now have compile-history, which is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; initialized to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; (list compile-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; but afterwards gmhist ignores compile-command. So your old file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; local variable sections or mode hooks will cease to work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; Here is a solution: Make compile-history instead of compile-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; buffer-local (in a local var section of a file or in a hook, using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; function make-local-variable). If you only sometimes have gmhist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; loaded, make both variables buffer-local.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; (gmhist-make-magic 'compile 'compile-history) won't work because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; the interactive spec is not a string. Instead, hand-craft it:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (gmhist-replace-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 'compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 '(list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (read-with-history-in 'compile-history "Compile command: ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; instead of...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;(put 'compile-history 'default compile-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; ... do the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (put 'compile-history 'backup t) ; requires at least gmhist 3.22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (put 'compile-history 'no-default t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (put 'compile-history 'initial-hist (list compile-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (put 'compile-history 'cursor-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;; gmhist modifications for tags.el (is autoloaded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;; The distributed version of tags.el does not support a load hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; Add the statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; (run-hooks 'tags-load-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;; at the very end of tags.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defvar tags-history nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 "History of tags.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (setq tags-load-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; redefine find-tag-tag upon loading of tags.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 '(lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (fset 'find-tag-tag 'gmhist-find-tag-tag)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (defun gmhist-find-tag-tag (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; compare these two lines to the original definition...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (let ((defalt (find-tag-default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (if (and defalt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (string-match "[:']$" defalt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (setq defalt (substring defalt 0 -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (put 'tags-history 'default defalt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; so that M-p lets you edit the default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (setq tags-history (cons defalt tags-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (list (read-with-history-in 'tags-history string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; Gmhist version of M-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; Make M-x have history (it actually has one already, but only through
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; C-x ESC (repeat-complex-command), not via M-p within the M-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;; prompt.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; execute-extended-command must be rewritten if minibuffer history is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; implemented in C. Probably call-interactively too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (defvar gmhist-execute-extended-command-map (copy-keymap gmhist-completion-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 "Keymap used inside `gmhist-execute-extended-command'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; We have to define custom version of RET and SPC (actually TAB as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; well) since they behave completely different immediately after M-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; (reading a command) or after the history postion has been changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; to a non-zero value (editing an s-expr, an old command with its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; arguments).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (define-key gmhist-execute-extended-command-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 "\r" 'gmhist-execute-extended-command-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (define-key gmhist-execute-extended-command-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 " " 'gmhist-execute-extended-command-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (defun gmhist-execute-extended-command-exit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 "Maybe complete the minibuffer contents, and exit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 Completes commands before exiting, but leaves command history items alone."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; Completion (over the set of commands) only occurs if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; minibufer-history-position is 0, meaning we are editing a command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; name. Non-zero history positions mean we are editing an sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; resulting from an earlier command and its argument, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;; completion is not meaningful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (if (equal 0 minibuffer-history-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;; Rather than calling minibuffer-complete-and-exit directly,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; account for the possibility that e.g. a partial completion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; has been loaded and changed the bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (funcall (lookup-key minibuffer-local-must-match-map "\C-m"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (exit-minibuffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (defun gmhist-execute-extended-command-space ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (if (equal 0 minibuffer-history-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (funcall (lookup-key minibuffer-local-must-match-map " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (insert " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (defun gmhist-execute-extended-command () ; M-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 "Read function name, then read its arguments and call it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 You can use all gmhist commands (see variable gmhist-completion-map),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 especially \\<gmhist-completion-map>\\[gmhist-previous] to backup in command-history."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; We don't want '(gmhist-execute-extended-command (quote COMMAND))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; on the command history, since this is ugly, and COMMAND itself is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; always right next to it. This is so because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; gmhist-execute-extended-command is not a builtin like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; execute-extended-command and thus is itself entered on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; command-history.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (if (assq 'gmhist-execute-extended-command command-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (let ((list command-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (while list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (setq elt (car list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (if (eq (car-safe elt) 'gmhist-execute-extended-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;; destructively remove this elt from command-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (setcar list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; and exit the loop since if we're doing this each time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; there shouldn't be more than one such elt - the one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; from the last time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (setq list nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (setq list (cdr list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (setq command-history (delq nil command-history))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (let (cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (let ((minibuffer-completion-confirm nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;; We only need read-with-history-in here to make M-p available,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; the new command will be recorded below
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (minibuffer-history-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (put 'command-history 'cursor-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; command-history is maintained automatically:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (put 'command-history 'hist-ignore ".*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (put 'command-history 'no-default t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (put 'command-history 'completion-table obarray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (put 'command-history 'hist-map gmhist-execute-extended-command-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (put 'command-history 'completion-predicate 'commandp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (put 'command-history 'backup nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (setq cmd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (read-with-history-in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 'command-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (format "%s M-x "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;; this is not exactly like the original M-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;; but the following doesn't seem to work right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ; (cond ((eq '(4) current-prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ; "C-u")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ; (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ; (prefix-numeric-value current-prefix-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 "M-x ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (if (commandp cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (let ((prefix-arg current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (setq this-command cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (command-execute cmd t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;; else it is a lisp form from the history of old commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (eval cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (setq command-history (cons cmd command-history))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237