*** empty log message ***
[bpt/emacs.git] / lisp / hexl.el
1 ;;; hexl-mode.el --- edit a file in a hex dump format.
2
3 ;; Copyright (C) 1989 Free Software Foundation, Inc.
4
5 ;; This file is part of GNU Emacs.
6
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 1, or (at your option)
10 ;; any later version.
11
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 ;;
22 ;; By: Keith Gabryelski (ag@wheaties.ai.mit.edu)
23 ;;
24 ;; This may be useful in your .emacs:
25 ;;
26 ;; (autoload 'hexl-find-file "hexl"
27 ;; "Edit file FILENAME in hexl-mode." t)
28 ;;
29 ;; (define-key global-map "\C-c\C-h" 'hexl-find-file)
30 ;;
31 ;; NOTE: Remember to change HEXL-PROGRAM or HEXL-OPTIONS if needed.
32 ;;
33 ;; Currently hexl only supports big endian hex output with 16 bit
34 ;; grouping.
35 ;;
36 ;; -iso in `hexl-options' will allow iso characters to display in the
37 ;; ASCII region of the screen (if your emacs supports this) instead of
38 ;; changing them to dots.
39
40 ;;
41 ;; vars here
42 ;;
43
44 (defvar hexl-program "hexl"
45 "The program that will hexlify and de-hexlify its stdin.
46 `hexl-program' will always be concated with `hexl-options'
47 and \"-de\" when dehexlfying a buffer.")
48
49 (defvar hexl-iso ""
50 "If your emacs can handle ISO characters, this should be set to
51 \"-iso\" otherwise it should be \"\".")
52
53 (defvar hexl-options (format "-hex %s" hexl-iso)
54 "Options to hexl-program that suit your needs.")
55
56 (defvar hexlify-command (format "%s %s" hexl-program hexl-options)
57 "The command to use to hexlify a buffer. It is the concatination of
58 `hexl-program' and `hexl-options'.")
59
60 (defvar dehexlify-command (format "%s -de %s" hexl-program hexl-options)
61 "The command to use to unhexlify a buffer. It is the concatination of
62 `hexl-program', the option \"-de\", and `hexl-options'.")
63
64 (defvar hexl-max-address 0
65 "Maximum offset into hexl buffer.")
66
67 (defvar hexl-mode-map nil)
68
69 ;; routines
70
71 ;;;###autoload
72 (defun hexl-mode (&optional arg)
73 "\\<hexl-mode-map>
74 A major mode for editting binary files in hex dump format.
75
76 This function automatically converts a buffer into the hexl format
77 using the function `hexlify-buffer'.
78
79 Each line in the buffer has an \"address\" (displayed in hexadecimal)
80 representing the offset into the file that the characters on this line
81 are at and 16 characters from the file (displayed as hexadecimal
82 values grouped every 16 bits) and as their ASCII values.
83
84 If any of the characters (displayed as ASCII characters) are
85 unprintable (control or meta characters) they will be replaced as
86 periods.
87
88 If `hexl-mode' is invoked with an argument the buffer is assumed to be
89 in hexl format.
90
91 A sample format:
92
93 HEX ADDR: 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f ASCII-TEXT
94 -------- ---- ---- ---- ---- ---- ---- ---- ---- ----------------
95 00000000: 5468 6973 2069 7320 6865 786c 2d6d 6f64 This is hexl-mod
96 00000010: 652e 2020 4561 6368 206c 696e 6520 7265 e. Each line re
97 00000020: 7072 6573 656e 7473 2031 3620 6279 7465 presents 16 byte
98 00000030: 7320 6173 2068 6578 6164 6563 696d 616c s as hexadecimal
99 00000040: 2041 5343 4949 0a61 6e64 2070 7269 6e74 ASCII.and print
100 00000050: 6162 6c65 2041 5343 4949 2063 6861 7261 able ASCII chara
101 00000060: 6374 6572 732e 2020 416e 7920 636f 6e74 cters. Any cont
102 00000070: 726f 6c20 6f72 206e 6f6e 2d41 5343 4949 rol or non-ASCII
103 00000080: 2063 6861 7261 6374 6572 730a 6172 6520 characters.are
104 00000090: 6469 7370 6c61 7965 6420 6173 2070 6572 displayed as per
105 000000a0: 696f 6473 2069 6e20 7468 6520 7072 696e iods in the prin
106 000000b0: 7461 626c 6520 6368 6172 6163 7465 7220 table character
107 000000c0: 7265 6769 6f6e 2e0a region..
108
109 Movement is as simple as movement in a normal emacs text buffer. Most
110 cursor movement bindings are the same (ie. Use \\[hexl-backward-char], \\[hexl-forward-char], \\[hexl-next-line], and \\[hexl-previous-line]
111 to move the cursor left, right, down, and up).
112
113 Advanced cursor movement commands (ala \\[hexl-beginning-of-line], \\[hexl-end-of-line], \\[hexl-beginning-of-buffer], and \\[hexl-end-of-buffer]) are
114 also supported.
115
116 There are several ways to change text in hexl mode:
117
118 ASCII characters (character between space (0x20) and tilde (0x7E)) are
119 bound to self-insert so you can simply type the character and it will
120 insert itself (actually overstrike) into the buffer.
121
122 \\[hexl-quoted-insert] followed by another keystroke allows you to insert the key even if
123 it isn't bound to self-insert. An octal number can be supplied in place
124 of another key to insert the octal number's ASCII representation.
125
126 \\[hexl-insert-hex-char] will insert a given hexadecimal value (if it is between 0 and 0xFF)
127 into the buffer at the current point.
128
129 \\[hexl-insert-octal-char] will insert a given octal value (if it is between 0 and 0377)
130 into the buffer at the current point.
131
132 \\[hexl-insert-decimal-char] will insert a given decimal value (if it is between 0 and 255)
133 into the buffer at the current point.
134
135 \\[hexl-mode-exit] will exit hexl-mode.
136
137 Note: saving the file with any of the usual Emacs commands
138 will actually convert it back to binary format while saving.
139
140 You can use \\[hexl-find-file] to visit a file in hexl-mode.
141
142 \\[describe-bindings] for advanced commands."
143 (interactive "p")
144 (if (eq major-mode 'hexl-mode)
145 (error "You are already in hexl mode.")
146 (kill-all-local-variables)
147 (make-local-variable 'hexl-mode-old-local-map)
148 (setq hexl-mode-old-local-map (current-local-map))
149 (use-local-map hexl-mode-map)
150
151 (make-local-variable 'hexl-mode-old-mode-name)
152 (setq hexl-mode-old-mode-name mode-name)
153 (setq mode-name "Hexl")
154
155 (make-local-variable 'hexl-mode-old-major-mode)
156 (setq hexl-mode-old-major-mode major-mode)
157 (setq major-mode 'hexl-mode)
158
159 (make-local-variable 'write-contents-hooks)
160 (setq write-contents-hooks
161 (cons 'hexl-save-buffer write-contents-hooks))
162
163 (let ((modified (buffer-modified-p))
164 (read-only buffer-read-only)
165 (original-point (1- (point))))
166 (if (not (or (eq arg 1) (not arg)))
167 ;; if no argument then we guess at hexl-max-address
168 (setq hexl-max-address (+ (* (/ (1- (buffer-size)) 68) 16) 15))
169 (setq buffer-read-only nil)
170 (setq hexl-max-address (1- (buffer-size)))
171 (hexlify-buffer)
172 (set-buffer-modified-p modified)
173 (setq buffer-read-only read-only)
174 (hexl-goto-address original-point)))))
175
176 (defun hexl-save-buffer ()
177 "Save a hexl format buffer as binary in visited file if modified."
178 (interactive)
179 (set-buffer-modified-p (if (buffer-modified-p)
180 (save-excursion
181 (let ((buf (generate-new-buffer " hexl"))
182 (name (buffer-name))
183 (file-name (buffer-file-name))
184 (start (point-min))
185 (end (point-max))
186 modified)
187 (set-buffer buf)
188 (insert-buffer-substring name start end)
189 (set-buffer name)
190 (dehexlify-buffer)
191 (save-buffer)
192 (setq modified (buffer-modified-p))
193 (delete-region (point-min) (point-max))
194 (insert-buffer-substring buf start end)
195 (kill-buffer buf)
196 modified))
197 (message "(No changes need to be saved)")
198 nil))
199 ;; Return t to indicate we have saved t
200 t)
201
202 ;;;###autoload
203 (defun hexl-find-file (filename)
204 "Edit file FILENAME in hexl-mode.
205 Switch to a buffer visiting file FILENAME, creating one in none exists."
206 (interactive "fFilename: ")
207 (find-file filename)
208 (if (not (eq major-mode 'hexl-mode))
209 (hexl-mode)))
210
211 (defun hexl-mode-exit (&optional arg)
212 "Exit Hexl mode, returning to previous mode.
213 With arg, don't unhexlify buffer."
214 (interactive "p")
215 (if (or (eq arg 1) (not arg))
216 (let ((modified (buffer-modified-p))
217 (read-only buffer-read-only)
218 (original-point (1+ (hexl-current-address))))
219 (setq buffer-read-only nil)
220 (dehexlify-buffer)
221 (set-buffer-modified-p modified)
222 (setq buffer-read-only read-only)
223 (goto-char original-point)))
224 (setq mode-name hexl-mode-old-mode-name)
225 (use-local-map hexl-mode-old-local-map)
226 (setq major-mode hexl-mode-old-major-mode)
227 ;; Kludge to update mode-line
228 (switch-to-buffer (current-buffer))
229 )
230
231 (defun hexl-current-address ()
232 "Return current hexl-address."
233 (interactive)
234 (let ((current-column (- (% (point) 68) 11))
235 (hexl-address 0))
236 (setq hexl-address (+ (* (/ (point) 68) 16)
237 (/ (- current-column (/ current-column 5)) 2)))
238 hexl-address))
239
240 (defun hexl-address-to-marker (address)
241 "Return marker for ADDRESS."
242 (interactive "nAddress: ")
243 (+ (* (/ address 16) 68) 11 (/ (* (% address 16) 5) 2)))
244
245 (defun hexl-goto-address (address)
246 "Goto hexl-mode (decimal) address ADDRESS.
247
248 Signal error if ADDRESS out of range."
249 (interactive "nAddress: ")
250 (if (or (< address 0) (> address hexl-max-address))
251 (error "Out of hexl region."))
252 (goto-char (hexl-address-to-marker address)))
253
254 (defun hexl-goto-hex-address (hex-address)
255 "Go to hexl-mode address (hex string) HEX-ADDRESS.
256
257 Signal error if HEX-ADDRESS is out of range."
258 (interactive "sHex Address: ")
259 (hexl-goto-address (hexl-hex-string-to-integer hex-address)))
260
261 (defun hexl-hex-string-to-integer (hex-string)
262 "Return decimal integer for HEX-STRING."
263 (interactive "sHex number: ")
264 (let ((hex-num 0))
265 (while (not (equal hex-string ""))
266 (setq hex-num (+ (* hex-num 16)
267 (hexl-hex-char-to-integer (string-to-char hex-string))))
268 (setq hex-string (substring hex-string 1)))
269 hex-num))
270
271 (defun hexl-octal-string-to-integer (octal-string)
272 "Return decimal integer for OCTAL-STRING."
273 (interactive "sOctal number: ")
274 (let ((oct-num 0))
275 (while (not (equal octal-string ""))
276 (setq oct-num (+ (* oct-num 8)
277 (hexl-oct-char-to-integer
278 (string-to-char octal-string))))
279 (setq octal-string (substring octal-string 1)))
280 oct-num))
281
282 ;; move point functions
283
284 (defun hexl-backward-char (arg)
285 "Move to left ARG bytes (right if ARG negative) in hexl-mode."
286 (interactive "p")
287 (hexl-goto-address (- (hexl-current-address) arg)))
288
289 (defun hexl-forward-char (arg)
290 "Move right ARG bytes (left if ARG negative) in hexl-mode."
291 (interactive "p")
292 (hexl-goto-address (+ (hexl-current-address) arg)))
293
294 (defun hexl-backward-short (arg)
295 "Move to left ARG shorts (right if ARG negative) in hexl-mode."
296 (interactive "p")
297 (hexl-goto-address (let ((address (hexl-current-address)))
298 (if (< arg 0)
299 (progn
300 (setq arg (- arg))
301 (while (> arg 0)
302 (if (not (equal address (logior address 3)))
303 (if (> address hexl-max-address)
304 (progn
305 (message "End of buffer.")
306 (setq address hexl-max-address))
307 (setq address (logior address 3)))
308 (if (> address hexl-max-address)
309 (progn
310 (message "End of buffer.")
311 (setq address hexl-max-address))
312 (setq address (+ address 4))))
313 (setq arg (1- arg)))
314 (if (> address hexl-max-address)
315 (progn
316 (message "End of buffer.")
317 (setq address hexl-max-address))
318 (setq address (logior address 3))))
319 (while (> arg 0)
320 (if (not (equal address (logand address -4)))
321 (setq address (logand address -4))
322 (if (not (equal address 0))
323 (setq address (- address 4))
324 (message "Beginning of buffer.")))
325 (setq arg (1- arg))))
326 address)))
327
328 (defun hexl-forward-short (arg)
329 "Move right ARG shorts (left if ARG negative) in hexl-mode."
330 (interactive "p")
331 (hexl-backward-short (- arg)))
332
333 (defun hexl-backward-word (arg)
334 "Move to left ARG words (right if ARG negative) in hexl-mode."
335 (interactive "p")
336 (hexl-goto-address (let ((address (hexl-current-address)))
337 (if (< arg 0)
338 (progn
339 (setq arg (- arg))
340 (while (> arg 0)
341 (if (not (equal address (logior address 7)))
342 (if (> address hexl-max-address)
343 (progn
344 (message "End of buffer.")
345 (setq address hexl-max-address))
346 (setq address (logior address 7)))
347 (if (> address hexl-max-address)
348 (progn
349 (message "End of buffer.")
350 (setq address hexl-max-address))
351 (setq address (+ address 8))))
352 (setq arg (1- arg)))
353 (if (> address hexl-max-address)
354 (progn
355 (message "End of buffer.")
356 (setq address hexl-max-address))
357 (setq address (logior address 7))))
358 (while (> arg 0)
359 (if (not (equal address (logand address -8)))
360 (setq address (logand address -8))
361 (if (not (equal address 0))
362 (setq address (- address 8))
363 (message "Beginning of buffer.")))
364 (setq arg (1- arg))))
365 address)))
366
367 (defun hexl-forward-word (arg)
368 "Move right ARG words (left if ARG negative) in hexl-mode."
369 (interactive "p")
370 (hexl-backward-word (- arg)))
371
372 (defun hexl-previous-line (arg)
373 "Move vertically up ARG lines [16 bytes] (down if ARG negative) in hexl-mode.
374 If there is byte at the target address move to the last byte in that line."
375 (interactive "p")
376 (hexl-next-line (- arg)))
377
378 (defun hexl-next-line (arg)
379 "Move vertically down ARG lines [16 bytes] (up if ARG negative) in hexl-mode.
380 If there is no byte at the target address move to the last byte in that line."
381 (interactive "p")
382 (hexl-goto-address (let ((address (+ (hexl-current-address) (* arg 16)) t))
383 (if (and (< arg 0) (< address 0))
384 (progn (message "Out of hexl region.")
385 (setq address
386 (% (hexl-current-address) 16)))
387 (if (and (> address hexl-max-address)
388 (< (% hexl-max-address 16) (% address 16)))
389 (setq address hexl-max-address)
390 (if (> address hexl-max-address)
391 (progn (message "Out of hexl region.")
392 (setq
393 address
394 (+ (logand hexl-max-address -16)
395 (% (hexl-current-address) 16)))))))
396 address)))
397
398 (defun hexl-beginning-of-buffer (arg)
399 "Move to the beginning of the hexl buffer.
400 Leaves `hexl-mark' at previous position.
401 With prefix arg N, puts point N bytes of the way from the true beginning."
402 (interactive "p")
403 (push-mark (point))
404 (hexl-goto-address (+ 0 (1- arg))))
405
406 (defun hexl-end-of-buffer (arg)
407 "Go to `hexl-max-address' minus ARG."
408 (interactive "p")
409 (push-mark (point))
410 (hexl-goto-address (- hexl-max-address (1- arg))))
411
412 (defun hexl-beginning-of-line ()
413 "Goto beginning of line in hexl mode."
414 (interactive)
415 (goto-char (+ (* (/ (point) 68) 68) 11)))
416
417 (defun hexl-end-of-line ()
418 "Goto end of line in hexl mode."
419 (interactive)
420 (hexl-goto-address (let ((address (logior (hexl-current-address) 15)))
421 (if (> address hexl-max-address)
422 (setq address hexl-max-address))
423 address)))
424
425 (defun hexl-scroll-down (arg)
426 "Scroll hexl buffer window upward ARG lines; or near full window if no ARG."
427 (interactive "P")
428 (if (null arg)
429 (setq arg (1- (window-height)))
430 (setq arg (prefix-numeric-value arg)))
431 (hexl-scroll-up (- arg)))
432
433 (defun hexl-scroll-up (arg)
434 "Scroll hexl buffer window upward ARG lines; or near full window if no ARG."
435 (interactive "P")
436 (if (null arg)
437 (setq arg (1- (window-height)))
438 (setq arg (prefix-numeric-value arg)))
439 (let ((movement (* arg 16))
440 (address (hexl-current-address)))
441 (if (or (> (+ address movement) hexl-max-address)
442 (< (+ address movement) 0))
443 (message "Out of hexl region.")
444 (hexl-goto-address (+ address movement))
445 (recenter 0))))
446
447 (defun hexl-beginning-of-1k-page ()
448 "Goto to beginning of 1k boundry."
449 (interactive)
450 (hexl-goto-address (logand (hexl-current-address) -1024)))
451
452 (defun hexl-end-of-1k-page ()
453 "Goto to end of 1k boundry."
454 (interactive)
455 (hexl-goto-address (let ((address (logior (hexl-current-address) 1023)))
456 (if (> address hexl-max-address)
457 (setq address hexl-max-address))
458 address)))
459
460 (defun hexl-beginning-of-512b-page ()
461 "Goto to beginning of 512 byte boundry."
462 (interactive)
463 (hexl-goto-address (logand (hexl-current-address) -512)))
464
465 (defun hexl-end-of-512b-page ()
466 "Goto to end of 512 byte boundry."
467 (interactive)
468 (hexl-goto-address (let ((address (logior (hexl-current-address) 511)))
469 (if (> address hexl-max-address)
470 (setq address hexl-max-address))
471 address)))
472
473 (defun hexl-quoted-insert (arg)
474 "Read next input character and insert it.
475 Useful for inserting control characters.
476 You may also type up to 3 octal digits, to insert a character with that code"
477 (interactive "p")
478 (hexl-insert-char (read-quoted-char) arg))
479
480 ;00000000: 0011 2233 4455 6677 8899 aabb ccdd eeff 0123456789ABCDEF
481
482 (defun hexlify-buffer ()
483 "Convert a binary buffer to hexl format"
484 (interactive)
485 (shell-command-on-region (point-min) (point-max) hexlify-command t))
486
487 (defun dehexlify-buffer ()
488 "Convert a hexl format buffer to binary."
489 (interactive)
490 (shell-command-on-region (point-min) (point-max) dehexlify-command t))
491
492 (defun hexl-char-after-point ()
493 "Return char for ASCII hex digits at point."
494 (setq lh (char-after (point)))
495 (setq rh (char-after (1+ (point))))
496 (hexl-htoi lh rh))
497
498 (defun hexl-htoi (lh rh)
499 "Hex (char) LH (char) RH to integer."
500 (+ (* (hexl-hex-char-to-integer lh) 16)
501 (hexl-hex-char-to-integer rh)))
502
503 (defun hexl-hex-char-to-integer (character)
504 "Take a char and return its value as if it was a hex digit."
505 (if (and (>= character ?0) (<= character ?9))
506 (- character ?0)
507 (let ((ch (logior character 32)))
508 (if (and (>= ch ?a) (<= ch ?f))
509 (- ch (- ?a 10))
510 (error (format "Invalid hex digit `%c'." ch))))))
511
512 (defun hexl-oct-char-to-integer (character)
513 "Take a char and return its value as if it was a octal digit."
514 (if (and (>= character ?0) (<= character ?7))
515 (- character ?0)
516 (error (format "Invalid octal digit `%c'." character))))
517
518 (defun hexl-printable-character (ch)
519 "Return a displayable string for character CH."
520 (format "%c" (if hexl-iso
521 (if (or (< ch 32) (and (>= ch 127) (< ch 160)))
522 46
523 ch)
524 (if (or (< ch 32) (>= ch 127))
525 46
526 ch))))
527
528 (defun hexl-self-insert-command (arg)
529 "Insert this character."
530 (interactive "p")
531 (hexl-insert-char last-command-char arg))
532
533 (defun hexl-insert-char (ch num)
534 "Insert a character in a hexl buffer."
535 (let ((address (hexl-current-address)))
536 (while (> num 0)
537 (delete-char 2)
538 (insert (format "%02x" ch))
539 (goto-char
540 (+ (* (/ address 16) 68) 52 (% address 16)))
541 (delete-char 1)
542 (insert (hexl-printable-character ch))
543 (if (eq address hexl-max-address)
544 (hexl-goto-address address)
545 (hexl-goto-address (1+ address)))
546 (setq num (1- num)))))
547
548 ;; hex conversion
549
550 (defun hexl-insert-hex-char (arg)
551 "Insert a ASCII char ARG times at point for a given hexadecimal number."
552 (interactive "p")
553 (let ((num (hexl-hex-string-to-integer (read-string "Hex number: "))))
554 (if (or (> num 255) (< num 0))
555 (error "Hex number out of range.")
556 (hexl-insert-char num arg))))
557
558 (defun hexl-insert-decimal-char (arg)
559 "Insert a ASCII char ARG times at point for a given decimal number."
560 (interactive "p")
561 (let ((num (string-to-int (read-string "Decimal Number: "))))
562 (if (or (> num 255) (< num 0))
563 (error "Decimal number out of range.")
564 (hexl-insert-char num arg))))
565
566 (defun hexl-insert-octal-char (arg)
567 "Insert a ASCII char ARG times at point for a given octal number."
568 (interactive "p")
569 (let ((num (hexl-octal-string-to-integer (read-string "Octal Number: "))))
570 (if (or (> num 255) (< num 0))
571 (error "Decimal number out of range.")
572 (hexl-insert-char num arg))))
573
574 ;; startup stuff.
575
576 (if hexl-mode-map
577 nil
578 (setq hexl-mode-map (make-sparse-keymap))
579
580 (define-key hexl-mode-map "\C-a" 'hexl-beginning-of-line)
581 (define-key hexl-mode-map "\C-b" 'hexl-backward-char)
582 (define-key hexl-mode-map "\C-d" 'undefined)
583 (define-key hexl-mode-map "\C-e" 'hexl-end-of-line)
584 (define-key hexl-mode-map "\C-f" 'hexl-forward-char)
585
586 (if (not (eq (key-binding "\C-h") 'help-command))
587 (define-key hexl-mode-map "\C-h" 'undefined))
588
589 (define-key hexl-mode-map "\C-i" 'hexl-self-insert-command)
590 (define-key hexl-mode-map "\C-j" 'hexl-self-insert-command)
591 (define-key hexl-mode-map "\C-k" 'undefined)
592 (define-key hexl-mode-map "\C-m" 'hexl-self-insert-command)
593 (define-key hexl-mode-map "\C-n" 'hexl-next-line)
594 (define-key hexl-mode-map "\C-o" 'undefined)
595 (define-key hexl-mode-map "\C-p" 'hexl-previous-line)
596 (define-key hexl-mode-map "\C-q" 'hexl-quoted-insert)
597 (define-key hexl-mode-map "\C-t" 'undefined)
598 (define-key hexl-mode-map "\C-v" 'hexl-scroll-up)
599 (define-key hexl-mode-map "\C-w" 'undefined)
600 (define-key hexl-mode-map "\C-y" 'undefined)
601
602 (let ((ch 32))
603 (while (< ch 127)
604 (define-key hexl-mode-map (format "%c" ch) 'hexl-self-insert-command)
605 (setq ch (1+ ch))))
606
607 (define-key hexl-mode-map "\e\C-a" 'hexl-beginning-of-512b-page)
608 (define-key hexl-mode-map "\e\C-b" 'hexl-backward-short)
609 (define-key hexl-mode-map "\e\C-c" 'undefined)
610 (define-key hexl-mode-map "\e\C-d" 'hexl-insert-decimal-char)
611 (define-key hexl-mode-map "\e\C-e" 'hexl-end-of-512b-page)
612 (define-key hexl-mode-map "\e\C-f" 'hexl-forward-short)
613 (define-key hexl-mode-map "\e\C-g" 'undefined)
614 (define-key hexl-mode-map "\e\C-h" 'undefined)
615 (define-key hexl-mode-map "\e\C-i" 'undefined)
616 (define-key hexl-mode-map "\e\C-j" 'undefined)
617 (define-key hexl-mode-map "\e\C-k" 'undefined)
618 (define-key hexl-mode-map "\e\C-l" 'undefined)
619 (define-key hexl-mode-map "\e\C-m" 'undefined)
620 (define-key hexl-mode-map "\e\C-n" 'undefined)
621 (define-key hexl-mode-map "\e\C-o" 'hexl-insert-octal-char)
622 (define-key hexl-mode-map "\e\C-p" 'undefined)
623 (define-key hexl-mode-map "\e\C-q" 'undefined)
624 (define-key hexl-mode-map "\e\C-r" 'undefined)
625 (define-key hexl-mode-map "\e\C-s" 'undefined)
626 (define-key hexl-mode-map "\e\C-t" 'undefined)
627 (define-key hexl-mode-map "\e\C-u" 'undefined)
628
629 (define-key hexl-mode-map "\e\C-w" 'undefined)
630 (define-key hexl-mode-map "\e\C-x" 'hexl-insert-hex-char)
631 (define-key hexl-mode-map "\e\C-y" 'undefined)
632
633 (define-key hexl-mode-map "\ea" 'undefined)
634 (define-key hexl-mode-map "\eb" 'hexl-backward-word)
635 (define-key hexl-mode-map "\ec" 'undefined)
636 (define-key hexl-mode-map "\ed" 'undefined)
637 (define-key hexl-mode-map "\ee" 'undefined)
638 (define-key hexl-mode-map "\ef" 'hexl-forward-word)
639 (define-key hexl-mode-map "\eg" 'hexl-goto-hex-address)
640 (define-key hexl-mode-map "\eh" 'undefined)
641 (define-key hexl-mode-map "\ei" 'undefined)
642 (define-key hexl-mode-map "\ej" 'hexl-goto-address)
643 (define-key hexl-mode-map "\ek" 'undefined)
644 (define-key hexl-mode-map "\el" 'undefined)
645 (define-key hexl-mode-map "\em" 'undefined)
646 (define-key hexl-mode-map "\en" 'undefined)
647 (define-key hexl-mode-map "\eo" 'undefined)
648 (define-key hexl-mode-map "\ep" 'undefined)
649 (define-key hexl-mode-map "\eq" 'undefined)
650 (define-key hexl-mode-map "\er" 'undefined)
651 (define-key hexl-mode-map "\es" 'undefined)
652 (define-key hexl-mode-map "\et" 'undefined)
653 (define-key hexl-mode-map "\eu" 'undefined)
654 (define-key hexl-mode-map "\ev" 'hexl-scroll-down)
655 (define-key hexl-mode-map "\ey" 'undefined)
656 (define-key hexl-mode-map "\ez" 'undefined)
657 (define-key hexl-mode-map "\e<" 'hexl-beginning-of-buffer)
658 (define-key hexl-mode-map "\e>" 'hexl-end-of-buffer)
659
660 (define-key hexl-mode-map "\C-c\C-c" 'hexl-mode-exit)
661
662 (define-key hexl-mode-map "\C-x[" 'hexl-beginning-of-1k-page)
663 (define-key hexl-mode-map "\C-x]" 'hexl-end-of-1k-page)
664 (define-key hexl-mode-map "\C-x\C-p" 'undefined)
665 (define-key hexl-mode-map "\C-x\C-s" 'hexl-save-buffer)
666 (define-key hexl-mode-map "\C-x\C-t" 'undefined))
667
668 ;;; hexl.el ends here