Commit | Line | Data |
---|---|---|
1cd7adc6 | 1 | ;;; bindings.el --- define standard key bindings and some variables |
4d120e8c | 2 | |
ab422c4d PE |
3 | ;; Copyright (C) 1985-1987, 1992-1996, 1999-2013 Free Software |
4 | ;; Foundation, Inc. | |
4d120e8c RS |
5 | |
6 | ;; Maintainer: FSF | |
7 | ;; Keywords: internal | |
bd78fa1d | 8 | ;; Package: emacs |
4d120e8c RS |
9 | |
10 | ;; This file is part of GNU Emacs. | |
11 | ||
eb3fa2cf | 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
4d120e8c | 13 | ;; it under the terms of the GNU General Public License as published by |
eb3fa2cf GM |
14 | ;; the Free Software Foundation, either version 3 of the License, or |
15 | ;; (at your option) any later version. | |
4d120e8c RS |
16 | |
17 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | ;; GNU General Public License for more details. | |
21 | ||
22 | ;; You should have received a copy of the GNU General Public License | |
eb3fa2cf | 23 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
4d120e8c RS |
24 | |
25 | ;;; Commentary: | |
26 | ||
4d120e8c RS |
27 | ;;; Code: |
28 | ||
1ebfdece GM |
29 | (defun make-mode-line-mouse-map (mouse function) "\ |
30 | Return a keymap with single entry for mouse key MOUSE on the mode line. | |
31 | MOUSE is defined to run function FUNCTION with no args in the buffer | |
dfdabcf9 DL |
32 | corresponding to the mode line clicked." |
33 | (let ((map (make-sparse-keymap))) | |
1ebfdece | 34 | (define-key map (vector 'mode-line mouse) function) |
dfdabcf9 DL |
35 | map)) |
36 | ||
e9580d71 GM |
37 | |
38 | (defun mode-line-toggle-read-only (event) | |
39 | "Like `toggle-read-only', for the mode-line." | |
40 | (interactive "e") | |
10766e9e | 41 | (with-selected-window (posn-window (event-start event)) |
9a930676 | 42 | (read-only-mode 'toggle))) |
e9580d71 | 43 | |
e9580d71 GM |
44 | (defun mode-line-toggle-modified (event) |
45 | "Toggle the buffer-modified flag from the mode-line." | |
24127af0 | 46 | (interactive "e") |
10766e9e | 47 | (with-selected-window (posn-window (event-start event)) |
e9580d71 GM |
48 | (set-buffer-modified-p (not (buffer-modified-p))) |
49 | (force-mode-line-update))) | |
50 | ||
e9580d71 GM |
51 | (defun mode-line-widen (event) |
52 | "Widen a buffer from the mode-line." | |
24127af0 | 53 | (interactive "e") |
10766e9e | 54 | (with-selected-window (posn-window (event-start event)) |
e9580d71 GM |
55 | (widen) |
56 | (force-mode-line-update))) | |
57 | ||
5e1cddda DL |
58 | (defvar mode-line-input-method-map |
59 | (let ((map (make-sparse-keymap))) | |
60 | (define-key map [mode-line mouse-2] | |
61 | (lambda (e) | |
62 | (interactive "e") | |
10766e9e | 63 | (with-selected-window (posn-window (event-start e)) |
5e1cddda DL |
64 | (toggle-input-method) |
65 | (force-mode-line-update)))) | |
66 | (define-key map [mode-line mouse-3] | |
67 | (lambda (e) | |
68 | (interactive "e") | |
10766e9e | 69 | (with-selected-window (posn-window (event-start e)) |
5e1cddda DL |
70 | (describe-current-input-method)))) |
71 | (purecopy map))) | |
72 | ||
f3185924 GM |
73 | (defvar mode-line-coding-system-map |
74 | (let ((map (make-sparse-keymap))) | |
da16962a | 75 | (define-key map [mode-line mouse-1] |
f3185924 GM |
76 | (lambda (e) |
77 | (interactive "e") | |
10766e9e | 78 | (with-selected-window (posn-window (event-start e)) |
f3185924 GM |
79 | (when (and enable-multibyte-characters |
80 | buffer-file-coding-system) | |
81 | (describe-coding-system buffer-file-coding-system))))) | |
cbe46e5f CY |
82 | (define-key map [mode-line mouse-3] |
83 | (lambda (e) | |
84 | (interactive "e") | |
10766e9e | 85 | (with-selected-window (posn-window (event-start e)) |
cbe46e5f | 86 | (call-interactively 'set-buffer-file-coding-system)))) |
f3185924 GM |
87 | (purecopy map)) |
88 | "Local keymap for the coding-system part of the mode line.") | |
89 | ||
6b61353c | 90 | (defun mode-line-change-eol (event) |
18a9f968 | 91 | "Cycle through the various possible kinds of end-of-line styles." |
6b61353c | 92 | (interactive "e") |
0ec08b38 | 93 | (with-selected-window (posn-window (event-start event)) |
6b61353c KH |
94 | (let ((eol (coding-system-eol-type buffer-file-coding-system))) |
95 | (set-buffer-file-coding-system | |
96 | (cond ((eq eol 0) 'dos) ((eq eol 1) 'mac) (t 'unix)))))) | |
18a9f968 SM |
97 | |
98 | (defvar mode-line-eol-desc-cache nil) | |
99 | ||
100 | (defun mode-line-eol-desc () | |
101 | (let* ((eol (coding-system-eol-type buffer-file-coding-system)) | |
102 | (mnemonic (coding-system-eol-type-mnemonic buffer-file-coding-system)) | |
1aa956a1 | 103 | (desc (assoc eol mode-line-eol-desc-cache))) |
18a9f968 SM |
104 | (if (and desc (eq (cadr desc) mnemonic)) |
105 | (cddr desc) | |
106 | (if desc (setq mode-line-eol-desc-cache nil)) ;Flush the cache if stale. | |
107 | (setq desc | |
108 | (propertize | |
109 | mnemonic | |
383f7350 | 110 | 'help-echo (format "End-of-line style: %s\nmouse-1: Cycle" |
18a9f968 | 111 | (if (eq eol 0) "Unix-style LF" |
44d15ae0 | 112 | (if (eq eol 1) "DOS-style CRLF" |
18a9f968 SM |
113 | (if (eq eol 2) "Mac-style CR" |
114 | "Undecided")))) | |
115 | 'keymap | |
116 | (eval-when-compile | |
117 | (let ((map (make-sparse-keymap))) | |
da16962a | 118 | (define-key map [mode-line mouse-1] 'mode-line-change-eol) |
359e4563 MY |
119 | map)) |
120 | 'mouse-face 'mode-line-highlight)) | |
18a9f968 SM |
121 | (push (cons eol (cons mnemonic desc)) mode-line-eol-desc-cache) |
122 | desc))) | |
123 | ||
5f2c76c6 CY |
124 | \f |
125 | ;;; Mode line contents | |
126 | ||
127 | (defcustom mode-line-default-help-echo | |
128 | "mouse-1: Select (drag to resize)\n\ | |
129 | mouse-2: Make current window occupy the whole frame\n\ | |
130 | mouse-3: Remove current window from display" | |
131 | "Default help text for the mode line. | |
132 | If the value is a string, it specifies the tooltip or echo area | |
133 | message to display when the mouse is moved over the mode line. | |
134 | If the text at the mouse position has a `help-echo' text | |
135 | property, that overrides this variable." | |
136 | :type '(choice (const :tag "No help" :value nil) string) | |
2a1e2476 | 137 | :version "24.3" |
5f2c76c6 CY |
138 | :group 'mode-line) |
139 | ||
140 | (defvar mode-line-front-space '(:eval (if (display-graphic-p) " " "-")) | |
141 | "Mode line construct to put at the front of the mode line. | |
142 | By default, this construct is displayed right at the beginning of | |
143 | the mode line, except that if there is a memory-full message, it | |
144 | is displayed first.") | |
145 | (put 'mode-line-front-space 'risky-local-variable t) | |
27d8b4bf | 146 | |
383f7350 CY |
147 | (defun mode-line-mule-info-help-echo (window _object _point) |
148 | "Return help text specifying WINDOW's buffer coding system." | |
149 | (with-current-buffer (window-buffer window) | |
150 | (if buffer-file-coding-system | |
151 | (format "Buffer coding system (%s): %s | |
cbe46e5f CY |
152 | mouse-1: Describe coding system |
153 | mouse-3: Set coding system" | |
383f7350 CY |
154 | (if enable-multibyte-characters "multi-byte" "unibyte") |
155 | (symbol-name buffer-file-coding-system)) | |
156 | "Buffer coding system: none specified"))) | |
157 | ||
dfdabcf9 DL |
158 | (defvar mode-line-mule-info |
159 | `("" | |
9ff33afb | 160 | (current-input-method |
27451bb4 RS |
161 | (:propertize ("" current-input-method-title) |
162 | help-echo (concat | |
6bdad9ae | 163 | ,(purecopy "Current input method: ") |
27451bb4 | 164 | current-input-method |
6bdad9ae | 165 | ,(purecopy "\n\ |
f46b8f6d | 166 | mouse-2: Disable input method\n\ |
6bdad9ae | 167 | mouse-3: Describe current input method")) |
359e4563 MY |
168 | local-map ,mode-line-input-method-map |
169 | mouse-face mode-line-highlight)) | |
3beb81fc | 170 | ,(propertize |
18a9f968 | 171 | "%z" |
383f7350 | 172 | 'help-echo 'mode-line-mule-info-help-echo |
359e4563 | 173 | 'mouse-face 'mode-line-highlight |
18a9f968 SM |
174 | 'local-map mode-line-coding-system-map) |
175 | (:eval (mode-line-eol-desc))) | |
383f7350 | 176 | "Mode line construct to report the multilingual environment. |
44c034c1 KH |
177 | Normally it displays current input method (if any activated) and |
178 | mnemonics of the following coding systems: | |
179 | coding system for saving or writing the current buffer | |
383f7350 CY |
180 | coding system for keyboard input (on a text terminal) |
181 | coding system for terminal output (on a text terminal)") | |
ac549fa5 | 182 | ;;;###autoload |
6dc3311d | 183 | (put 'mode-line-mule-info 'risky-local-variable t) |
f8bce5df KH |
184 | (make-variable-buffer-local 'mode-line-mule-info) |
185 | ||
5f2c76c6 CY |
186 | (defvar mode-line-client |
187 | `("" | |
188 | (:propertize ("" (:eval (if (frame-parameter nil 'client) "@" ""))) | |
189 | help-echo ,(purecopy "emacsclient frame"))) | |
190 | "Mode line construct for identifying emacsclient frames.") | |
ac549fa5 | 191 | ;;;###autoload |
5f2c76c6 | 192 | (put 'mode-line-client 'risky-local-variable t) |
4d120e8c | 193 | |
383f7350 CY |
194 | (defun mode-line-read-only-help-echo (window _object _point) |
195 | "Return help text specifying WINDOW's buffer read-only status." | |
196 | (format "Buffer is %s\nmouse-1: Toggle" | |
197 | (if (buffer-local-value 'buffer-read-only (window-buffer window)) | |
198 | "read-only" | |
199 | "writable"))) | |
200 | ||
201 | (defun mode-line-modified-help-echo (window _object _point) | |
202 | "Return help text specifying WINDOW's buffer modification status." | |
203 | (format "Buffer is %smodified\nmouse-1: Toggle modification state" | |
204 | (if (buffer-modified-p (window-buffer window)) "" "not "))) | |
205 | ||
dfdabcf9 DL |
206 | (defvar mode-line-modified |
207 | (list (propertize | |
3beb81fc | 208 | "%1*" |
383f7350 | 209 | 'help-echo 'mode-line-read-only-help-echo |
1ebfdece | 210 | 'local-map (purecopy (make-mode-line-mouse-map |
da16962a | 211 | 'mouse-1 |
359e4563 MY |
212 | #'mode-line-toggle-read-only)) |
213 | 'mouse-face 'mode-line-highlight) | |
3beb81fc DL |
214 | (propertize |
215 | "%1+" | |
383f7350 | 216 | 'help-echo 'mode-line-modified-help-echo |
1ebfdece | 217 | 'local-map (purecopy (make-mode-line-mouse-map |
da16962a | 218 | 'mouse-1 #'mode-line-toggle-modified)) |
359e4563 | 219 | 'mouse-face 'mode-line-highlight)) |
5f2c76c6 | 220 | "Mode line construct for displaying whether current buffer is modified.") |
ac549fa5 | 221 | ;;;###autoload |
6dc3311d | 222 | (put 'mode-line-modified 'risky-local-variable t) |
4d120e8c RS |
223 | (make-variable-buffer-local 'mode-line-modified) |
224 | ||
4c43ca07 NR |
225 | (defvar mode-line-remote |
226 | (list (propertize | |
2c5b4e79 | 227 | "%1@" |
38805987 | 228 | 'mouse-face 'mode-line-highlight |
06b60517 | 229 | 'help-echo (purecopy (lambda (window _object _point) |
4c43ca07 | 230 | (format "%s" |
10766e9e | 231 | (with-selected-window window |
2826687d | 232 | (concat |
38805987 DN |
233 | (if (file-remote-p default-directory) |
234 | "Current directory is remote: " | |
235 | "Current directory is local: ") | |
236 | default-directory))))))) | |
5f2c76c6 | 237 | "Mode line construct to indicate a remote buffer.") |
ac549fa5 | 238 | ;;;###autoload |
6dc3311d | 239 | (put 'mode-line-remote 'risky-local-variable t) |
4c43ca07 NR |
240 | (make-variable-buffer-local 'mode-line-remote) |
241 | ||
5f2c76c6 CY |
242 | ;; MSDOS frames have window-system, but want the Fn identification. |
243 | (defun mode-line-frame-control () | |
244 | "Compute mode line construct for frame identification. | |
245 | Value is used for `mode-line-frame-identification', which see." | |
246 | (if (or (null window-system) | |
247 | (eq window-system 'pc)) | |
248 | "-%F " | |
249 | " ")) | |
250 | ||
251 | ;; We need to defer the call to mode-line-frame-control to the time | |
252 | ;; the mode line is actually displayed. | |
253 | (defvar mode-line-frame-identification '(:eval (mode-line-frame-control)) | |
254 | "Mode line construct to describe the current frame.") | |
ac549fa5 | 255 | ;;;###autoload |
5f2c76c6 | 256 | (put 'mode-line-frame-identification 'risky-local-variable t) |
e6188964 | 257 | |
5f2c76c6 CY |
258 | (defvar mode-line-process nil |
259 | "Mode line construct for displaying info on process status. | |
260 | Normally nil in most modes, since there is no process to display.") | |
ac549fa5 | 261 | ;;;###autoload |
5f2c76c6 CY |
262 | (put 'mode-line-process 'risky-local-variable t) |
263 | (make-variable-buffer-local 'mode-line-process) | |
e6188964 | 264 | |
1ec4b7b2 SM |
265 | (defun bindings--define-key (map key item) |
266 | "Make as much as possible of the menus pure." | |
267 | (declare (indent 2)) | |
268 | (define-key map key | |
269 | (cond | |
270 | ((not (consp item)) item) ;Not sure that could be other than a symbol. | |
271 | ;; Keymaps can't be made pure otherwise users can't remove/add elements | |
272 | ;; from/to them any more. | |
273 | ((keymapp item) item) | |
274 | ((stringp (car item)) | |
275 | (if (keymapp (cdr item)) | |
276 | (cons (purecopy (car item)) (cdr item)) | |
277 | (purecopy item))) | |
278 | ((eq 'menu-item (car item)) | |
279 | (if (keymapp (nth 2 item)) | |
280 | `(menu-item ,(purecopy (nth 1 item)) ,(nth 2 item) | |
281 | ,@(purecopy (nthcdr 3 item))) | |
282 | (purecopy item))) | |
283 | (t (message "non-menu-item: %S" item) item)))) | |
284 | ||
03b63ba9 SM |
285 | (defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\ |
286 | Menu of mode operations in the mode line.") | |
287 | ||
6b61353c | 288 | (defvar mode-line-major-mode-keymap |
335028c3 | 289 | (let ((map (make-sparse-keymap))) |
1ec4b7b2 SM |
290 | (bindings--define-key map [mode-line down-mouse-1] |
291 | `(menu-item "Menu Bar" ignore | |
292 | :filter ,(lambda (_) (mouse-menu-major-mode-map)))) | |
335028c3 | 293 | (define-key map [mode-line mouse-2] 'describe-mode) |
03b63ba9 | 294 | (define-key map [mode-line down-mouse-3] mode-line-mode-menu) |
335028c3 | 295 | map) "\ |
8a42b336 JB |
296 | Keymap to display on major mode.") |
297 | ||
6b61353c | 298 | (defvar mode-line-minor-mode-keymap |
335028c3 | 299 | (let ((map (make-sparse-keymap))) |
fe1afc9b | 300 | (define-key map [mode-line down-mouse-1] 'mouse-minor-mode-menu) |
335028c3 | 301 | (define-key map [mode-line mouse-2] 'mode-line-minor-mode-help) |
03b63ba9 SM |
302 | (define-key map [mode-line down-mouse-3] mode-line-mode-menu) |
303 | (define-key map [header-line down-mouse-3] mode-line-mode-menu) | |
335028c3 | 304 | map) "\ |
8a42b336 JB |
305 | Keymap to display on minor modes.") |
306 | ||
5f2c76c6 CY |
307 | (defvar mode-line-modes |
308 | (let ((recursive-edit-help-echo "Recursive edit, type C-M-c to get out")) | |
309 | (list (propertize "%[" 'help-echo recursive-edit-help-echo) | |
310 | "(" | |
311 | `(:propertize ("" mode-name) | |
312 | help-echo "Major mode\n\ | |
313 | mouse-1: Display major mode menu\n\ | |
314 | mouse-2: Show help for major mode\n\ | |
315 | mouse-3: Toggle minor modes" | |
316 | mouse-face mode-line-highlight | |
317 | local-map ,mode-line-major-mode-keymap) | |
318 | '("" mode-line-process) | |
319 | `(:propertize ("" minor-mode-alist) | |
320 | mouse-face mode-line-highlight | |
321 | help-echo "Minor mode\n\ | |
322 | mouse-1: Display minor mode menu\n\ | |
323 | mouse-2: Show help for minor mode\n\ | |
324 | mouse-3: Toggle minor modes" | |
325 | local-map ,mode-line-minor-mode-keymap) | |
383f7350 | 326 | (propertize "%n" 'help-echo "mouse-2: Remove narrowing from buffer" |
5f2c76c6 CY |
327 | 'mouse-face 'mode-line-highlight |
328 | 'local-map (make-mode-line-mouse-map | |
329 | 'mouse-2 #'mode-line-widen)) | |
330 | ")" | |
331 | (propertize "%]" 'help-echo recursive-edit-help-echo) | |
332 | " ")) | |
333 | "Mode line construct for displaying major and minor modes.") | |
334 | (put 'mode-line-modes 'risky-local-variable t) | |
335 | ||
10a55ba0 DN |
336 | (defvar mode-line-column-line-number-mode-map |
337 | (let ((map (make-sparse-keymap)) | |
338 | (menu-map (make-sparse-keymap "Toggle Line and Column Number Display"))) | |
1ec4b7b2 SM |
339 | (bindings--define-key menu-map [line-number-mode] |
340 | '(menu-item "Display Line Numbers" line-number-mode | |
341 | :help "Toggle displaying line numbers in the mode-line" | |
10a55ba0 | 342 | :button (:toggle . line-number-mode))) |
1ec4b7b2 SM |
343 | (bindings--define-key menu-map [column-number-mode] |
344 | '(menu-item "Display Column Numbers" column-number-mode | |
345 | :help "Toggle displaying column numbers in the mode-line" | |
10a55ba0 DN |
346 | :button (:toggle . column-number-mode))) |
347 | (define-key map [mode-line down-mouse-1] menu-map) | |
348 | map) "\ | |
349 | Keymap to display on column and line numbers.") | |
350 | ||
5f2c76c6 CY |
351 | (defvar mode-line-position |
352 | `((-3 ,(propertize | |
353 | "%p" | |
354 | 'local-map mode-line-column-line-number-mode-map | |
355 | 'mouse-face 'mode-line-highlight | |
356 | ;; XXX needs better description | |
357 | 'help-echo "Size indication mode\n\ | |
10a55ba0 | 358 | mouse-1: Display Line and Column Mode Menu")) |
5f2c76c6 CY |
359 | (size-indication-mode |
360 | (8 ,(propertize | |
361 | " of %I" | |
362 | 'local-map mode-line-column-line-number-mode-map | |
363 | 'mouse-face 'mode-line-highlight | |
364 | ;; XXX needs better description | |
365 | 'help-echo "Size indication mode\n\ | |
10a55ba0 | 366 | mouse-1: Display Line and Column Mode Menu"))) |
5f2c76c6 CY |
367 | (line-number-mode |
368 | ((column-number-mode | |
369 | (10 ,(propertize | |
370 | " (%l,%c)" | |
371 | 'local-map mode-line-column-line-number-mode-map | |
372 | 'mouse-face 'mode-line-highlight | |
373 | 'help-echo "Line number and Column number\n\ | |
10a55ba0 | 374 | mouse-1: Display Line and Column Mode Menu")) |
5f2c76c6 CY |
375 | (6 ,(propertize |
376 | " L%l" | |
377 | 'local-map mode-line-column-line-number-mode-map | |
378 | 'mouse-face 'mode-line-highlight | |
379 | 'help-echo "Line Number\n\ | |
10a55ba0 | 380 | mouse-1: Display Line and Column Mode Menu")))) |
5f2c76c6 CY |
381 | ((column-number-mode |
382 | (5 ,(propertize | |
383 | " C%c" | |
384 | 'local-map mode-line-column-line-number-mode-map | |
385 | 'mouse-face 'mode-line-highlight | |
386 | 'help-echo "Column number\n\ | |
387 | mouse-1: Display Line and Column Mode Menu")))))) | |
388 | "Mode line construct for displaying the position in the buffer. | |
389 | Normally displays the buffer percentage and, optionally, the | |
390 | buffer size, the line number and the column number.") | |
391 | (put 'mode-line-position 'risky-local-variable t) | |
4d120e8c | 392 | |
a8b7149d SM |
393 | (defvar mode-line-buffer-identification-keymap |
394 | ;; Add menu of buffer operations to the buffer identification part | |
395 | ;; of the mode line.or header line. | |
396 | (let ((map (make-sparse-keymap))) | |
397 | ;; Bind down- events so that the global keymap won't ``shine | |
398 | ;; through''. | |
399 | (define-key map [mode-line mouse-1] 'mode-line-previous-buffer) | |
400 | (define-key map [header-line down-mouse-1] 'ignore) | |
401 | (define-key map [header-line mouse-1] 'mode-line-previous-buffer) | |
a8b7149d SM |
402 | (define-key map [mode-line mouse-3] 'mode-line-next-buffer) |
403 | (define-key map [header-line down-mouse-3] 'ignore) | |
404 | (define-key map [header-line mouse-3] 'mode-line-next-buffer) | |
405 | map) "\ | |
688953b5 | 406 | Keymap for what is displayed by `mode-line-buffer-identification'.") |
b1dcba7b | 407 | |
3bd80f8b RS |
408 | (defun propertized-buffer-identification (fmt) |
409 | "Return a list suitable for `mode-line-buffer-identification'. | |
410 | FMT is a format specifier such as \"%12b\". This function adds | |
411 | text properties for face, help-echo, and local-map to it." | |
e0fcce78 | 412 | (list (propertize fmt |
3bd80f8b RS |
413 | 'face 'mode-line-buffer-id |
414 | 'help-echo | |
383f7350 CY |
415 | (purecopy "Buffer name |
416 | mouse-1: Previous buffer\nmouse-3: Next buffer") | |
3bd80f8b RS |
417 | 'mouse-face 'mode-line-highlight |
418 | 'local-map mode-line-buffer-identification-keymap))) | |
419 | ||
5f2c76c6 CY |
420 | (defvar mode-line-buffer-identification |
421 | (propertized-buffer-identification "%12b") | |
422 | "Mode line construct for identifying the buffer being displayed. | |
3bd80f8b RS |
423 | Its default value is (\"%12b\") with some text properties added. |
424 | Major modes that edit things other than ordinary files may change this | |
425 | \(e.g. Info, Dired,...)") | |
ac549fa5 | 426 | ;;;###autoload |
6dc3311d | 427 | (put 'mode-line-buffer-identification 'risky-local-variable t) |
3bd80f8b RS |
428 | (make-variable-buffer-local 'mode-line-buffer-identification) |
429 | ||
5f2c76c6 CY |
430 | (defvar mode-line-misc-info |
431 | '((which-func-mode ("" which-func-format " ")) | |
432 | (global-mode-string ("" global-mode-string " "))) | |
433 | "Mode line construct for miscellaneous information. | |
434 | By default, this shows the information specified by | |
435 | `which-func-mode' and `global-mode-string'.") | |
436 | (put 'mode-line-misc-info 'risky-local-variable t) | |
437 | ||
438 | (defvar mode-line-end-spaces '(:eval (unless (display-graphic-p) "-%-")) | |
439 | "Mode line construct to put at the end of the mode line.") | |
440 | (put 'mode-line-end-spaces 'risky-local-variable t) | |
441 | ||
442 | ;; Default value of the top-level `mode-line-format' variable: | |
443 | (let ((standard-mode-line-format | |
444 | (list "%e" | |
445 | 'mode-line-front-space | |
446 | 'mode-line-mule-info | |
447 | 'mode-line-client | |
448 | 'mode-line-modified | |
449 | 'mode-line-remote | |
450 | 'mode-line-frame-identification | |
451 | 'mode-line-buffer-identification | |
452 | " " | |
453 | 'mode-line-position | |
454 | '(vc-mode vc-mode) | |
455 | " " | |
456 | 'mode-line-modes | |
457 | 'mode-line-misc-info | |
458 | 'mode-line-end-spaces))) | |
459 | (setq-default mode-line-format standard-mode-line-format) | |
460 | (put 'mode-line-format 'standard-value | |
461 | (list `(quote ,standard-mode-line-format)))) | |
462 | ||
463 | \f | |
22b50772 | 464 | (defun mode-line-unbury-buffer (event) "\ |
545f7310 | 465 | Call `unbury-buffer' in this window." |
22b50772 | 466 | (interactive "e") |
10766e9e | 467 | (with-selected-window (posn-window (event-start event)) |
545f7310 | 468 | (unbury-buffer))) |
22b50772 GM |
469 | |
470 | (defun mode-line-bury-buffer (event) "\ | |
c85ee897 | 471 | Like `bury-buffer', but temporarily select EVENT's window." |
22b50772 | 472 | (interactive "e") |
10766e9e | 473 | (with-selected-window (posn-window (event-start event)) |
22b50772 | 474 | (bury-buffer))) |
b1dcba7b | 475 | |
688953b5 DL |
476 | (defun mode-line-other-buffer () "\ |
477 | Switch to the most recently selected buffer other than the current one." | |
b1dcba7b | 478 | (interactive) |
8bdfa064 | 479 | (switch-to-buffer (other-buffer) nil t)) |
b1dcba7b | 480 | |
4ec983f1 JL |
481 | (defun mode-line-next-buffer (event) |
482 | "Like `next-buffer', but temporarily select EVENT's window." | |
483 | (interactive "e") | |
10766e9e | 484 | (with-selected-window (posn-window (event-start event)) |
4ec983f1 JL |
485 | (next-buffer))) |
486 | ||
487 | (defun mode-line-previous-buffer (event) | |
488 | "Like `previous-buffer', but temporarily select EVENT's window." | |
489 | (interactive "e") | |
10766e9e | 490 | (with-selected-window (posn-window (event-start event)) |
4ec983f1 JL |
491 | (previous-buffer))) |
492 | ||
842d2ee9 DL |
493 | (defmacro bound-and-true-p (var) |
494 | "Return the value of symbol VAR if it is bound, else nil." | |
ff69e012 | 495 | `(and (boundp (quote ,var)) ,var)) |
842d2ee9 | 496 | |
5400586c NR |
497 | ;; Use mode-line-mode-menu for local minor-modes only. |
498 | ;; Global ones can go on the menubar (Options --> Show/Hide). | |
1ec4b7b2 SM |
499 | (bindings--define-key mode-line-mode-menu [overwrite-mode] |
500 | '(menu-item "Overwrite (Ovwrt)" overwrite-mode | |
501 | :help "Overwrite mode: typed characters replace existing text" | |
dfdabcf9 | 502 | :button (:toggle . overwrite-mode))) |
1ec4b7b2 SM |
503 | (bindings--define-key mode-line-mode-menu [outline-minor-mode] |
504 | '(menu-item "Outline (Outl)" outline-minor-mode | |
40fabc71 | 505 | ;; XXX: This needs a good, brief description. |
1ec4b7b2 | 506 | :help "" |
2a5405b6 | 507 | :button (:toggle . (bound-and-true-p outline-minor-mode)))) |
1ec4b7b2 SM |
508 | (bindings--define-key mode-line-mode-menu [highlight-changes-mode] |
509 | '(menu-item "Highlight changes (Chg)" highlight-changes-mode | |
510 | :help "Show changes in the buffer in a distinctive color" | |
6455508d | 511 | :button (:toggle . (bound-and-true-p highlight-changes-mode)))) |
1ec4b7b2 SM |
512 | (bindings--define-key mode-line-mode-menu [hide-ifdef-mode] |
513 | '(menu-item "Hide ifdef (Ifdef)" hide-ifdef-mode | |
514 | :help "Show/Hide code within #ifdef constructs" | |
2a5405b6 | 515 | :button (:toggle . (bound-and-true-p hide-ifdef-mode)))) |
1ec4b7b2 SM |
516 | (bindings--define-key mode-line-mode-menu [glasses-mode] |
517 | '(menu-item "Glasses (o^o)" glasses-mode | |
518 | :help "Insert virtual separators to make long identifiers easy to read" | |
c29a05c8 | 519 | :button (:toggle . (bound-and-true-p glasses-mode)))) |
1ec4b7b2 SM |
520 | (bindings--define-key mode-line-mode-menu [font-lock-mode] |
521 | '(menu-item "Font Lock" font-lock-mode | |
522 | :help "Syntax coloring" | |
2a5405b6 | 523 | :button (:toggle . font-lock-mode))) |
1ec4b7b2 SM |
524 | (bindings--define-key mode-line-mode-menu [flyspell-mode] |
525 | '(menu-item "Flyspell (Fly)" flyspell-mode | |
526 | :help "Spell checking on the fly" | |
2a5405b6 | 527 | :button (:toggle . (bound-and-true-p flyspell-mode)))) |
1ec4b7b2 SM |
528 | (bindings--define-key mode-line-mode-menu [auto-revert-tail-mode] |
529 | '(menu-item "Auto revert tail (Tail)" auto-revert-tail-mode | |
530 | :help "Revert the tail of the buffer when buffer grows" | |
9f37aef4 | 531 | :enable (buffer-file-name) |
6455508d | 532 | :button (:toggle . (bound-and-true-p auto-revert-tail-mode)))) |
1ec4b7b2 SM |
533 | (bindings--define-key mode-line-mode-menu [auto-revert-mode] |
534 | '(menu-item "Auto revert (ARev)" auto-revert-mode | |
535 | :help "Revert the buffer when the file on disk changes" | |
6455508d | 536 | :button (:toggle . (bound-and-true-p auto-revert-mode)))) |
1ec4b7b2 SM |
537 | (bindings--define-key mode-line-mode-menu [auto-fill-mode] |
538 | '(menu-item "Auto fill (Fill)" auto-fill-mode | |
539 | :help "Automatically insert new lines" | |
c29a05c8 | 540 | :button (:toggle . auto-fill-function))) |
1ec4b7b2 SM |
541 | (bindings--define-key mode-line-mode-menu [abbrev-mode] |
542 | '(menu-item "Abbrev (Abbrev)" abbrev-mode | |
543 | :help "Automatically expand abbreviations" | |
2a5405b6 | 544 | :button (:toggle . abbrev-mode))) |
dfdabcf9 | 545 | |
8a42b336 | 546 | (defun mode-line-minor-mode-help (event) |
fe1afc9b | 547 | "Describe minor mode for EVENT on minor modes area of the mode line." |
8a42b336 JB |
548 | (interactive "@e") |
549 | (let ((indicator (car (nth 4 (car (cdr event)))))) | |
550 | (describe-minor-mode-from-indicator indicator))) | |
551 | ||
541b8aff GM |
552 | (defvar minor-mode-alist nil "\ |
553 | Alist saying how to show minor modes in the mode line. | |
554 | Each element looks like (VARIABLE STRING); | |
4837b516 | 555 | STRING is included in the mode line if VARIABLE's value is non-nil. |
541b8aff | 556 | |
5f2c76c6 CY |
557 | Actually, STRING need not be a string; any mode-line construct is |
558 | okay. See `mode-line-format'.") | |
ac549fa5 | 559 | ;;;###autoload |
6dc3311d | 560 | (put 'minor-mode-alist 'risky-local-variable t) |
541b8aff GM |
561 | ;; Don't use purecopy here--some people want to change these strings. |
562 | (setq minor-mode-alist | |
0b2b62ff SM |
563 | '((abbrev-mode " Abbrev") |
564 | (overwrite-mode overwrite-mode) | |
565 | (auto-fill-function " Fill") | |
566 | ;; not really a minor mode... | |
567 | (defining-kbd-macro " Def"))) | |
541b8aff | 568 | |
4d120e8c RS |
569 | ;; These variables are used by autoloadable packages. |
570 | ;; They are defined here so that they do not get overridden | |
571 | ;; by the loading of those packages. | |
572 | ||
573 | ;; Names in directory that end in one of these | |
574 | ;; are ignored in completion, | |
575 | ;; making it more likely you will get a unique match. | |
576 | (setq completion-ignored-extensions | |
d34c1b05 | 577 | (append |
a12ca054 | 578 | (cond ((memq system-type '(ms-dos windows-nt)) |
a7610c52 | 579 | (mapcar 'purecopy |
a12ca054 | 580 | '(".o" "~" ".bin" ".bak" ".obj" ".map" ".ico" ".pif" ".lnk" |
a7610c52 | 581 | ".a" ".ln" ".blg" ".bbl" ".dll" ".drv" ".vxd" ".386"))) |
d34c1b05 | 582 | (t |
a7610c52 | 583 | (mapcar 'purecopy |
a12ca054 | 584 | '(".o" "~" ".bin" ".lbin" ".so" |
a7610c52 DN |
585 | ".a" ".ln" ".blg" ".bbl")))) |
586 | (mapcar 'purecopy | |
d34c1b05 RS |
587 | '(".elc" ".lof" |
588 | ".glo" ".idx" ".lot" | |
bcca751d JB |
589 | ;; VCS metadata directories |
590 | ".svn/" ".hg/" ".git/" ".bzr/" "CVS/" "_darcs/" "_MTN/" | |
d34c1b05 | 591 | ;; TeX-related |
640602f7 | 592 | ".fmt" ".tfm" |
c79e04d8 RS |
593 | ;; Java compiled |
594 | ".class" | |
7ed93890 SS |
595 | ;; CLISP |
596 | ".fas" ".lib" ".mem" | |
c79e04d8 | 597 | ;; CMUCL |
ff69e012 | 598 | ".x86f" ".sparcf" |
b6c78ef2 JB |
599 | ;; OpenMCL / Clozure CL |
600 | ".dfsl" ".pfsl" ".d64fsl" ".p64fsl" ".lx64fsl" ".lx32fsl" | |
601 | ".dx64fsl" ".dx32fsl" ".fx64fsl" ".fx32fsl" ".sx64fsl" | |
602 | ".sx32fsl" ".wx64fsl" ".wx32fsl" | |
603 | ;; Other CL implementations (Allegro, LispWorks) | |
604 | ".fasl" ".ufsl" ".fsl" ".dxl" | |
f7e1a28d GM |
605 | ;; Libtool |
606 | ".lo" ".la" | |
008c915c RS |
607 | ;; Gettext |
608 | ".gmo" ".mo" | |
d34c1b05 | 609 | ;; Texinfo-related |
6b61353c KH |
610 | ;; This used to contain .log, but that's commonly used for log |
611 | ;; files you do want to see, not just TeX stuff. -- fx | |
612 | ".toc" ".aux" | |
d34c1b05 | 613 | ".cp" ".fn" ".ky" ".pg" ".tp" ".vr" |
7c226e40 EZ |
614 | ".cps" ".fns" ".kys" ".pgs" ".tps" ".vrs" |
615 | ;; Python byte-compiled | |
a7610c52 | 616 | ".pyc" ".pyo")))) |
4d120e8c | 617 | |
ae95a95a SM |
618 | ;; Suffixes used for executables. |
619 | (setq exec-suffixes | |
620 | (cond | |
621 | ((memq system-type '(ms-dos windows-nt)) | |
622 | '(".exe" ".com" ".bat" ".cmd" ".btm" "")) | |
623 | (t | |
624 | '("")))) | |
625 | ||
2b4b2add DL |
626 | ;; Packages should add to this list appropriately when they are |
627 | ;; loaded, rather than listing everything here. | |
4d120e8c | 628 | (setq debug-ignored-errors |
71873e2b SM |
629 | ;; FIXME: Maybe beginning-of-line, beginning-of-buffer, end-of-line, |
630 | ;; end-of-buffer, end-of-file, buffer-read-only, and | |
631 | ;; file-supersession should all be user-errors! | |
a7610c52 | 632 | `(beginning-of-line beginning-of-buffer end-of-line |
4d120e8c | 633 | end-of-buffer end-of-file buffer-read-only |
c79e04d8 | 634 | file-supersession |
71873e2b | 635 | user-error ;; That's the main one! |
cd8d6674 | 636 | )) |
4d120e8c | 637 | |
4d120e8c RS |
638 | (make-variable-buffer-local 'indent-tabs-mode) |
639 | ||
dea31bd3 CY |
640 | ;; These per-buffer variables are never reset by |
641 | ;; `kill-all-local-variables', because they have no default value. | |
642 | ;; For consistency, we give them the `permanent-local' property, even | |
643 | ;; though `kill-all-local-variables' does not actually consult it. | |
644 | ||
80185fed JB |
645 | (mapc (lambda (sym) (put sym 'permanent-local t)) |
646 | '(buffer-file-name default-directory buffer-backed-up | |
647 | buffer-saved-size buffer-auto-save-file-name | |
648 | buffer-read-only buffer-undo-list mark-active | |
649 | point-before-scroll buffer-file-truename | |
650 | buffer-file-format buffer-auto-save-file-format | |
651 | buffer-display-count buffer-display-time | |
652 | enable-multibyte-characters)) | |
dea31bd3 | 653 | |
e1b90ef6 | 654 | ;; We have base64, md5 and sha1 functions built in now. |
d1bf2a73 SM |
655 | (provide 'base64) |
656 | (provide 'md5) | |
e1b90ef6 | 657 | (provide 'sha1) |
d1bf2a73 SM |
658 | (provide 'overlay '(display syntax-table field)) |
659 | (provide 'text-properties '(display syntax-table field point-entered)) | |
acafa9cf | 660 | |
0094907b RS |
661 | (define-key esc-map "\t" 'complete-symbol) |
662 | ||
67027b49 SM |
663 | (defun complete-symbol (arg) |
664 | "Perform completion on the text around point. | |
665 | The completion method is determined by `completion-at-point-functions'. | |
666 | ||
667 | With a prefix argument, this command does completion within | |
668 | the collection of symbols listed in the index of the manual for the | |
669 | language you are using." | |
670 | (interactive "P") | |
671 | (if arg (info-complete-symbol) (completion-at-point))) | |
672 | ||
4d120e8c RS |
673 | ;; Reduce total amount of space we must allocate during this function |
674 | ;; that we will not need to keep permanently. | |
675 | (garbage-collect) | |
676 | \f | |
3607b64d | 677 | |
29f47822 | 678 | (setq help-event-list '(help f1 ?\?)) |
4d120e8c | 679 | |
97710114 RS |
680 | (make-variable-buffer-local 'minor-mode-overriding-map-alist) |
681 | ||
d1bf2a73 SM |
682 | ;; From frame.c |
683 | (global-set-key [switch-frame] 'handle-switch-frame) | |
b6cb37ae SM |
684 | (global-set-key [select-window] 'handle-select-window) |
685 | ||
686 | ;; FIXME: Do those 3 events really ever reach the global-map ? | |
687 | ;; It seems that they can't because they're handled via | |
688 | ;; special-event-map which is used at very low-level. -stef | |
d1bf2a73 SM |
689 | (global-set-key [delete-frame] 'handle-delete-frame) |
690 | (global-set-key [iconify-frame] 'ignore-event) | |
691 | (global-set-key [make-frame-visible] 'ignore-event) | |
692 | ||
693 | ||
4d120e8c RS |
694 | ;These commands are defined in editfns.c |
695 | ;but they are not assigned to keys there. | |
696 | (put 'narrow-to-region 'disabled t) | |
d455ee85 | 697 | |
db5dce9d | 698 | ;; Moving with arrows in bidi-sensitive direction. |
4c672a0f EZ |
699 | (defcustom visual-order-cursor-movement nil |
700 | "If non-nil, moving cursor with arrow keys follows the visual order. | |
701 | ||
702 | When this is non-nil, \\[right-char] will move to the character that is | |
703 | to the right of point on display, and \\[left-char] will move to the left, | |
704 | disregarding the surrounding bidirectional context. Depending on the | |
705 | bidirectional context of the surrounding characters, this can move point | |
706 | many buffer positions away. | |
707 | ||
708 | When the text is entirely left-to-right, logical-order and visual-order | |
709 | cursor movements produce identical results." | |
710 | :type '(choice (const :tag "Logical-order cursor movement" nil) | |
711 | (const :tag "Visual-order cursor movement" t)) | |
712 | :group 'display | |
713 | :version "24.5") | |
714 | ||
db5dce9d EZ |
715 | (defun right-char (&optional n) |
716 | "Move point N characters to the right (to the left if N is negative). | |
717 | On reaching beginning or end of buffer, stop and signal error. | |
718 | ||
4c672a0f EZ |
719 | If `visual-order-cursor-movement' is non-nil, this always moves |
720 | to the right on display, wherever that is in the buffer. | |
721 | Otherwise, depending on the bidirectional context, this may move | |
722 | one position either forward or backward in the buffer. This is | |
723 | in contrast with \\[forward-char] and \\[backward-char], which | |
724 | see." | |
db5dce9d | 725 | (interactive "^p") |
4c672a0f EZ |
726 | (if visual-order-cursor-movement |
727 | (dotimes (i (if (numberp n) (abs n) 1)) | |
0ba54312 | 728 | (move-point-visually (if (and (numberp n) (< n 0)) -1 1))) |
4c672a0f EZ |
729 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) |
730 | (forward-char n) | |
731 | (backward-char n)))) | |
db5dce9d EZ |
732 | |
733 | (defun left-char ( &optional n) | |
734 | "Move point N characters to the left (to the right if N is negative). | |
735 | On reaching beginning or end of buffer, stop and signal error. | |
736 | ||
4c672a0f EZ |
737 | If `visual-order-cursor-movement' is non-nil, this always moves |
738 | to the left on display, wherever that is in the buffer. | |
739 | Otherwise, depending on the bidirectional context, this may move | |
740 | one position either backward or forward in the buffer. This is | |
741 | in contrast with \\[forward-char] and \\[backward-char], which | |
742 | see." | |
db5dce9d | 743 | (interactive "^p") |
4c672a0f EZ |
744 | (if visual-order-cursor-movement |
745 | (dotimes (i (if (numberp n) (abs n) 1)) | |
0ba54312 | 746 | (move-point-visually (if (and (numberp n) (< n 0)) 1 -1))) |
4c672a0f EZ |
747 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) |
748 | (backward-char n) | |
749 | (forward-char n)))) | |
db5dce9d EZ |
750 | |
751 | (defun right-word (&optional n) | |
752 | "Move point N words to the right (to the left if N is negative). | |
753 | ||
754 | Depending on the bidirectional context, this may move either forward | |
755 | or backward in the buffer. This is in contrast with \\[forward-word] | |
756 | and \\[backward-word], which see. | |
757 | ||
758 | Value is normally t. | |
759 | If an edge of the buffer or a field boundary is reached, point is left there | |
760 | there and the function returns nil. Field boundaries are not noticed | |
761 | if `inhibit-field-text-motion' is non-nil." | |
762 | (interactive "^p") | |
763 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | |
764 | (forward-word n) | |
765 | (backward-word n))) | |
766 | ||
767 | (defun left-word (&optional n) | |
768 | "Move point N words to the left (to the right if N is negative). | |
769 | ||
770 | Depending on the bidirectional context, this may move either backward | |
771 | or forward in the buffer. This is in contrast with \\[backward-word] | |
772 | and \\[forward-word], which see. | |
773 | ||
774 | Value is normally t. | |
775 | If an edge of the buffer or a field boundary is reached, point is left there | |
776 | there and the function returns nil. Field boundaries are not noticed | |
777 | if `inhibit-field-text-motion' is non-nil." | |
778 | (interactive "^p") | |
779 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | |
780 | (backward-word n) | |
781 | (forward-word n))) | |
782 | ||
d455ee85 JL |
783 | (defvar narrow-map (make-sparse-keymap) |
784 | "Keymap for narrowing commands.") | |
785 | (define-key ctl-x-map "n" narrow-map) | |
786 | ||
787 | (define-key narrow-map "n" 'narrow-to-region) | |
788 | (define-key narrow-map "w" 'widen) | |
4d120e8c | 789 | |
ad1cc346 KS |
790 | ;; Quitting |
791 | (define-key global-map "\e\e\e" 'keyboard-escape-quit) | |
792 | (define-key global-map "\C-g" 'keyboard-quit) | |
793 | ||
d3615887 SM |
794 | ;; Used to be in termdev.el: when using several terminals, make C-z |
795 | ;; suspend only the relevant terminal. | |
796 | (substitute-key-definition 'suspend-emacs 'suspend-frame global-map) | |
797 | ||
4d120e8c RS |
798 | (define-key global-map "\C-j" 'newline-and-indent) |
799 | (define-key global-map "\C-m" 'newline) | |
800 | (define-key global-map "\C-o" 'open-line) | |
801 | (define-key esc-map "\C-o" 'split-line) | |
802 | (define-key global-map "\C-q" 'quoted-insert) | |
803 | (define-key esc-map "^" 'delete-indentation) | |
804 | (define-key esc-map "\\" 'delete-horizontal-space) | |
805 | (define-key esc-map "m" 'back-to-indentation) | |
806 | (define-key ctl-x-map "\C-o" 'delete-blank-lines) | |
807 | (define-key esc-map " " 'just-one-space) | |
808 | (define-key esc-map "z" 'zap-to-char) | |
e1293765 | 809 | (define-key esc-map "=" 'count-words-region) |
4d120e8c RS |
810 | (define-key ctl-x-map "=" 'what-cursor-position) |
811 | (define-key esc-map ":" 'eval-expression) | |
812 | ;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit. | |
813 | (define-key esc-map "\M-:" 'eval-expression) | |
814 | ;; Changed from C-x ESC so that function keys work following C-x. | |
815 | (define-key ctl-x-map "\e\e" 'repeat-complex-command) | |
816 | ;; New binding analogous to M-:. | |
817 | (define-key ctl-x-map "\M-:" 'repeat-complex-command) | |
8cb95edf SM |
818 | (define-key ctl-x-map "u" 'undo) |
819 | (put 'undo :advertised-binding [?\C-x ?u]) | |
4d120e8c RS |
820 | ;; Many people are used to typing C-/ on X terminals and getting C-_. |
821 | (define-key global-map [?\C-/] 'undo) | |
822 | (define-key global-map "\C-_" 'undo) | |
ad1cc346 KS |
823 | ;; Richard said that we should not use C-x <uppercase letter> and I have |
824 | ;; no idea whereas to bind it. Any suggestion welcome. -stef | |
825 | ;; (define-key ctl-x-map "U" 'undo-only) | |
826 | ||
4d120e8c RS |
827 | (define-key esc-map "!" 'shell-command) |
828 | (define-key esc-map "|" 'shell-command-on-region) | |
6f2d8b35 | 829 | (define-key esc-map "&" 'async-shell-command) |
4d120e8c | 830 | |
d455ee85 JL |
831 | (define-key ctl-x-map [right] 'next-buffer) |
832 | (define-key ctl-x-map [C-right] 'next-buffer) | |
3d10db47 | 833 | (define-key global-map [XF86Forward] 'next-buffer) |
d455ee85 JL |
834 | (define-key ctl-x-map [left] 'previous-buffer) |
835 | (define-key ctl-x-map [C-left] 'previous-buffer) | |
3d10db47 | 836 | (define-key global-map [XF86Back] 'previous-buffer) |
ad1cc346 | 837 | |
a77dfeb0 SM |
838 | (let ((map minibuffer-local-map)) |
839 | (define-key map "\en" 'next-history-element) | |
840 | (define-key map [next] 'next-history-element) | |
841 | (define-key map [down] 'next-history-element) | |
3d10db47 | 842 | (define-key map [XF86Forward] 'next-history-element) |
a77dfeb0 SM |
843 | (define-key map "\ep" 'previous-history-element) |
844 | (define-key map [prior] 'previous-history-element) | |
845 | (define-key map [up] 'previous-history-element) | |
3d10db47 | 846 | (define-key map [XF86Back] 'previous-history-element) |
a77dfeb0 | 847 | (define-key map "\es" 'next-matching-history-element) |
b0c24554 SM |
848 | (define-key map "\er" 'previous-matching-history-element) |
849 | ;; Override the global binding (which calls indent-relative via | |
850 | ;; indent-for-tab-command). The alignment that indent-relative tries to | |
851 | ;; do doesn't make much sense here since the prompt messes it up. | |
2d914448 | 852 | (define-key map "\t" 'self-insert-command) |
77e0c5b6 | 853 | (define-key map [C-tab] 'file-cache-minibuffer-complete)) |
4d120e8c RS |
854 | |
855 | (define-key global-map "\C-u" 'universal-argument) | |
856 | (let ((i ?0)) | |
857 | (while (<= i ?9) | |
858 | (define-key esc-map (char-to-string i) 'digit-argument) | |
859 | (setq i (1+ i)))) | |
860 | (define-key esc-map "-" 'negative-argument) | |
861 | ;; Define control-digits. | |
862 | (let ((i ?0)) | |
863 | (while (<= i ?9) | |
864 | (define-key global-map (read (format "[?\\C-%c]" i)) 'digit-argument) | |
865 | (setq i (1+ i)))) | |
866 | (define-key global-map [?\C--] 'negative-argument) | |
867 | ;; Define control-meta-digits. | |
868 | (let ((i ?0)) | |
869 | (while (<= i ?9) | |
870 | (define-key esc-map (read (format "[?\\C-%c]" i)) 'digit-argument) | |
871 | (setq i (1+ i)))) | |
872 | (define-key global-map [?\C-\M--] 'negative-argument) | |
873 | ||
59ee0542 | 874 | ;; Update tutorial--default-keys if you change these. |
b9229673 | 875 | (define-key global-map "\177" 'delete-backward-char) |
b8a47412 | 876 | (define-key global-map "\C-d" 'delete-char) |
b9229673 | 877 | |
4d120e8c RS |
878 | (define-key global-map "\C-k" 'kill-line) |
879 | (define-key global-map "\C-w" 'kill-region) | |
880 | (define-key esc-map "w" 'kill-ring-save) | |
881 | (define-key esc-map "\C-w" 'append-next-kill) | |
882 | (define-key global-map "\C-y" 'yank) | |
883 | (define-key esc-map "y" 'yank-pop) | |
884 | ||
885 | ;; (define-key ctl-x-map "a" 'append-to-buffer) | |
886 | ||
887 | (define-key global-map "\C-@" 'set-mark-command) | |
888 | ;; Many people are used to typing C-SPC and getting C-@. | |
e68e61b5 | 889 | (define-key global-map [?\C- ] 'set-mark-command) |
27fa387a CY |
890 | (put 'set-mark-command :advertised-binding [?\C- ]) |
891 | ||
4d120e8c RS |
892 | (define-key ctl-x-map "\C-x" 'exchange-point-and-mark) |
893 | (define-key ctl-x-map "\C-@" 'pop-global-mark) | |
e68e61b5 | 894 | (define-key ctl-x-map [?\C- ] 'pop-global-mark) |
4d120e8c RS |
895 | |
896 | (define-key global-map "\C-n" 'next-line) | |
897 | (define-key global-map "\C-p" 'previous-line) | |
898 | (define-key ctl-x-map "\C-n" 'set-goal-column) | |
d17a638d | 899 | (define-key global-map "\C-a" 'move-beginning-of-line) |
c77ddea7 | 900 | (define-key global-map "\C-e" 'move-end-of-line) |
4d120e8c | 901 | |
ad1cc346 KS |
902 | (define-key ctl-x-map "`" 'next-error) |
903 | ||
56d62ee1 JL |
904 | (defvar goto-map (make-sparse-keymap) |
905 | "Keymap for navigation commands.") | |
906 | (define-key esc-map "g" goto-map) | |
907 | ||
5dd1713e | 908 | (define-key goto-map "c" 'goto-char) |
56d62ee1 JL |
909 | (define-key goto-map "g" 'goto-line) |
910 | (define-key goto-map "\M-g" 'goto-line) | |
911 | (define-key goto-map "n" 'next-error) | |
912 | (define-key goto-map "\M-n" 'next-error) | |
913 | (define-key goto-map "p" 'previous-error) | |
914 | (define-key goto-map "\M-p" 'previous-error) | |
d39d3c8e | 915 | (define-key goto-map "\t" 'move-to-column) |
56d62ee1 JL |
916 | |
917 | (defvar search-map (make-sparse-keymap) | |
918 | "Keymap for search related commands.") | |
919 | (define-key esc-map "s" search-map) | |
920 | ||
921 | (define-key search-map "o" 'occur) | |
922 | (define-key search-map "hr" 'highlight-regexp) | |
923 | (define-key search-map "hp" 'highlight-phrase) | |
924 | (define-key search-map "hl" 'highlight-lines-matching-regexp) | |
e5e4a942 | 925 | (define-key search-map "h." 'highlight-symbol-at-point) |
56d62ee1 JL |
926 | (define-key search-map "hu" 'unhighlight-regexp) |
927 | (define-key search-map "hf" 'hi-lock-find-patterns) | |
928 | (define-key search-map "hw" 'hi-lock-write-interactive-patterns) | |
ad1cc346 | 929 | |
4d120e8c RS |
930 | ;;(defun function-key-error () |
931 | ;; (interactive) | |
1cd7adc6 | 932 | ;; (error "That function key is not bound to anything")) |
4d120e8c RS |
933 | |
934 | (define-key global-map [menu] 'execute-extended-command) | |
935 | (define-key global-map [find] 'search-forward) | |
936 | ||
9d4850e5 GM |
937 | ;; Don't do this. We define <delete> in function-key-map instead. |
938 | ;(define-key global-map [delete] 'backward-delete-char) | |
4e4f9651 | 939 | |
4d120e8c | 940 | ;; natural bindings for terminal keycaps --- defined in X keysym order |
d391e05c | 941 | (define-key global-map [C-S-backspace] 'kill-whole-line) |
f88febbb | 942 | (define-key global-map [home] 'move-beginning-of-line) |
1dfca644 | 943 | (define-key global-map [C-home] 'beginning-of-buffer) |
4d120e8c | 944 | (define-key global-map [M-home] 'beginning-of-buffer-other-window) |
480c8cd3 | 945 | (define-key esc-map [home] 'beginning-of-buffer-other-window) |
db5dce9d | 946 | (define-key global-map [left] 'left-char) |
4d120e8c | 947 | (define-key global-map [up] 'previous-line) |
db5dce9d | 948 | (define-key global-map [right] 'right-char) |
4d120e8c | 949 | (define-key global-map [down] 'next-line) |
79ce172a JL |
950 | (define-key global-map [prior] 'scroll-down-command) |
951 | (define-key global-map [next] 'scroll-up-command) | |
4d120e8c RS |
952 | (define-key global-map [C-up] 'backward-paragraph) |
953 | (define-key global-map [C-down] 'forward-paragraph) | |
954 | (define-key global-map [C-prior] 'scroll-right) | |
e980968d | 955 | (put 'scroll-left 'disabled t) |
4d120e8c RS |
956 | (define-key global-map [C-next] 'scroll-left) |
957 | (define-key global-map [M-next] 'scroll-other-window) | |
480c8cd3 | 958 | (define-key esc-map [next] 'scroll-other-window) |
4d120e8c | 959 | (define-key global-map [M-prior] 'scroll-other-window-down) |
480c8cd3 | 960 | (define-key esc-map [prior] 'scroll-other-window-down) |
ad1cc346 | 961 | (define-key esc-map [?\C-\S-v] 'scroll-other-window-down) |
f88febbb | 962 | (define-key global-map [end] 'move-end-of-line) |
1dfca644 | 963 | (define-key global-map [C-end] 'end-of-buffer) |
4d120e8c | 964 | (define-key global-map [M-end] 'end-of-buffer-other-window) |
480c8cd3 | 965 | (define-key esc-map [end] 'end-of-buffer-other-window) |
4d120e8c RS |
966 | (define-key global-map [begin] 'beginning-of-buffer) |
967 | (define-key global-map [M-begin] 'beginning-of-buffer-other-window) | |
480c8cd3 | 968 | (define-key esc-map [begin] 'beginning-of-buffer-other-window) |
4d120e8c RS |
969 | ;; (define-key global-map [select] 'function-key-error) |
970 | ;; (define-key global-map [print] 'function-key-error) | |
971 | (define-key global-map [execute] 'execute-extended-command) | |
972 | (define-key global-map [insert] 'overwrite-mode) | |
973 | (define-key global-map [C-insert] 'kill-ring-save) | |
974 | (define-key global-map [S-insert] 'yank) | |
8d79731e RS |
975 | ;; `insertchar' is what term.c produces. Should we change term.c |
976 | ;; to produce `insert' instead? | |
977 | (define-key global-map [insertchar] 'overwrite-mode) | |
978 | (define-key global-map [C-insertchar] 'kill-ring-save) | |
979 | (define-key global-map [S-insertchar] 'yank) | |
4d120e8c RS |
980 | (define-key global-map [undo] 'undo) |
981 | (define-key global-map [redo] 'repeat-complex-command) | |
6b61353c KH |
982 | (define-key global-map [again] 'repeat-complex-command) ; Sun keyboard |
983 | (define-key global-map [open] 'find-file) ; Sun | |
984 | ;; The following wouldn't work to interrupt running code since C-g is | |
985 | ;; treated specially in the event loop. | |
986 | ;; (define-key global-map [stop] 'keyboard-quit) ; Sun | |
4d120e8c RS |
987 | ;; (define-key global-map [clearline] 'function-key-error) |
988 | (define-key global-map [insertline] 'open-line) | |
989 | (define-key global-map [deleteline] 'kill-line) | |
b8a47412 | 990 | (define-key global-map [deletechar] 'delete-forward-char) |
4d120e8c RS |
991 | ;; (define-key global-map [backtab] 'function-key-error) |
992 | ;; (define-key global-map [f1] 'function-key-error) | |
993 | ;; (define-key global-map [f2] 'function-key-error) | |
994 | ;; (define-key global-map [f3] 'function-key-error) | |
995 | ;; (define-key global-map [f4] 'function-key-error) | |
996 | ;; (define-key global-map [f5] 'function-key-error) | |
997 | ;; (define-key global-map [f6] 'function-key-error) | |
998 | ;; (define-key global-map [f7] 'function-key-error) | |
999 | ;; (define-key global-map [f8] 'function-key-error) | |
1000 | ;; (define-key global-map [f9] 'function-key-error) | |
1001 | ;; (define-key global-map [f10] 'function-key-error) | |
1002 | ;; (define-key global-map [f11] 'function-key-error) | |
1003 | ;; (define-key global-map [f12] 'function-key-error) | |
1004 | ;; (define-key global-map [f13] 'function-key-error) | |
1005 | ;; (define-key global-map [f14] 'function-key-error) | |
1006 | ;; (define-key global-map [f15] 'function-key-error) | |
1007 | ;; (define-key global-map [f16] 'function-key-error) | |
1008 | ;; (define-key global-map [f17] 'function-key-error) | |
1009 | ;; (define-key global-map [f18] 'function-key-error) | |
1010 | ;; (define-key global-map [f19] 'function-key-error) | |
1011 | ;; (define-key global-map [f20] 'function-key-error) | |
1012 | ;; (define-key global-map [f21] 'function-key-error) | |
1013 | ;; (define-key global-map [f22] 'function-key-error) | |
1014 | ;; (define-key global-map [f23] 'function-key-error) | |
1015 | ;; (define-key global-map [f24] 'function-key-error) | |
1016 | ;; (define-key global-map [f25] 'function-key-error) | |
1017 | ;; (define-key global-map [f26] 'function-key-error) | |
1018 | ;; (define-key global-map [f27] 'function-key-error) | |
1019 | ;; (define-key global-map [f28] 'function-key-error) | |
1020 | ;; (define-key global-map [f29] 'function-key-error) | |
1021 | ;; (define-key global-map [f30] 'function-key-error) | |
1022 | ;; (define-key global-map [f31] 'function-key-error) | |
1023 | ;; (define-key global-map [f32] 'function-key-error) | |
1024 | ;; (define-key global-map [f33] 'function-key-error) | |
1025 | ;; (define-key global-map [f34] 'function-key-error) | |
1026 | ;; (define-key global-map [f35] 'function-key-error) | |
1027 | ;; (define-key global-map [kp-backtab] 'function-key-error) | |
1028 | ;; (define-key global-map [kp-space] 'function-key-error) | |
1029 | ;; (define-key global-map [kp-tab] 'function-key-error) | |
1030 | ;; (define-key global-map [kp-enter] 'function-key-error) | |
1031 | ;; (define-key global-map [kp-f1] 'function-key-error) | |
1032 | ;; (define-key global-map [kp-f2] 'function-key-error) | |
1033 | ;; (define-key global-map [kp-f3] 'function-key-error) | |
1034 | ;; (define-key global-map [kp-f4] 'function-key-error) | |
1035 | ;; (define-key global-map [kp-multiply] 'function-key-error) | |
1036 | ;; (define-key global-map [kp-add] 'function-key-error) | |
1037 | ;; (define-key global-map [kp-separator] 'function-key-error) | |
1038 | ;; (define-key global-map [kp-subtract] 'function-key-error) | |
1039 | ;; (define-key global-map [kp-decimal] 'function-key-error) | |
1040 | ;; (define-key global-map [kp-divide] 'function-key-error) | |
1041 | ;; (define-key global-map [kp-0] 'function-key-error) | |
1042 | ;; (define-key global-map [kp-1] 'function-key-error) | |
1043 | ;; (define-key global-map [kp-2] 'function-key-error) | |
1044 | ;; (define-key global-map [kp-3] 'function-key-error) | |
1045 | ;; (define-key global-map [kp-4] 'function-key-error) | |
1046 | ;; (define-key global-map [kp-5] 'recenter) | |
1047 | ;; (define-key global-map [kp-6] 'function-key-error) | |
1048 | ;; (define-key global-map [kp-7] 'function-key-error) | |
1049 | ;; (define-key global-map [kp-8] 'function-key-error) | |
1050 | ;; (define-key global-map [kp-9] 'function-key-error) | |
1051 | ;; (define-key global-map [kp-equal] 'function-key-error) | |
1052 | ||
1053 | ;; X11R6 distinguishes these keys from the non-kp keys. | |
1054 | ;; Make them behave like the non-kp keys unless otherwise bound. | |
554efd10 SM |
1055 | ;; FIXME: rather than list such mappings for every modifier-combination, |
1056 | ;; we should come up with a way to do it generically, something like | |
1057 | ;; (define-key function-key-map [*-kp-home] [*-home]) | |
4d120e8c RS |
1058 | (define-key function-key-map [kp-home] [home]) |
1059 | (define-key function-key-map [kp-left] [left]) | |
1060 | (define-key function-key-map [kp-up] [up]) | |
1061 | (define-key function-key-map [kp-right] [right]) | |
1062 | (define-key function-key-map [kp-down] [down]) | |
1063 | (define-key function-key-map [kp-prior] [prior]) | |
1064 | (define-key function-key-map [kp-next] [next]) | |
1065 | (define-key function-key-map [M-kp-next] [M-next]) | |
1066 | (define-key function-key-map [kp-end] [end]) | |
1067 | (define-key function-key-map [kp-begin] [begin]) | |
1068 | (define-key function-key-map [kp-insert] [insert]) | |
9d4850e5 GM |
1069 | (define-key function-key-map [backspace] [?\C-?]) |
1070 | (define-key function-key-map [delete] [?\C-?]) | |
ee5cece0 | 1071 | (define-key function-key-map [kp-delete] [?\C-?]) |
9761cd3a EZ |
1072 | (define-key function-key-map [S-kp-end] [S-end]) |
1073 | (define-key function-key-map [S-kp-down] [S-down]) | |
1074 | (define-key function-key-map [S-kp-next] [S-next]) | |
1075 | (define-key function-key-map [S-kp-left] [S-left]) | |
1076 | (define-key function-key-map [S-kp-right] [S-right]) | |
1077 | (define-key function-key-map [S-kp-home] [S-home]) | |
1078 | (define-key function-key-map [S-kp-up] [S-up]) | |
1079 | (define-key function-key-map [S-kp-prior] [S-prior]) | |
1080 | (define-key function-key-map [C-S-kp-end] [C-S-end]) | |
1081 | (define-key function-key-map [C-S-kp-down] [C-S-down]) | |
1082 | (define-key function-key-map [C-S-kp-next] [C-S-next]) | |
1083 | (define-key function-key-map [C-S-kp-left] [C-S-left]) | |
1084 | (define-key function-key-map [C-S-kp-right] [C-S-right]) | |
1085 | (define-key function-key-map [C-S-kp-home] [C-S-home]) | |
1086 | (define-key function-key-map [C-S-kp-up] [C-S-up]) | |
1087 | (define-key function-key-map [C-S-kp-prior] [C-S-prior]) | |
7bc60154 EZ |
1088 | ;; Don't bind shifted keypad numeric keys, they reportedly |
1089 | ;; interfere with the feature of some keyboards to produce | |
1090 | ;; numbers when NumLock is off. | |
1091 | ;(define-key function-key-map [S-kp-1] [S-end]) | |
1092 | ;(define-key function-key-map [S-kp-2] [S-down]) | |
1093 | ;(define-key function-key-map [S-kp-3] [S-next]) | |
1094 | ;(define-key function-key-map [S-kp-4] [S-left]) | |
1095 | ;(define-key function-key-map [S-kp-6] [S-right]) | |
1096 | ;(define-key function-key-map [S-kp-7] [S-home]) | |
1097 | ;(define-key function-key-map [S-kp-8] [S-up]) | |
1098 | ;(define-key function-key-map [S-kp-9] [S-prior]) | |
9761cd3a EZ |
1099 | (define-key function-key-map [C-S-kp-1] [C-S-end]) |
1100 | (define-key function-key-map [C-S-kp-2] [C-S-down]) | |
1101 | (define-key function-key-map [C-S-kp-3] [C-S-next]) | |
1102 | (define-key function-key-map [C-S-kp-4] [C-S-left]) | |
1103 | (define-key function-key-map [C-S-kp-6] [C-S-right]) | |
1104 | (define-key function-key-map [C-S-kp-7] [C-S-home]) | |
1105 | (define-key function-key-map [C-S-kp-8] [C-S-up]) | |
1106 | (define-key function-key-map [C-S-kp-9] [C-S-prior]) | |
4d120e8c | 1107 | |
554efd10 SM |
1108 | ;; Hitting C-SPC on text terminals, usually sends the ascii code 0 (aka C-@), |
1109 | ;; so we can't distinguish those two keys, but usually we consider C-SPC | |
1110 | ;; (rather than C-@) as the "canonical" binding. | |
1111 | (define-key function-key-map [?\C-@] [?\C-\s]) | |
a7e26d8b SM |
1112 | ;; Many keyboards don't have a `backtab' key, so by convention the user |
1113 | ;; can use S-tab instead to access that binding. | |
1114 | (define-key function-key-map [S-tab] [backtab]) | |
554efd10 | 1115 | |
4d120e8c RS |
1116 | (define-key global-map [mouse-movement] 'ignore) |
1117 | ||
1118 | (define-key global-map "\C-t" 'transpose-chars) | |
1119 | (define-key esc-map "t" 'transpose-words) | |
1120 | (define-key esc-map "\C-t" 'transpose-sexps) | |
1121 | (define-key ctl-x-map "\C-t" 'transpose-lines) | |
1122 | ||
5589b330 | 1123 | (define-key esc-map ";" 'comment-dwim) |
fedff3c6 SM |
1124 | (define-key esc-map "j" 'indent-new-comment-line) |
1125 | (define-key esc-map "\C-j" 'indent-new-comment-line) | |
5589b330 | 1126 | (define-key ctl-x-map ";" 'comment-set-column) |
4d120e8c RS |
1127 | (define-key ctl-x-map "f" 'set-fill-column) |
1128 | (define-key ctl-x-map "$" 'set-selective-display) | |
1129 | ||
1130 | (define-key esc-map "@" 'mark-word) | |
1131 | (define-key esc-map "f" 'forward-word) | |
1132 | (define-key esc-map "b" 'backward-word) | |
1133 | (define-key esc-map "d" 'kill-word) | |
1134 | (define-key esc-map "\177" 'backward-kill-word) | |
1135 | ||
1136 | (define-key esc-map "<" 'beginning-of-buffer) | |
1137 | (define-key esc-map ">" 'end-of-buffer) | |
1138 | (define-key ctl-x-map "h" 'mark-whole-buffer) | |
1139 | (define-key esc-map "\\" 'delete-horizontal-space) | |
1140 | ||
1141 | (defalias 'mode-specific-command-prefix (make-sparse-keymap)) | |
4b189189 | 1142 | (defvar mode-specific-map (symbol-function 'mode-specific-command-prefix) |
4d120e8c RS |
1143 | "Keymap for characters following C-c.") |
1144 | (define-key global-map "\C-c" 'mode-specific-command-prefix) | |
1145 | ||
c3833279 | 1146 | (global-set-key [M-right] 'right-word) |
480c8cd3 | 1147 | (define-key esc-map [right] 'forward-word) |
c3833279 | 1148 | (global-set-key [M-left] 'left-word) |
480c8cd3 | 1149 | (define-key esc-map [left] 'backward-word) |
4d120e8c | 1150 | ;; ilya@math.ohio-state.edu says these bindings are standard on PC editors. |
db5dce9d EZ |
1151 | (global-set-key [C-right] 'right-word) |
1152 | (global-set-key [C-left] 'left-word) | |
4d120e8c | 1153 | ;; This is not quite compatible, but at least is analogous |
7957d2f5 CY |
1154 | (global-set-key [C-delete] 'kill-word) |
1155 | (global-set-key [C-backspace] 'backward-kill-word) | |
4d120e8c RS |
1156 | ;; This is "move to the clipboard", or as close as we come. |
1157 | (global-set-key [S-delete] 'kill-region) | |
1158 | ||
480c8cd3 AS |
1159 | (global-set-key [C-M-left] 'backward-sexp) |
1160 | (define-key esc-map [C-left] 'backward-sexp) | |
1161 | (global-set-key [C-M-right] 'forward-sexp) | |
1162 | (define-key esc-map [C-right] 'forward-sexp) | |
1163 | (global-set-key [C-M-up] 'backward-up-list) | |
1164 | (define-key esc-map [C-up] 'backward-up-list) | |
1165 | (global-set-key [C-M-down] 'down-list) | |
1166 | (define-key esc-map [C-down] 'down-list) | |
1167 | (global-set-key [C-M-home] 'beginning-of-defun) | |
1168 | (define-key esc-map [C-home] 'beginning-of-defun) | |
1169 | (global-set-key [C-M-end] 'end-of-defun) | |
1170 | (define-key esc-map [C-end] 'end-of-defun) | |
486add9d | 1171 | |
4d120e8c RS |
1172 | (define-key esc-map "\C-f" 'forward-sexp) |
1173 | (define-key esc-map "\C-b" 'backward-sexp) | |
1174 | (define-key esc-map "\C-u" 'backward-up-list) | |
1175 | (define-key esc-map "\C-@" 'mark-sexp) | |
1176 | (define-key esc-map [?\C-\ ] 'mark-sexp) | |
1177 | (define-key esc-map "\C-d" 'down-list) | |
1178 | (define-key esc-map "\C-k" 'kill-sexp) | |
0c3a466c RS |
1179 | ;;; These are dangerous in various situations, |
1180 | ;;; so let's not encourage anyone to use them. | |
1181 | ;;;(define-key global-map [C-M-delete] 'backward-kill-sexp) | |
1182 | ;;;(define-key global-map [C-M-backspace] 'backward-kill-sexp) | |
da7ddbed GM |
1183 | (define-key esc-map [C-delete] 'backward-kill-sexp) |
1184 | (define-key esc-map [C-backspace] 'backward-kill-sexp) | |
4d120e8c RS |
1185 | (define-key esc-map "\C-n" 'forward-list) |
1186 | (define-key esc-map "\C-p" 'backward-list) | |
1187 | (define-key esc-map "\C-a" 'beginning-of-defun) | |
1188 | (define-key esc-map "\C-e" 'end-of-defun) | |
1189 | (define-key esc-map "\C-h" 'mark-defun) | |
1190 | (define-key ctl-x-map "nd" 'narrow-to-defun) | |
1191 | (define-key esc-map "(" 'insert-parentheses) | |
1192 | (define-key esc-map ")" 'move-past-close-and-reindent) | |
4d120e8c RS |
1193 | |
1194 | (define-key ctl-x-map "\C-e" 'eval-last-sexp) | |
6d64bc9f RS |
1195 | |
1196 | (define-key ctl-x-map "m" 'compose-mail) | |
1197 | (define-key ctl-x-4-map "m" 'compose-mail-other-window) | |
1198 | (define-key ctl-x-5-map "m" 'compose-mail-other-frame) | |
4d120e8c | 1199 | \f |
d455ee85 | 1200 | |
be755c79 RT |
1201 | (defvar ctl-x-r-map |
1202 | (let ((map (make-sparse-keymap))) | |
1203 | (define-key map "c" 'clear-rectangle) | |
1204 | (define-key map "k" 'kill-rectangle) | |
1205 | (define-key map "d" 'delete-rectangle) | |
1206 | (define-key map "y" 'yank-rectangle) | |
1207 | (define-key map "o" 'open-rectangle) | |
1208 | (define-key map "t" 'string-rectangle) | |
1209 | (define-key map "N" 'rectangle-number-lines) | |
1210 | (define-key map "\M-w" 'copy-rectangle-as-kill) | |
1211 | (define-key map "\C-@" 'point-to-register) | |
1212 | (define-key map [?\C-\ ] 'point-to-register) | |
1213 | (define-key map " " 'point-to-register) | |
1214 | (define-key map "j" 'jump-to-register) | |
1215 | (define-key map "s" 'copy-to-register) | |
1216 | (define-key map "x" 'copy-to-register) | |
1217 | (define-key map "i" 'insert-register) | |
1218 | (define-key map "g" 'insert-register) | |
1219 | (define-key map "r" 'copy-rectangle-to-register) | |
1220 | (define-key map "n" 'number-to-register) | |
1221 | (define-key map "+" 'increment-register) | |
1222 | (define-key map "w" 'window-configuration-to-register) | |
2805a651 | 1223 | (define-key map "f" 'frameset-to-register) |
be755c79 | 1224 | map) |
d455ee85 JL |
1225 | "Keymap for subcommands of C-x r.") |
1226 | (define-key ctl-x-map "r" ctl-x-r-map) | |
4d120e8c | 1227 | |
792eb719 | 1228 | (define-key esc-map "q" 'fill-paragraph) |
4d120e8c RS |
1229 | (define-key ctl-x-map "." 'set-fill-prefix) |
1230 | \f | |
1231 | (define-key esc-map "{" 'backward-paragraph) | |
1232 | (define-key esc-map "}" 'forward-paragraph) | |
1233 | (define-key esc-map "h" 'mark-paragraph) | |
1234 | (define-key esc-map "a" 'backward-sentence) | |
1235 | (define-key esc-map "e" 'forward-sentence) | |
1236 | (define-key esc-map "k" 'kill-sentence) | |
1237 | (define-key ctl-x-map "\177" 'backward-kill-sentence) | |
1238 | ||
1239 | (define-key ctl-x-map "[" 'backward-page) | |
1240 | (define-key ctl-x-map "]" 'forward-page) | |
1241 | (define-key ctl-x-map "\C-p" 'mark-page) | |
1242 | (define-key ctl-x-map "l" 'count-lines-page) | |
1243 | (define-key ctl-x-map "np" 'narrow-to-page) | |
1244 | ;; (define-key ctl-x-map "p" 'narrow-to-page) | |
1245 | \f | |
d455ee85 JL |
1246 | (defvar abbrev-map (make-sparse-keymap) |
1247 | "Keymap for abbrev commands.") | |
1248 | (define-key ctl-x-map "a" abbrev-map) | |
1249 | ||
1250 | (define-key abbrev-map "l" 'add-mode-abbrev) | |
1251 | (define-key abbrev-map "\C-a" 'add-mode-abbrev) | |
1252 | (define-key abbrev-map "g" 'add-global-abbrev) | |
1253 | (define-key abbrev-map "+" 'add-mode-abbrev) | |
1254 | (define-key abbrev-map "ig" 'inverse-add-global-abbrev) | |
1255 | (define-key abbrev-map "il" 'inverse-add-mode-abbrev) | |
1256 | ;; (define-key abbrev-map "\C-h" 'inverse-add-global-abbrev) | |
1257 | (define-key abbrev-map "-" 'inverse-add-global-abbrev) | |
1258 | (define-key abbrev-map "e" 'expand-abbrev) | |
1259 | (define-key abbrev-map "'" 'expand-abbrev) | |
4d120e8c RS |
1260 | ;; (define-key ctl-x-map "\C-a" 'add-mode-abbrev) |
1261 | ;; (define-key ctl-x-map "\+" 'add-global-abbrev) | |
1262 | ;; (define-key ctl-x-map "\C-h" 'inverse-add-mode-abbrev) | |
1263 | ;; (define-key ctl-x-map "\-" 'inverse-add-global-abbrev) | |
1264 | (define-key esc-map "'" 'abbrev-prefix-mark) | |
1265 | (define-key ctl-x-map "'" 'expand-abbrev) | |
3cc99f68 | 1266 | (define-key ctl-x-map "\C-b" 'list-buffers) |
4d120e8c | 1267 | |
aa5ba90e | 1268 | (define-key ctl-x-map "z" 'repeat) |
e4ade21b | 1269 | |
ef2cfb2e RS |
1270 | (define-key esc-map "\C-l" 'reposition-window) |
1271 | ||
1272 | (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window) | |
ad1cc346 KS |
1273 | (define-key ctl-x-4-map "c" 'clone-indirect-buffer-other-window) |
1274 | ||
56c5808a | 1275 | ;; Signal handlers |
653a9100 KS |
1276 | (define-key special-event-map [sigusr1] 'ignore) |
1277 | (define-key special-event-map [sigusr2] 'ignore) | |
56c5808a | 1278 | |
d1bf2a73 SM |
1279 | ;; Don't look for autoload cookies in this file. |
1280 | ;; Local Variables: | |
1281 | ;; no-update-autoloads: t | |
1282 | ;; End: | |
4d120e8c RS |
1283 | |
1284 | ;;; bindings.el ends here |