diff options
| author | Richard M. Stallman | 1994-07-12 07:25:31 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-07-12 07:25:31 +0000 |
| commit | 8eeac2cebd36cc1df63121530acf6c862787cd0e (patch) | |
| tree | e616dea7606cfca88a1b3125669dc8bbf0b44dda | |
| parent | 4638b80645e62c31911f669a7248449f21caaa44 (diff) | |
| download | emacs-8eeac2cebd36cc1df63121530acf6c862787cd0e.tar.gz emacs-8eeac2cebd36cc1df63121530acf6c862787cd0e.zip | |
(hexl-maybe-dehexlify-buffer): New function.
(hexl-mode): Add it to change-major-mode-hook.
(hexl-mode-exit): Remove kludge for mode-line update.
(hexlify-buffer): Doc fix.
| -rw-r--r-- | lisp/hexl.el | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lisp/hexl.el b/lisp/hexl.el index f45540c599d..2043196a637 100644 --- a/lisp/hexl.el +++ b/lisp/hexl.el | |||
| @@ -172,6 +172,9 @@ You can use \\[hexl-find-file] to visit a file in hexl-mode. | |||
| 172 | 172 | ||
| 173 | (make-local-variable 'hexl-max-address) | 173 | (make-local-variable 'hexl-max-address) |
| 174 | 174 | ||
| 175 | (make-local-variable 'change-major-mode-hook) | ||
| 176 | (add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer) | ||
| 177 | |||
| 175 | (let ((modified (buffer-modified-p)) | 178 | (let ((modified (buffer-modified-p)) |
| 176 | (inhibit-read-only t) | 179 | (inhibit-read-only t) |
| 177 | (original-point (1- (point)))) | 180 | (original-point (1- (point)))) |
| @@ -241,9 +244,19 @@ With arg, don't unhexlify buffer." | |||
| 241 | (setq mode-name hexl-mode-old-mode-name) | 244 | (setq mode-name hexl-mode-old-mode-name) |
| 242 | (use-local-map hexl-mode-old-local-map) | 245 | (use-local-map hexl-mode-old-local-map) |
| 243 | (setq major-mode hexl-mode-old-major-mode) | 246 | (setq major-mode hexl-mode-old-major-mode) |
| 244 | ;; Kludge to update mode-line | 247 | (force-mode-line-update)) |
| 245 | (switch-to-buffer (current-buffer)) | 248 | |
| 246 | ) | 249 | (defun hexl-maybe-dehexlify-buffer () |
| 250 | "Convert a hexl format buffer to binary. | ||
| 251 | Ask the user for confirmation." | ||
| 252 | (if (y-or-n-p "Convert contents back to binary format? ") | ||
| 253 | (let ((modified (buffer-modified-p)) | ||
| 254 | (inhibit-read-only t) | ||
| 255 | (original-point (1+ (hexl-current-address)))) | ||
| 256 | (dehexlify-buffer) | ||
| 257 | (remove-hook 'write-contents-hook 'hexl-save-buffer) | ||
| 258 | (set-buffer-modified-p modified) | ||
| 259 | (goto-char original-point)))) | ||
| 247 | 260 | ||
| 248 | (defun hexl-current-address () | 261 | (defun hexl-current-address () |
| 249 | "Return current hexl-address." | 262 | "Return current hexl-address." |
| @@ -498,7 +511,7 @@ You may also type up to 3 octal digits, to insert a character with that code" | |||
| 498 | 511 | ||
| 499 | ;;;###autoload | 512 | ;;;###autoload |
| 500 | (defun hexlify-buffer () | 513 | (defun hexlify-buffer () |
| 501 | "Convert a binary buffer to hexl format" | 514 | "Convert a binary buffer to hexl format." |
| 502 | (interactive) | 515 | (interactive) |
| 503 | (let ((binary-process-output nil) ; for Ms-Dos | 516 | (let ((binary-process-output nil) ; for Ms-Dos |
| 504 | (binary-process-input t)) | 517 | (binary-process-input t)) |