Mercurial > emacs
comparison lisp/hexl.el @ 19113:c21a3a07b6fd
(hexlify-buffer, dehexlify-buffer):
Pay attention to buffer-file-type.
(hexl-save-buffer): Don't bind buffer-file-type around save-buffer.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 04 Aug 1997 02:44:42 +0000 |
parents | 13df6938d925 |
children | 3b008d891adb |
comparison
equal
deleted
inserted
replaced
19112:3940bb7f5515 | 19113:c21a3a07b6fd |
---|---|
253 (set-buffer buf) | 253 (set-buffer buf) |
254 (insert-buffer-substring name start end) | 254 (insert-buffer-substring name start end) |
255 (set-buffer name) | 255 (set-buffer name) |
256 (dehexlify-buffer) | 256 (dehexlify-buffer) |
257 ;; Prevent infinite recursion. | 257 ;; Prevent infinite recursion. |
258 (let ((hexl-in-save-buffer t) | 258 (let ((hexl-in-save-buffer t)) |
259 (buffer-file-type t)) ; for ms-dos | |
260 (save-buffer)) | 259 (save-buffer)) |
261 (setq modified (buffer-modified-p)) | 260 (setq modified (buffer-modified-p)) |
262 (delete-region (point-min) (point-max)) | 261 (delete-region (point-min) (point-max)) |
263 (insert-buffer-substring buf start end) | 262 (insert-buffer-substring buf start end) |
264 (kill-buffer buf) | 263 (kill-buffer buf) |
271 ;;;###autoload | 270 ;;;###autoload |
272 (defun hexl-find-file (filename) | 271 (defun hexl-find-file (filename) |
273 "Edit file FILENAME in hexl-mode. | 272 "Edit file FILENAME in hexl-mode. |
274 Switch to a buffer visiting file FILENAME, creating one in none exists." | 273 Switch to a buffer visiting file FILENAME, creating one in none exists." |
275 (interactive "fFilename: ") | 274 (interactive "fFilename: ") |
276 (if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt)) | 275 (find-file-literally filename) |
277 (find-file-binary filename) | |
278 (find-file filename)) | |
279 (if (not (eq major-mode 'hexl-mode)) | 276 (if (not (eq major-mode 'hexl-mode)) |
280 (hexl-mode))) | 277 (hexl-mode))) |
281 | 278 |
282 (defun hexl-mode-exit (&optional arg) | 279 (defun hexl-mode-exit (&optional arg) |
283 "Exit Hexl mode, returning to previous mode. | 280 "Exit Hexl mode, returning to previous mode. |
579 (and buffer-undo-list | 576 (and buffer-undo-list |
580 (or (y-or-n-p "Converting to hexl format discards undo info; ok? ") | 577 (or (y-or-n-p "Converting to hexl format discards undo info; ok? ") |
581 (error "Aborted"))) | 578 (error "Aborted"))) |
582 (setq buffer-undo-list nil) | 579 (setq buffer-undo-list nil) |
583 (let ((binary-process-output nil) ; for Ms-Dos | 580 (let ((binary-process-output nil) ; for Ms-Dos |
584 (binary-process-input t) | 581 (binary-process-input buffer-file-type) |
582 (coding-system-for-write 'no-conversion) | |
585 (buffer-undo-list t)) | 583 (buffer-undo-list t)) |
586 (shell-command-on-region (point-min) (point-max) hexlify-command t))) | 584 (shell-command-on-region (point-min) (point-max) hexlify-command t))) |
587 | 585 |
588 (defun dehexlify-buffer () | 586 (defun dehexlify-buffer () |
589 "Convert a hexl format buffer to binary. | 587 "Convert a hexl format buffer to binary. |
591 (interactive) | 589 (interactive) |
592 (and buffer-undo-list | 590 (and buffer-undo-list |
593 (or (y-or-n-p "Converting from hexl format discards undo info; ok? ") | 591 (or (y-or-n-p "Converting from hexl format discards undo info; ok? ") |
594 (error "Aborted"))) | 592 (error "Aborted"))) |
595 (setq buffer-undo-list nil) | 593 (setq buffer-undo-list nil) |
596 (let ((binary-process-output t) ; for Ms-Dos | 594 (let ((binary-process-output buffer-file-type) ; for Ms-Dos |
597 (binary-process-input nil) | 595 (binary-process-input nil) |
596 (coding-system-for-read 'no-conversion) | |
598 (buffer-undo-list t)) | 597 (buffer-undo-list t)) |
599 (shell-command-on-region (point-min) (point-max) dehexlify-command t))) | 598 (shell-command-on-region (point-min) (point-max) dehexlify-command t))) |
600 | 599 |
601 (defun hexl-char-after-point () | 600 (defun hexl-char-after-point () |
602 "Return char for ASCII hex digits at point." | 601 "Return char for ASCII hex digits at point." |