0
|
1 ;;; echistory.el --- Electric Command History Mode
|
|
2
|
|
3 ;; Copyright (C) 1985 Free Software Foundation, Inc.
|
|
4
|
|
5 ;; Author: K. Shane Hartman
|
|
6 ;; Maintainer: FSF
|
|
7
|
|
8 ;; This file is part of XEmacs.
|
|
9
|
|
10 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
11 ;; under the terms of the GNU General Public License as published by
|
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
13 ;; any later version.
|
|
14
|
|
15 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
18 ;; General Public License for more details.
|
|
19
|
|
20 ;; You should have received a copy of the GNU General Public License
|
|
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
70
|
22 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
0
|
23
|
70
|
24 ;;; Synched up with: FSF 19.30.
|
0
|
25
|
|
26 ;;; Code:
|
|
27
|
|
28 (require 'electric) ; command loop
|
|
29 (require 'chistory) ; history lister
|
|
30
|
|
31 ;;;###autoload
|
|
32 (defun Electric-command-history-redo-expression (&optional noconfirm)
|
|
33 "Edit current history line in minibuffer and execute result.
|
70
|
34 With prefix argument NOCONFIRM, execute current line as-is without editing."
|
0
|
35 (interactive "P")
|
|
36 (let (todo)
|
|
37 (save-excursion
|
|
38 (set-buffer "*Command History*")
|
|
39 (beginning-of-line)
|
|
40 (setq todo (read (current-buffer)))
|
|
41 (if (boundp 'electric-history-in-progress)
|
|
42 (if todo (throw 'electric-history-quit (list noconfirm todo)))))))
|
|
43
|
|
44 (defvar electric-history-map ())
|
|
45 (if electric-history-map
|
|
46 ()
|
|
47 (setq electric-history-map (make-keymap))
|
|
48 (set-keymap-name electric-history-map 'electric-history-map)
|
|
49 (set-keymap-default-binding electric-history-map 'Electric-history-undefined)
|
|
50 (define-key electric-history-map "\C-u" 'universal-argument)
|
|
51 (define-key electric-history-map " " 'Electric-command-history-redo-expression)
|
|
52 (define-key electric-history-map "!" 'Electric-command-history-redo-expression)
|
|
53 (define-key electric-history-map "\e\C-x" 'eval-sexp)
|
|
54 (define-key electric-history-map "\e\C-d" 'down-list)
|
|
55 (define-key electric-history-map "\e\C-u" 'backward-up-list)
|
|
56 (define-key electric-history-map "\e\C-b" 'backward-sexp)
|
|
57 (define-key electric-history-map "\e\C-f" 'forward-sexp)
|
|
58 (define-key electric-history-map "\e\C-a" 'beginning-of-defun)
|
|
59 (define-key electric-history-map "\e\C-e" 'end-of-defun)
|
|
60 (define-key electric-history-map "\e\C-n" 'forward-list)
|
|
61 (define-key electric-history-map "\e\C-p" 'backward-list)
|
|
62 (define-key electric-history-map "q" 'Electric-history-quit)
|
|
63 (define-key electric-history-map "\C-c" nil)
|
|
64 (define-key electric-history-map "\C-c\C-c" 'Electric-history-quit)
|
|
65 (define-key electric-history-map "\C-]" 'Electric-history-quit)
|
|
66 (define-key electric-history-map "\C-z" 'suspend-emacs)
|
70
|
67 ;; (define-key electric-history-map "\C-h" 'Helper-help)
|
|
68 (define-key electric-history-map '(control h) 'Helper-help)
|
0
|
69 (define-key electric-history-map 'backspace 'previous-line)
|
|
70 (define-key electric-history-map "?" 'Helper-describe-bindings)
|
|
71 (define-key electric-history-map "\e>" 'end-of-buffer)
|
|
72 (define-key electric-history-map "\e<" 'beginning-of-buffer)
|
|
73 (define-key electric-history-map "\n" 'next-line)
|
|
74 (define-key electric-history-map "\r" 'next-line)
|
|
75 (define-key electric-history-map "\177" 'previous-line)
|
|
76 (define-key electric-history-map "\C-n" 'next-line)
|
|
77 (define-key electric-history-map "\C-p" 'previous-line)
|
|
78 (define-key electric-history-map "\ev" 'scroll-down)
|
|
79 (define-key electric-history-map "\C-v" 'scroll-up)
|
|
80 (define-key electric-history-map [home] 'beginning-of-buffer)
|
|
81 (define-key electric-history-map [down] 'next-line)
|
|
82 (define-key electric-history-map [up] 'previous-line)
|
|
83 (define-key electric-history-map [prior] 'scroll-down)
|
|
84 (define-key electric-history-map [next] 'scroll-up)
|
|
85 (define-key electric-history-map "\C-l" 'recenter)
|
|
86 (define-key electric-history-map "\e\C-v" 'scroll-other-window))
|
|
87
|
|
88 (defvar electric-command-history-hook nil
|
|
89 "If non-nil, its value is called by `electric-command-history'.")
|
|
90
|
|
91 ;;;###autoload
|
|
92 (defun electric-command-history ()
|
|
93 "\\<electric-history-map>Major mode for examining and redoing commands from `command-history'.
|
|
94 This pops up a window with the Command History listing.
|
|
95 The number of command listed is controlled by `list-command-history-max'.
|
|
96 The command history is filtered by `list-command-history-filter' if non-nil.
|
|
97 Combines typeout Command History list window with menu like selection
|
|
98 of an expression from the history for re-evaluation in the *original* buffer.
|
|
99
|
|
100 The history displayed is filtered by `list-command-history-filter' if non-nil.
|
|
101
|
70
|
102 This pops up a window with the Command History listing. If the very
|
|
103 next character typed is Space, the listing is killed and the previous
|
|
104 window configuration is restored. Otherwise, you can browse in the
|
|
105 Command History with Return moving down and Delete moving up, possibly
|
|
106 selecting an expression to be redone with Space or quitting with `Q'.
|
|
107
|
0
|
108 Like Emacs-Lisp mode except that characters do not insert themselves and
|
|
109 Tab and Linefeed do not indent. Instead these commands are provided:
|
|
110 \\{electric-history-map}
|
|
111
|
|
112 Calls the value of `electric-command-history-hook' if that is non-nil.
|
|
113 The Command History listing is recomputed each time this mode is invoked."
|
|
114 (interactive)
|
|
115 (let ((electric-history-in-progress t)
|
|
116 (old-buffer (current-buffer))
|
|
117 (todo))
|
|
118 (unwind-protect
|
|
119 (setq todo
|
|
120 (catch 'electric-history-quit
|
|
121 (save-window-excursion
|
|
122 (save-window-excursion
|
|
123 (list-command-history)
|
|
124 (set-buffer "*Command History*")
|
|
125 (Command-history-setup 'electric-command-history
|
|
126 "Electric History"
|
|
127 electric-history-map))
|
|
128 (Electric-pop-up-window "*Command History*")
|
|
129 (run-hooks 'electric-command-history-hook)
|
|
130 (if (eobp)
|
|
131 (progn (ding)
|
|
132 (message "No command history.")
|
|
133 (throw 'electric-history-quit nil))
|
|
134 (let ((Helper-return-blurb "return to History"))
|
|
135 (Electric-command-loop 'electric-history-quit
|
|
136 "->" t))))))
|
|
137 (set-buffer "*Command History*")
|
|
138 (Command-history-setup)
|
|
139 (bury-buffer (current-buffer)))
|
|
140 (if (consp todo)
|
|
141 (progn (set-buffer old-buffer)
|
|
142 (if (car todo)
|
|
143 (apply (car (car (cdr todo))) (cdr (car (cdr todo))))
|
|
144 (edit-and-eval-command "Redo: " (car (cdr todo))))))))
|
|
145
|
|
146 (defun Electric-history-undefined ()
|
|
147 (interactive)
|
|
148 (ding)
|
|
149 (message (substitute-command-keys "Type \\[Helper-help] for help, ? for commands, C-c C-c to quit, Space to execute"))
|
|
150 (sit-for 4))
|
|
151
|
|
152 (defun Electric-history-quit ()
|
|
153 "Quit Electric Command History, restoring previous window configuration."
|
|
154 (interactive)
|
|
155 (if (boundp 'electric-history-in-progress)
|
70
|
156 (progn (message nil)
|
0
|
157 (throw 'electric-history-quit nil))))
|
|
158
|
|
159 ;;; echistory.el ends here
|