]> code.delx.au - gnu-emacs/blob - lisp/hexl.el
Merge changes from emacs-23 branch.
[gnu-emacs] / lisp / hexl.el
1 ;;; hexl.el --- edit a file in a hex dump format using the hexl filter
2
3 ;; Copyright (C) 1989, 1994, 1998, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5
6 ;; Author: Keith Gabryelski <ag@wheaties.ai.mit.edu>
7 ;; Maintainer: FSF
8 ;; Keywords: data
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
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
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
27 ;; This package implements a major mode for editing binary files. It uses
28 ;; a program called hexl, supplied with the GNU Emacs distribution, that
29 ;; can filter a binary into an editable format or from the format back into
30 ;; binary. For full instructions, invoke `hexl-mode' on an empty buffer and
31 ;; do M-x `describe-mode'.
32 ;;
33 ;; NOTE: Remember to change `hexl-program' or `hexl-options' if needed.
34 ;;
35 ;; Currently hexl only supports big endian hex output with 16 bit
36 ;; grouping.
37 ;;
38 ;; -iso in `hexl-options' will allow iso characters to display in the
39 ;; ASCII region of the screen (if your Emacs supports this) instead of
40 ;; changing them to dots.
41
42 ;;; Code:
43
44 (require 'eldoc)
45 (eval-when-compile (require 'cl))
46
47 ;;
48 ;; vars here
49 ;;
50
51 (defgroup hexl nil
52 "Edit a file in a hex dump format using the hexl filter."
53 :group 'data)
54
55
56 (defcustom hexl-program "hexl"
57 "The program that will hexlify and dehexlify its stdin.
58 `hexl-program' will always be concatenated with `hexl-options'
59 and \"-de\" when dehexlifying a buffer."
60 :type 'string
61 :group 'hexl)
62
63 (defcustom hexl-iso ""
64 "If your Emacs can handle ISO characters, this should be set to
65 \"-iso\" otherwise it should be \"\"."
66 :type 'string
67 :group 'hexl)
68
69 (defcustom hexl-options (format "-hex %s" hexl-iso)
70 "Space separated options to `hexl-program' that suit your needs.
71 Quoting cannot be used, so the arguments cannot themselves contain spaces."
72 :type 'string
73 :group 'hexl)
74
75 (defcustom hexl-follow-ascii t
76 "If non-nil then highlight the ASCII character corresponding to point."
77 :type 'boolean
78 :group 'hexl
79 :version "20.3")
80
81 (defcustom hexl-mode-hook '(hexl-follow-line hexl-activate-ruler)
82 "Normal hook run when entering Hexl mode."
83 :type 'hook
84 :options '(hexl-follow-line hexl-activate-ruler turn-on-eldoc-mode)
85 :group 'hexl)
86
87 (defface hexl-address-region
88 '((t (:inherit header-line)))
89 "Face used in address area of hexl-mode buffer."
90 :group 'hexl)
91
92 (defface hexl-ascii-region
93 '((t (:inherit header-line)))
94 "Face used in ascii area of hexl-mode buffer."
95 :group 'hexl)
96
97 (defvar hexl-max-address 0
98 "Maximum offset into hexl buffer.")
99
100 (defvar hexl-mode-map
101 (let ((map (make-keymap)))
102 ;; Make all self-inserting keys go through hexl-self-insert-command,
103 ;; because we need to convert them to unibyte characters before
104 ;; inserting them into the buffer.
105 (define-key map [remap self-insert-command] 'hexl-self-insert-command)
106
107 (define-key map "\C-m" 'hexl-self-insert-command)
108 (define-key map [left] 'hexl-backward-char)
109 (define-key map [right] 'hexl-forward-char)
110 (define-key map [up] 'hexl-previous-line)
111 (define-key map [down] 'hexl-next-line)
112 (define-key map [M-left] 'hexl-backward-short)
113 (define-key map [?\e left] 'hexl-backward-short)
114 (define-key map [M-right] 'hexl-forward-short)
115 (define-key map [?\e right] 'hexl-forward-short)
116 (define-key map [next] 'hexl-scroll-up)
117 (define-key map [prior] 'hexl-scroll-down)
118 (define-key map [home] 'hexl-beginning-of-line)
119 (define-key map [end] 'hexl-end-of-line)
120 (define-key map [C-home] 'hexl-beginning-of-buffer)
121 (define-key map [C-end] 'hexl-end-of-buffer)
122 (define-key map [deletechar] 'undefined)
123 (define-key map [deleteline] 'undefined)
124 (define-key map [insertline] 'undefined)
125 (define-key map [S-delete] 'undefined)
126 (define-key map "\177" 'undefined)
127
128 (define-key map "\C-a" 'hexl-beginning-of-line)
129 (define-key map "\C-b" 'hexl-backward-char)
130 (define-key map "\C-d" 'undefined)
131 (define-key map "\C-e" 'hexl-end-of-line)
132 (define-key map "\C-f" 'hexl-forward-char)
133
134 (if (not (memq (key-binding (char-to-string help-char))
135 '(help-command ehelp-command)))
136 (define-key map (char-to-string help-char) 'undefined))
137
138 (define-key map "\C-k" 'undefined)
139 (define-key map "\C-n" 'hexl-next-line)
140 (define-key map "\C-o" 'undefined)
141 (define-key map "\C-p" 'hexl-previous-line)
142 (define-key map "\C-q" 'hexl-quoted-insert)
143 (define-key map "\C-t" 'undefined)
144 (define-key map "\C-v" 'hexl-scroll-up)
145 (define-key map "\C-w" 'undefined)
146 (define-key map "\C-y" 'undefined)
147
148 (fset 'hexl-ESC-prefix (copy-keymap 'ESC-prefix))
149 (define-key map "\e" 'hexl-ESC-prefix)
150 (define-key map "\e\C-a" 'hexl-beginning-of-512b-page)
151 (define-key map "\e\C-b" 'hexl-backward-short)
152 (define-key map "\e\C-d" 'hexl-insert-decimal-char)
153 (define-key map "\e\C-e" 'hexl-end-of-512b-page)
154 (define-key map "\e\C-f" 'hexl-forward-short)
155 (define-key map "\e\C-i" 'undefined)
156 (define-key map "\e\C-j" 'undefined)
157 (define-key map "\e\C-k" 'undefined)
158 (define-key map "\e\C-o" 'hexl-insert-octal-char)
159 (define-key map "\e\C-q" 'undefined)
160 (define-key map "\e\C-t" 'undefined)
161 (define-key map "\e\C-x" 'hexl-insert-hex-char)
162 (define-key map "\eb" 'hexl-backward-word)
163 (define-key map "\ec" 'undefined)
164 (define-key map "\ed" 'undefined)
165 (define-key map "\ef" 'hexl-forward-word)
166 (define-key map "\eg" 'hexl-goto-hex-address)
167 (define-key map "\ei" 'undefined)
168 (define-key map "\ej" 'hexl-goto-address)
169 (define-key map "\ek" 'undefined)
170 (define-key map "\el" 'undefined)
171 (define-key map "\eq" 'undefined)
172 (define-key map "\es" 'undefined)
173 (define-key map "\et" 'undefined)
174 (define-key map "\eu" 'undefined)
175 (define-key map "\ev" 'hexl-scroll-down)
176 (define-key map "\ey" 'undefined)
177 (define-key map "\ez" 'undefined)
178 (define-key map "\e<" 'hexl-beginning-of-buffer)
179 (define-key map "\e>" 'hexl-end-of-buffer)
180
181 (fset 'hexl-C-c-prefix (copy-keymap mode-specific-map))
182 (define-key map "\C-c" 'hexl-C-c-prefix)
183 (define-key map "\C-c\C-c" 'hexl-mode-exit)
184
185 (fset 'hexl-C-x-prefix (copy-keymap 'Control-X-prefix))
186 (define-key map "\C-x" 'hexl-C-x-prefix)
187 (define-key map "\C-x[" 'hexl-beginning-of-1k-page)
188 (define-key map "\C-x]" 'hexl-end-of-1k-page)
189 (define-key map "\C-x\C-p" 'undefined)
190 (define-key map "\C-x\C-s" 'hexl-save-buffer)
191 (define-key map "\C-x\C-t" 'undefined)
192 map))
193
194 ;; Variable declarations for suppressing warnings from the byte-compiler.
195 (defvar ruler-mode)
196 (defvar ruler-mode-ruler-function)
197 (defvar hl-line-mode)
198 (defvar hl-line-range-function)
199 (defvar hl-line-face)
200
201 ;; Variables where the original values are stored to.
202 (defvar hexl-mode-old-hl-line-mode)
203 (defvar hexl-mode-old-hl-line-range-function)
204 (defvar hexl-mode-old-hl-line-face)
205 (defvar hexl-mode-old-local-map)
206 (defvar hexl-mode-old-mode-name)
207 (defvar hexl-mode-old-major-mode)
208 (defvar hexl-mode-old-ruler-mode)
209 (defvar hexl-mode-old-ruler-function)
210 (defvar hexl-mode-old-isearch-search-fun-function)
211 (defvar hexl-mode-old-require-final-newline)
212 (defvar hexl-mode-old-syntax-table)
213 (defvar hexl-mode-old-font-lock-keywords)
214 (defvar hexl-mode-old-eldoc-documentation-function)
215
216 (defvar hexl-ascii-overlay nil
217 "Overlay used to highlight ASCII element corresponding to current point.")
218 (make-variable-buffer-local 'hexl-ascii-overlay)
219
220 (defvar hexl-font-lock-keywords
221 '(("^\\([0-9a-f]+:\\).\\{40\\} \\(.+$\\)"
222 ;; "^\\([0-9a-f]+:\\).+ \\(.+$\\)"
223 (1 'hexl-address-region t t)
224 (2 'hexl-ascii-region t t)))
225 "Font lock keywords used in `hexl-mode'.")
226
227 ;; routines
228
229 (put 'hexl-mode 'mode-class 'special)
230
231 ;;;###autoload
232 (defun hexl-mode (&optional arg)
233 "\\<hexl-mode-map>A mode for editing binary files in hex dump format.
234 This is not an ordinary major mode; it alters some aspects
235 of the current mode's behavior, but not all; also, you can exit
236 Hexl mode and return to the previous mode using `hexl-mode-exit'.
237
238 This function automatically converts a buffer into the hexl format
239 using the function `hexlify-buffer'.
240
241 Each line in the buffer has an \"address\" (displayed in hexadecimal)
242 representing the offset into the file that the characters on this line
243 are at and 16 characters from the file (displayed as hexadecimal
244 values grouped every 16 bits) and as their ASCII values.
245
246 If any of the characters (displayed as ASCII characters) are
247 unprintable (control or meta characters) they will be replaced as
248 periods.
249
250 If `hexl-mode' is invoked with an argument the buffer is assumed to be
251 in hexl format.
252
253 A sample format:
254
255 HEX ADDR: 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f ASCII-TEXT
256 -------- ---- ---- ---- ---- ---- ---- ---- ---- ----------------
257 00000000: 5468 6973 2069 7320 6865 786c 2d6d 6f64 This is hexl-mod
258 00000010: 652e 2020 4561 6368 206c 696e 6520 7265 e. Each line re
259 00000020: 7072 6573 656e 7473 2031 3620 6279 7465 presents 16 byte
260 00000030: 7320 6173 2068 6578 6164 6563 696d 616c s as hexadecimal
261 00000040: 2041 5343 4949 0a61 6e64 2070 7269 6e74 ASCII.and print
262 00000050: 6162 6c65 2041 5343 4949 2063 6861 7261 able ASCII chara
263 00000060: 6374 6572 732e 2020 416e 7920 636f 6e74 cters. Any cont
264 00000070: 726f 6c20 6f72 206e 6f6e 2d41 5343 4949 rol or non-ASCII
265 00000080: 2063 6861 7261 6374 6572 730a 6172 6520 characters.are
266 00000090: 6469 7370 6c61 7965 6420 6173 2070 6572 displayed as per
267 000000a0: 696f 6473 2069 6e20 7468 6520 7072 696e iods in the prin
268 000000b0: 7461 626c 6520 6368 6172 6163 7465 7220 table character
269 000000c0: 7265 6769 6f6e 2e0a region..
270
271 Movement is as simple as movement in a normal Emacs text buffer. Most
272 cursor movement bindings are the same (ie. Use \\[hexl-backward-char], \\[hexl-forward-char], \\[hexl-next-line], and \\[hexl-previous-line]
273 to move the cursor left, right, down, and up).
274
275 Advanced cursor movement commands (ala \\[hexl-beginning-of-line], \\[hexl-end-of-line], \\[hexl-beginning-of-buffer], and \\[hexl-end-of-buffer]) are
276 also supported.
277
278 There are several ways to change text in hexl mode:
279
280 ASCII characters (character between space (0x20) and tilde (0x7E)) are
281 bound to self-insert so you can simply type the character and it will
282 insert itself (actually overstrike) into the buffer.
283
284 \\[hexl-quoted-insert] followed by another keystroke allows you to insert the key even if
285 it isn't bound to self-insert. An octal number can be supplied in place
286 of another key to insert the octal number's ASCII representation.
287
288 \\[hexl-insert-hex-char] will insert a given hexadecimal value (if it is between 0 and 0xFF)
289 into the buffer at the current point.
290
291 \\[hexl-insert-octal-char] will insert a given octal value (if it is between 0 and 0377)
292 into the buffer at the current point.
293
294 \\[hexl-insert-decimal-char] will insert a given decimal value (if it is between 0 and 255)
295 into the buffer at the current point.
296
297 \\[hexl-mode-exit] will exit hexl-mode.
298
299 Note: saving the file with any of the usual Emacs commands
300 will actually convert it back to binary format while saving.
301
302 You can use \\[hexl-find-file] to visit a file in Hexl mode.
303
304 \\[describe-bindings] for advanced commands."
305 (interactive "p")
306 (unless (eq major-mode 'hexl-mode)
307 (let ((modified (buffer-modified-p))
308 (inhibit-read-only t)
309 (original-point (- (point) (point-min))))
310 (and (eobp) (not (bobp))
311 (setq original-point (1- original-point)))
312 ;; If `hexl-mode' is invoked with an argument the buffer is assumed to
313 ;; be in hexl format.
314 (when (memq arg '(1 nil))
315 ;; If the buffer's EOL type is -dos, we need to account for
316 ;; extra CR characters added when hexlify-buffer writes the
317 ;; buffer to a file.
318 ;; FIXME: This doesn't take into account multibyte coding systems.
319 (when (eq (coding-system-eol-type buffer-file-coding-system) 1)
320 (setq original-point (+ (count-lines (point-min) (point))
321 original-point))
322 (or (bolp) (setq original-point (1- original-point))))
323 (hexlify-buffer)
324 (restore-buffer-modified-p modified))
325 (set (make-local-variable 'hexl-max-address)
326 (let* ((full-lines (/ (buffer-size) 68))
327 (last-line (% (buffer-size) 68))
328 (last-line-bytes (% last-line 52)))
329 (+ last-line-bytes (* full-lines 16) -1)))
330 (condition-case nil
331 (hexl-goto-address original-point)
332 (error nil)))
333
334 ;; We do not turn off the old major mode; instead we just
335 ;; override most of it. That way, we can restore it perfectly.
336 (make-local-variable 'hexl-mode-old-local-map)
337 (setq hexl-mode-old-local-map (current-local-map))
338 (use-local-map hexl-mode-map)
339
340 (make-local-variable 'hexl-mode-old-mode-name)
341 (setq hexl-mode-old-mode-name mode-name)
342 (setq mode-name "Hexl")
343
344 (set (make-local-variable 'hexl-mode-old-isearch-search-fun-function)
345 isearch-search-fun-function)
346 (set (make-local-variable 'isearch-search-fun-function)
347 'hexl-isearch-search-function)
348
349 (make-local-variable 'hexl-mode-old-major-mode)
350 (setq hexl-mode-old-major-mode major-mode)
351 (setq major-mode 'hexl-mode)
352
353 (make-local-variable 'hexl-mode-old-ruler-mode)
354 (setq hexl-mode-old-ruler-mode
355 (and (boundp 'ruler-mode) ruler-mode))
356
357 (make-local-variable 'hexl-mode-old-hl-line-mode)
358 (setq hexl-mode-old-hl-line-mode
359 (and (boundp 'hl-line-mode) hl-line-mode))
360
361 (make-local-variable 'hexl-mode-old-syntax-table)
362 (setq hexl-mode-old-syntax-table (syntax-table))
363 (set-syntax-table (standard-syntax-table))
364
365 (add-hook 'write-contents-functions 'hexl-save-buffer nil t)
366
367 (make-local-variable 'hexl-mode-old-require-final-newline)
368 (setq hexl-mode-old-require-final-newline require-final-newline)
369 (make-local-variable 'require-final-newline)
370 (setq require-final-newline nil)
371
372 (make-local-variable 'hexl-mode-old-font-lock-keywords)
373 (setq hexl-mode-old-font-lock-keywords font-lock-defaults)
374 (setq font-lock-defaults '(hexl-font-lock-keywords t))
375
376 ;; Add hooks to rehexlify or dehexlify on various events.
377 (add-hook 'before-revert-hook 'hexl-before-revert-hook nil t)
378 (add-hook 'after-revert-hook 'hexl-after-revert-hook nil t)
379
380 (add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer nil t)
381
382 ;; Set a callback function for eldoc.
383 (make-local-variable 'hexl-mode-old-eldoc-documentation-function)
384 (setq hexl-mode-old-eldoc-documentation-function
385 (bound-and-true-p eldoc-documentation-function))
386
387 (set (make-local-variable 'eldoc-documentation-function)
388 'hexl-print-current-point-info)
389 (eldoc-add-command-completions "hexl-")
390 (eldoc-remove-command "hexl-save-buffer"
391 "hexl-current-address")
392
393 (if hexl-follow-ascii (hexl-follow-ascii 1)))
394 (run-mode-hooks 'hexl-mode-hook))
395
396
397 (defun hexl-isearch-search-function ()
398 (if (and (not isearch-regexp) (not isearch-word))
399 (lambda (string &optional bound noerror count)
400 (funcall
401 (if isearch-forward 're-search-forward 're-search-backward)
402 (let ((textre
403 (if (> (length string) 80)
404 (regexp-quote string)
405 (mapconcat (lambda (c) (regexp-quote (string c))) string
406 "\\(?:\n\\(?:[:a-f0-9]+ \\)+ \\)?"))))
407 (if (string-match "\\` ?\\([a-f0-9]+ \\)*[a-f0-9]+ ?\\'" string)
408 (concat textre "\\|"
409 (mapconcat 'regexp-quote (split-string string " ")
410 " \\(?: .+\n[a-f0-9]+: \\)?"))
411 textre))
412 bound noerror count))
413 (let ((isearch-search-fun-function nil))
414 (isearch-search-fun))))
415
416 (defun hexl-before-revert-hook ()
417 (remove-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer t))
418
419 (defun hexl-after-revert-hook ()
420 (hexl-mode))
421
422 (defvar hexl-in-save-buffer nil)
423
424 (defun hexl-save-buffer ()
425 "Save a hexl format buffer as binary in visited file if modified."
426 (interactive)
427 (if hexl-in-save-buffer nil
428 (restore-buffer-modified-p
429 (if (buffer-modified-p)
430 (let ((buf (generate-new-buffer " hexl"))
431 (name (buffer-name))
432 (start (point-min))
433 (end (point-max))
434 modified)
435 (with-current-buffer buf
436 (insert-buffer-substring name start end)
437 (set-buffer name)
438 (dehexlify-buffer)
439 ;; Prevent infinite recursion.
440 (let ((hexl-in-save-buffer t))
441 (save-buffer))
442 (setq modified (buffer-modified-p))
443 (delete-region (point-min) (point-max))
444 (insert-buffer-substring buf start end)
445 (kill-buffer buf)
446 modified))
447 (message "(No changes need to be saved)")
448 nil))
449 ;; Return t to indicate we have saved t
450 t))
451
452 ;;;###autoload
453 (defun hexl-find-file (filename)
454 "Edit file FILENAME as a binary file in hex dump format.
455 Switch to a buffer visiting file FILENAME, creating one if none exists,
456 and edit the file in `hexl-mode'."
457 (interactive
458 (list
459 (let ((completion-ignored-extensions nil))
460 (read-file-name "Filename: " nil nil 'ret-must-match))))
461 ;; Ignore the user's setting of default major-mode.
462 (letf (((default-value 'major-mode) 'fundamental-mode))
463 (find-file-literally filename))
464 (if (not (eq major-mode 'hexl-mode))
465 (hexl-mode)))
466
467 (defun hexl-mode-exit (&optional arg)
468 "Exit Hexl mode, returning to previous mode.
469 With arg, don't unhexlify buffer."
470 (interactive "p")
471 (if (or (eq arg 1) (not arg))
472 (let ((modified (buffer-modified-p))
473 (inhibit-read-only t)
474 (original-point (1+ (hexl-current-address))))
475 (dehexlify-buffer)
476 (remove-hook 'write-contents-functions 'hexl-save-buffer t)
477 (restore-buffer-modified-p modified)
478 (goto-char original-point)
479 ;; Maybe adjust point for the removed CR characters.
480 (when (eq (coding-system-eol-type buffer-file-coding-system) 1)
481 (setq original-point (- original-point
482 (count-lines (point-min) (point))))
483 (or (bobp) (setq original-point (1+ original-point))))
484 (goto-char original-point)))
485
486 (remove-hook 'before-revert-hook 'hexl-before-revert-hook t)
487 (remove-hook 'after-revert-hook 'hexl-after-revert-hook t)
488 (remove-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer t)
489 (remove-hook 'post-command-hook 'hexl-follow-ascii-find t)
490 (setq hexl-ascii-overlay nil)
491
492 (if (and (boundp 'ruler-mode) ruler-mode (not hexl-mode-old-ruler-mode))
493 (ruler-mode 0))
494 (when (boundp 'hexl-mode-old-ruler-function)
495 (setq ruler-mode-ruler-function hexl-mode-old-ruler-function))
496
497 (if (and (boundp 'hl-line-mode) hl-line-mode (not hexl-mode-old-hl-line-mode))
498 (hl-line-mode 0))
499 (when (boundp 'hexl-mode-old-hl-line-range-function)
500 (setq hl-line-range-function hexl-mode-old-hl-line-range-function))
501 (when (boundp 'hexl-mode-old-hl-line-face)
502 (setq hl-line-face hexl-mode-old-hl-line-face))
503
504 (when (boundp 'hexl-mode-old-eldoc-documentation-function)
505 (setq eldoc-documentation-function
506 hexl-mode-old-eldoc-documentation-function))
507
508 (setq require-final-newline hexl-mode-old-require-final-newline)
509 (setq mode-name hexl-mode-old-mode-name)
510 (setq isearch-search-fun-function hexl-mode-old-isearch-search-fun-function)
511 (use-local-map hexl-mode-old-local-map)
512 (set-syntax-table hexl-mode-old-syntax-table)
513 (setq font-lock-defaults hexl-mode-old-font-lock-keywords)
514 (setq major-mode hexl-mode-old-major-mode)
515 (force-mode-line-update))
516
517 (defun hexl-maybe-dehexlify-buffer ()
518 "Convert a hexl format buffer to binary.
519 Ask the user for confirmation."
520 (if (y-or-n-p "Convert contents back to binary format? ")
521 (let ((modified (buffer-modified-p))
522 (inhibit-read-only t)
523 (original-point (1+ (hexl-current-address))))
524 (dehexlify-buffer)
525 (remove-hook 'write-contents-functions 'hexl-save-buffer t)
526 (restore-buffer-modified-p modified)
527 (goto-char original-point))))
528
529 (defun hexl-current-address (&optional validate)
530 "Return current hexl-address."
531 (interactive)
532 (let ((current-column (- (% (- (point) (point-min) -1) 68) 11))
533 (hexl-address 0))
534 (if (< current-column 0)
535 (if validate
536 (error "Point is not on a character in the file")
537 (setq current-column 0)))
538 (setq hexl-address
539 (+ (* (/ (- (point) (point-min) -1) 68) 16)
540 (if (>= current-column 41)
541 (- current-column 41)
542 (/ (- current-column (/ current-column 5)) 2))))
543 (when (called-interactively-p 'interactive)
544 (message "Current address is %d/0x%08x" hexl-address hexl-address))
545 hexl-address))
546
547 (defun hexl-print-current-point-info ()
548 "Return current hexl-address in string.
549 This function is intended to be used as eldoc callback."
550 (let ((addr (hexl-current-address)))
551 (format "Current address is %d/0x%08x" addr addr)))
552
553 (defun hexl-address-to-marker (address)
554 "Return buffer position for ADDRESS."
555 (interactive "nAddress: ")
556 (+ (* (/ address 16) 68) 10 (point-min) (/ (* (% address 16) 5) 2)))
557
558 (defun hexl-goto-address (address)
559 "Go to hexl-mode (decimal) address ADDRESS.
560 Signal error if ADDRESS is out of range."
561 (interactive "nAddress: ")
562 (if (or (< address 0) (> address hexl-max-address))
563 (error "Out of hexl region"))
564 (goto-char (hexl-address-to-marker address)))
565
566 (defun hexl-goto-hex-address (hex-address)
567 "Go to hexl-mode address (hex string) HEX-ADDRESS.
568 Signal error if HEX-ADDRESS is out of range."
569 (interactive "sHex Address: ")
570 (hexl-goto-address (hexl-hex-string-to-integer hex-address)))
571
572 (defun hexl-hex-string-to-integer (hex-string)
573 "Return decimal integer for HEX-STRING."
574 (interactive "sHex number: ")
575 (let ((hex-num 0))
576 (while (not (equal hex-string ""))
577 (setq hex-num (+ (* hex-num 16)
578 (hexl-hex-char-to-integer (string-to-char hex-string))))
579 (setq hex-string (substring hex-string 1)))
580 hex-num))
581
582 (defun hexl-octal-string-to-integer (octal-string)
583 "Return decimal integer for OCTAL-STRING."
584 (interactive "sOctal number: ")
585 (let ((oct-num 0))
586 (while (not (equal octal-string ""))
587 (setq oct-num (+ (* oct-num 8)
588 (hexl-oct-char-to-integer
589 (string-to-char octal-string))))
590 (setq octal-string (substring octal-string 1)))
591 oct-num))
592
593 ;; move point functions
594
595 (defun hexl-backward-char (arg)
596 "Move to left ARG bytes (right if ARG negative) in hexl-mode."
597 (interactive "p")
598 (hexl-goto-address (- (hexl-current-address) arg)))
599
600 (defun hexl-forward-char (arg)
601 "Move to right ARG bytes (left if ARG negative) in hexl-mode."
602 (interactive "p")
603 (hexl-goto-address (+ (hexl-current-address) arg)))
604
605 (defun hexl-backward-short (arg)
606 "Move to left ARG shorts (right if ARG negative) in hexl-mode."
607 (interactive "p")
608 (hexl-goto-address (let ((address (hexl-current-address)))
609 (if (< arg 0)
610 (progn
611 (setq arg (- arg))
612 (while (> arg 0)
613 (if (not (equal address (logior address 3)))
614 (if (> address hexl-max-address)
615 (progn
616 (message "End of buffer.")
617 (setq address hexl-max-address))
618 (setq address (logior address 3)))
619 (if (> address hexl-max-address)
620 (progn
621 (message "End of buffer.")
622 (setq address hexl-max-address))
623 (setq address (+ address 4))))
624 (setq arg (1- arg)))
625 (if (> address hexl-max-address)
626 (progn
627 (message "End of buffer.")
628 (setq address hexl-max-address))
629 (setq address (logior address 3))))
630 (while (> arg 0)
631 (if (not (equal address (logand address -4)))
632 (setq address (logand address -4))
633 (if (not (equal address 0))
634 (setq address (- address 4))
635 (message "Beginning of buffer.")))
636 (setq arg (1- arg))))
637 address)))
638
639 (defun hexl-forward-short (arg)
640 "Move to right ARG shorts (left if ARG negative) in hexl-mode."
641 (interactive "p")
642 (hexl-backward-short (- arg)))
643
644 (defun hexl-backward-word (arg)
645 "Move to left ARG words (right if ARG negative) in hexl-mode."
646 (interactive "p")
647 (hexl-goto-address (let ((address (hexl-current-address)))
648 (if (< arg 0)
649 (progn
650 (setq arg (- arg))
651 (while (> arg 0)
652 (if (not (equal address (logior address 7)))
653 (if (> address hexl-max-address)
654 (progn
655 (message "End of buffer.")
656 (setq address hexl-max-address))
657 (setq address (logior address 7)))
658 (if (> address hexl-max-address)
659 (progn
660 (message "End of buffer.")
661 (setq address hexl-max-address))
662 (setq address (+ address 8))))
663 (setq arg (1- arg)))
664 (if (> address hexl-max-address)
665 (progn
666 (message "End of buffer.")
667 (setq address hexl-max-address))
668 (setq address (logior address 7))))
669 (while (> arg 0)
670 (if (not (equal address (logand address -8)))
671 (setq address (logand address -8))
672 (if (not (equal address 0))
673 (setq address (- address 8))
674 (message "Beginning of buffer.")))
675 (setq arg (1- arg))))
676 address)))
677
678 (defun hexl-forward-word (arg)
679 "Move to right ARG words (left if ARG negative) in hexl-mode."
680 (interactive "p")
681 (hexl-backward-word (- arg)))
682
683 (defun hexl-previous-line (arg)
684 "Move vertically up ARG lines [16 bytes] (down if ARG negative) in hexl-mode.
685 If there is no byte at the target address move to the last byte in that line."
686 (interactive "p")
687 (hexl-next-line (- arg)))
688
689 (defun hexl-next-line (arg)
690 "Move vertically down ARG lines [16 bytes] (up if ARG negative) in hexl-mode.
691 If there is no byte at the target address move to the last byte in that line."
692 (interactive "p")
693 (hexl-goto-address (let ((address (+ (hexl-current-address) (* arg 16))))
694 (if (and (< arg 0) (< address 0))
695 (progn (message "Out of hexl region.")
696 (setq address
697 (% (hexl-current-address) 16)))
698 (if (and (> address hexl-max-address)
699 (< (% hexl-max-address 16) (% address 16)))
700 (setq address hexl-max-address)
701 (if (> address hexl-max-address)
702 (progn (message "Out of hexl region.")
703 (setq
704 address
705 (+ (logand hexl-max-address -16)
706 (% (hexl-current-address) 16)))))))
707 address)))
708
709 (defun hexl-beginning-of-buffer (arg)
710 "Move to the beginning of the hexl buffer.
711 Leaves `hexl-mark' at previous position.
712 With prefix arg N, puts point N bytes of the way from the true beginning."
713 (interactive "p")
714 (push-mark (point))
715 (hexl-goto-address (+ 0 (1- arg))))
716
717 (defun hexl-end-of-buffer (arg)
718 "Go to `hexl-max-address' minus ARG."
719 (interactive "p")
720 (push-mark (point))
721 (hexl-goto-address (- hexl-max-address (1- arg))))
722
723 (defun hexl-beginning-of-line ()
724 "Goto beginning of line in hexl mode."
725 (interactive)
726 (goto-char (+ (* (/ (point) 68) 68) 11)))
727
728 (defun hexl-end-of-line ()
729 "Goto end of line in hexl mode."
730 (interactive)
731 (hexl-goto-address (let ((address (logior (hexl-current-address) 15)))
732 (if (> address hexl-max-address)
733 (setq address hexl-max-address))
734 address)))
735
736 (defun hexl-scroll-down (arg)
737 "Scroll hexl buffer window upward ARG lines; or near full window if no ARG."
738 (interactive "P")
739 (if (null arg)
740 (setq arg (1- (window-height)))
741 (setq arg (prefix-numeric-value arg)))
742 (hexl-scroll-up (- arg)))
743
744 (defun hexl-scroll-up (arg)
745 "Scroll hexl buffer window upward ARG lines; or near full window if no ARG.
746 If there's no byte at the target address, move to the first or last line."
747 (interactive "P")
748 (if (null arg)
749 (setq arg (1- (window-height)))
750 (setq arg (prefix-numeric-value arg)))
751 (let* ((movement (* arg 16))
752 (address (hexl-current-address))
753 (dest (+ address movement)))
754 (cond
755 ;; If possible, try to stay at the same offset from the beginning
756 ;; of the 16-byte group, even if we move to the first or last
757 ;; group.
758 ((and (> dest hexl-max-address)
759 (>= (% hexl-max-address 16) (% address 16)))
760 (setq dest (+ (logand hexl-max-address -16) (% address 16))))
761 ((> dest hexl-max-address)
762 (setq dest hexl-max-address))
763 ((< dest 0)
764 (setq dest (% address 16))))
765 (if (/= dest (+ address movement))
766 (message "Out of hexl region."))
767 (hexl-goto-address dest)
768 (recenter 0)))
769
770 (defun hexl-beginning-of-1k-page ()
771 "Go to beginning of 1KB boundary."
772 (interactive)
773 (hexl-goto-address (logand (hexl-current-address) -1024)))
774
775 (defun hexl-end-of-1k-page ()
776 "Go to end of 1KB boundary."
777 (interactive)
778 (hexl-goto-address (let ((address (logior (hexl-current-address) 1023)))
779 (if (> address hexl-max-address)
780 (setq address hexl-max-address))
781 address)))
782
783 (defun hexl-beginning-of-512b-page ()
784 "Go to beginning of 512 byte boundary."
785 (interactive)
786 (hexl-goto-address (logand (hexl-current-address) -512)))
787
788 (defun hexl-end-of-512b-page ()
789 "Go to end of 512 byte boundary."
790 (interactive)
791 (hexl-goto-address (let ((address (logior (hexl-current-address) 511)))
792 (if (> address hexl-max-address)
793 (setq address hexl-max-address))
794 address)))
795
796 (defun hexl-quoted-insert (arg)
797 "Read next input character and insert it.
798 Useful for inserting control characters and non-ASCII characters given their
799 numerical code.
800 You may also type octal digits, to insert a character with that code."
801 (interactive "p")
802 (hexl-insert-multibyte-char (read-quoted-char) arg))
803
804 ;00000000: 0011 2233 4455 6677 8899 aabb ccdd eeff 0123456789ABCDEF
805
806 ;;;###autoload
807 (defun hexlify-buffer ()
808 "Convert a binary buffer to hexl format.
809 This discards the buffer's undo information."
810 (interactive)
811 (and (consp buffer-undo-list)
812 (or (y-or-n-p "Converting to hexl format discards undo info; ok? ")
813 (error "Aborted"))
814 (setq buffer-undo-list nil))
815 ;; Don't decode text in the ASCII part of `hexl' program output.
816 (let ((coding-system-for-read 'raw-text)
817 (coding-system-for-write buffer-file-coding-system)
818 (buffer-undo-list t))
819 (apply 'call-process-region (point-min) (point-max)
820 (expand-file-name hexl-program exec-directory)
821 t t nil
822 ;; Manually encode the args, otherwise they're encoded using
823 ;; coding-system-for-write (i.e. buffer-file-coding-system) which
824 ;; may not be what we want (e.g. utf-16 on a non-utf-16 system).
825 (mapcar (lambda (s)
826 (if (not (multibyte-string-p s)) s
827 (encode-coding-string s locale-coding-system)))
828 (split-string hexl-options)))
829 (if (> (point) (hexl-address-to-marker hexl-max-address))
830 (hexl-goto-address hexl-max-address))))
831
832 (defun dehexlify-buffer ()
833 "Convert a hexl format buffer to binary.
834 This discards the buffer's undo information."
835 (interactive)
836 (and (consp buffer-undo-list)
837 (or (y-or-n-p "Converting from hexl format discards undo info; ok? ")
838 (error "Aborted"))
839 (setq buffer-undo-list nil))
840 (let ((coding-system-for-write 'raw-text)
841 (coding-system-for-read buffer-file-coding-system)
842 (buffer-undo-list t))
843 (apply 'call-process-region (point-min) (point-max)
844 (expand-file-name hexl-program exec-directory)
845 t t nil "-de" (split-string hexl-options))))
846
847 (defun hexl-char-after-point ()
848 "Return char for ASCII hex digits at point."
849 (hexl-htoi (char-after (point))
850 (char-after (1+ (point)))))
851
852 (defun hexl-htoi (lh rh)
853 "Hex (char) LH (char) RH to integer."
854 (+ (* (hexl-hex-char-to-integer lh) 16)
855 (hexl-hex-char-to-integer rh)))
856
857 (defun hexl-hex-char-to-integer (character)
858 "Take a char and return its value as if it was a hex digit."
859 (if (and (>= character ?0) (<= character ?9))
860 (- character ?0)
861 (let ((ch (logior character 32)))
862 (if (and (>= ch ?a) (<= ch ?f))
863 (- ch (- ?a 10))
864 (error "Invalid hex digit `%c'" ch)))))
865
866 (defun hexl-oct-char-to-integer (character)
867 "Take a char and return its value as if it was a octal digit."
868 (if (and (>= character ?0) (<= character ?7))
869 (- character ?0)
870 (error "Invalid octal digit `%c'" character)))
871
872 (defun hexl-printable-character (ch)
873 "Return a displayable string for character CH."
874 (format "%c" (if (equal hexl-iso "")
875 (if (or (< ch 32) (>= ch 127))
876 46
877 ch)
878 (if (or (< ch 32) (and (>= ch 127) (< ch 160)))
879 46
880 ch))))
881
882 (defun hexl-insert-multibyte-char (ch num)
883 "Insert a possibly multibyte character CH NUM times.
884
885 Non-ASCII characters are first encoded with `buffer-file-coding-system',
886 and their encoded form is inserted byte by byte."
887 (let ((charset (char-charset ch))
888 (coding (if (or (null buffer-file-coding-system)
889 ;; coding-system-type equals t means undecided.
890 (eq (coding-system-type buffer-file-coding-system) t))
891 (default-value 'buffer-file-coding-system)
892 buffer-file-coding-system)))
893 (cond ((and (> ch 0) (< ch 256))
894 (hexl-insert-char ch num))
895 ((eq charset 'unknown)
896 (error
897 "0x%x -- invalid character code; use \\[hexl-insert-hex-string]"
898 ch))
899 (t
900 (let ((encoded (encode-coding-char ch coding))
901 (internal (string-as-unibyte (char-to-string ch)))
902 internal-hex)
903 ;; If encode-coding-char returns nil, it means our character
904 ;; cannot be safely encoded with buffer-file-coding-system.
905 ;; In that case, we offer to insert the internal representation
906 ;; of that character, byte by byte.
907 (when (null encoded)
908 (setq internal-hex
909 (mapconcat (function (lambda (c) (format "%x" c)))
910 internal " "))
911 (if (yes-or-no-p
912 (format
913 "Insert char 0x%x's internal representation \"%s\"? "
914 ch internal-hex))
915 (setq encoded internal)
916 (error
917 "Can't encode `0x%x' with this buffer's coding system; try \\[hexl-insert-hex-string]"
918 ch)))
919 (while (> num 0)
920 (mapc
921 (function (lambda (c) (hexl-insert-char c 1))) encoded)
922 (setq num (1- num))))))))
923
924 (defun hexl-self-insert-command (arg)
925 "Insert this character.
926 Interactively, with a numeric argument, insert this character that many times.
927
928 Non-ASCII characters are first encoded with `buffer-file-coding-system',
929 and their encoded form is inserted byte by byte."
930 (interactive "p")
931 (hexl-insert-multibyte-char last-command-event arg))
932
933 (defun hexl-insert-char (ch num)
934 "Insert the character CH NUM times in a hexl buffer.
935
936 CH must be a unibyte character whose value is between 0 and 255."
937 (if (or (< ch 0) (> ch 255))
938 (error "Invalid character 0x%x -- must be in the range [0..255]" ch))
939 (let ((address (hexl-current-address t)))
940 (while (> num 0)
941 (let ((hex-position
942 (+ (* (/ address 16) 68)
943 10 (point-min)
944 (* 2 (% address 16))
945 (/ (% address 16) 2)))
946 (ascii-position
947 (+ (* (/ address 16) 68) 51 (point-min) (% address 16)))
948 at-ascii-position)
949 (if (= (point) ascii-position)
950 (setq at-ascii-position t))
951 (goto-char hex-position)
952 (delete-char 2)
953 (insert (format "%02x" ch))
954 (goto-char ascii-position)
955 (delete-char 1)
956 (insert (hexl-printable-character ch))
957 (or (eq address hexl-max-address)
958 (setq address (1+ address)))
959 (hexl-goto-address address)
960 (if at-ascii-position
961 (progn
962 (beginning-of-line)
963 (forward-char 51)
964 (forward-char (% address 16)))))
965 (setq num (1- num)))))
966
967 ;; hex conversion
968
969 (defun hexl-insert-hex-char (arg)
970 "Insert a character given by its hexadecimal code ARG times at point."
971 (interactive "p")
972 (let ((num (hexl-hex-string-to-integer (read-string "Hex number: "))))
973 (if (< num 0)
974 (error "Hex number out of range")
975 (hexl-insert-multibyte-char num arg))))
976
977 (defun hexl-insert-hex-string (str arg)
978 "Insert hexadecimal string STR at point ARG times.
979 Embedded whitespace, dashes, and periods in the string are ignored."
980 (interactive "sHex string: \np")
981 (setq str (replace-regexp-in-string "[- \t.]" "" str))
982 (let ((chars '()))
983 (let ((len (length str))
984 (idx 0))
985 (if (eq (logand len 1) 1)
986 (let ((num (hexl-hex-string-to-integer (substring str 0 1))))
987 (setq chars (cons num chars))
988 (setq idx 1)))
989 (while (< idx len)
990 (let* ((nidx (+ idx 2))
991 (num (hexl-hex-string-to-integer (substring str idx nidx))))
992 (setq chars (cons num chars))
993 (setq idx nidx))))
994 (setq chars (nreverse chars))
995 (while (> arg 0)
996 (let ((chars chars))
997 (while chars
998 (hexl-insert-char (car chars) 1)
999 (setq chars (cdr chars))))
1000 (setq arg (- arg 1)))))
1001
1002 (defun hexl-insert-decimal-char (arg)
1003 "Insert a character given by its decimal code ARG times at point."
1004 (interactive "p")
1005 (let ((num (string-to-number (read-string "Decimal Number: "))))
1006 (if (< num 0)
1007 (error "Decimal number out of range")
1008 (hexl-insert-multibyte-char num arg))))
1009
1010 (defun hexl-insert-octal-char (arg)
1011 "Insert a character given by its octal code ARG times at point."
1012 (interactive "p")
1013 (let ((num (hexl-octal-string-to-integer (read-string "Octal Number: "))))
1014 (if (< num 0)
1015 (error "Decimal number out of range")
1016 (hexl-insert-multibyte-char num arg))))
1017
1018 (defun hexl-follow-ascii (&optional arg)
1019 "Toggle following ASCII in Hexl buffers.
1020 With prefix ARG, turn on following if and only if ARG is positive.
1021 When following is enabled, the ASCII character corresponding to the
1022 element under the point is highlighted.
1023 Customize the variable `hexl-follow-ascii' to disable this feature."
1024 (interactive "P")
1025 (let ((on-p (if arg
1026 (> (prefix-numeric-value arg) 0)
1027 (not hexl-ascii-overlay))))
1028
1029 (if on-p
1030 ;; turn it on
1031 (if (not hexl-ascii-overlay)
1032 (progn
1033 (setq hexl-ascii-overlay (make-overlay 1 1)
1034 hexl-follow-ascii t)
1035 (overlay-put hexl-ascii-overlay 'face 'highlight)
1036 (add-hook 'post-command-hook 'hexl-follow-ascii-find nil t)))
1037 ;; turn it off
1038 (if hexl-ascii-overlay
1039 (progn
1040 (delete-overlay hexl-ascii-overlay)
1041 (setq hexl-ascii-overlay nil
1042 hexl-follow-ascii nil)
1043 (remove-hook 'post-command-hook 'hexl-follow-ascii-find t)
1044 )))))
1045
1046 (defun hexl-activate-ruler ()
1047 "Activate `ruler-mode'."
1048 (require 'ruler-mode)
1049 (unless (boundp 'hexl-mode-old-ruler-function)
1050 (set (make-local-variable 'hexl-mode-old-ruler-function)
1051 ruler-mode-ruler-function))
1052 (set (make-local-variable 'ruler-mode-ruler-function)
1053 'hexl-mode-ruler)
1054 (ruler-mode 1))
1055
1056 (defun hexl-follow-line ()
1057 "Activate `hl-line-mode'."
1058 (require 'hl-line)
1059 (unless (boundp 'hexl-mode-old-hl-line-range-function)
1060 (set (make-local-variable 'hexl-mode-old-hl-line-range-function)
1061 hl-line-range-function))
1062 (unless (boundp 'hexl-mode-old-hl-line-face)
1063 (set (make-local-variable 'hexl-mode-old-hl-line-face)
1064 hl-line-face))
1065 (set (make-local-variable 'hl-line-range-function)
1066 'hexl-highlight-line-range)
1067 (set (make-local-variable 'hl-line-face)
1068 'highlight)
1069 (hl-line-mode 1))
1070
1071 (defun hexl-highlight-line-range ()
1072 "Return the range of address region for the point.
1073 This function is assumed to be used as callback function for `hl-line-mode'."
1074 (cons
1075 (line-beginning-position)
1076 ;; 9 stands for (length "87654321:")
1077 (+ (line-beginning-position) 9)))
1078
1079 (defun hexl-follow-ascii-find ()
1080 "Find and highlight the ASCII element corresponding to current point."
1081 (let ((pos (+ 51
1082 (- (point) (current-column))
1083 (mod (hexl-current-address) 16))))
1084 (move-overlay hexl-ascii-overlay pos (1+ pos))
1085 ))
1086
1087 (defun hexl-mode-ruler ()
1088 "Return a string ruler for hexl mode."
1089 (let* ((highlight (mod (hexl-current-address) 16))
1090 (s " 87654321 0011 2233 4455 6677 8899 aabb ccdd eeff 0123456789abcdef")
1091 (pos 0))
1092 (set-text-properties 0 (length s) nil s)
1093 ;; Turn spaces in the header into stretch specs so they work
1094 ;; regardless of the header-line face.
1095 (while (string-match "[ \t]+" s pos)
1096 (setq pos (match-end 0))
1097 (put-text-property (match-beginning 0) pos 'display
1098 ;; Assume fixed-size chars
1099 `(space :align-to ,(1- pos))
1100 s))
1101 ;; Highlight the current column.
1102 (put-text-property (+ 11 (/ (* 5 highlight) 2))
1103 (+ 13 (/ (* 5 highlight) 2))
1104 'face 'highlight s)
1105 ;; Highlight the current ascii column
1106 (put-text-property (+ 13 39 highlight) (+ 13 40 highlight)
1107 'face 'highlight s)
1108 s))
1109
1110 ;; startup stuff.
1111
1112 (easy-menu-define hexl-menu hexl-mode-map "Hexl Mode menu"
1113 `("Hexl"
1114 :help "Hexl-specific Features"
1115
1116 ["Backward short" hexl-backward-short
1117 :help "Move to left a short"]
1118 ["Forward short" hexl-forward-short
1119 :help "Move to right a short"]
1120 ["Backward word" hexl-backward-short
1121 :help "Move to left a word"]
1122 ["Forward word" hexl-forward-short
1123 :help "Move to right a word"]
1124 "-"
1125 ["Beginning of 512b page" hexl-beginning-of-512b-page
1126 :help "Go to beginning of 512 byte boundary"]
1127 ["End of 512b page" hexl-end-of-512b-page
1128 :help "Go to end of 512 byte boundary"]
1129 ["Beginning of 1K page" hexl-beginning-of-1k-page
1130 :help "Go to beginning of 1KB boundary"]
1131 ["End of 1K page" hexl-end-of-1k-page
1132 :help "Go to end of 1KB boundary"]
1133 "-"
1134 ["Go to address" hexl-goto-address
1135 :help "Go to hexl-mode (decimal) address"]
1136 ["Go to address" hexl-goto-hex-address
1137 :help "Go to hexl-mode (hex string) address"]
1138 "-"
1139 ["Insert decimal char" hexl-insert-decimal-char
1140 :help "Insert a character given by its decimal code"]
1141 ["Insert hex char" hexl-insert-hex-char
1142 :help "Insert a character given by its hexadecimal code"]
1143 ["Insert octal char" hexl-insert-octal-char
1144 :help "Insert a character given by its octal code"]
1145 "-"
1146 ["Exit hexl mode" hexl-mode-exit
1147 :help "Exit hexl mode returning to previous mode"]))
1148
1149 (provide 'hexl)
1150
1151 ;; arch-tag: d5a7aa8a-9bce-480b-bcff-6c4c7ca5ea4a
1152 ;;; hexl.el ends here