Subject: hexl-revert-buffer
From: Daiki Ueno <[email-masked]>
To: [email-masked]
Date: Wed, 20 Oct 2010 14:57:13 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

If I open a ZIP file with M-x hexl-find-file and then M-x revert-buffer,
I see hexified file list generated by arc-mode, instead of raw ZIP data.

This behavior is surprising for me and it is cumbersome to do M-x
kill-buffer and M-x hexl-find-file each time.

How about adding M-x hexl-revert-buffer?

=== modified file 'lisp/hexl.el'
--- lisp/hexl.el	2010-10-10 23:12:30 +0000
+++ lisp/hexl.el	2010-10-20 05:46:47 +0000
@@ -189,6 +189,7 @@
     (define-key map "\C-x\C-p" 'undefined)
     (define-key map "\C-x\C-s" 'hexl-save-buffer)
     (define-key map "\C-x\C-t" 'undefined)
+    (define-key map "\C-xg" 'hexl-revert-buffer)
     map))
 
 ;; Variable declarations for suppressing warnings from the byte-compiler.
@@ -464,6 +465,16 @@
   (if (not (eq major-mode 'hexl-mode))
       (hexl-mode)))
 
+(defun hexl-revert-buffer ()
+  "Revert the buffer previously opened with `hexl-find-file'."
+  (interactive)
+  (if (eq major-mode 'hexl-mode)
+      (let ((coding-system-for-read 'no-conversion))
+	(revert-buffer nil nil t)
+	(setq major-mode 'fundamental-mode)
+	(hexl-mode))
+    (call-interactively #'revert-buffer)))
+
 (defun hexl-mode-exit (&optional arg)
   "Exit Hexl mode, returning to previous mode.
 With arg, don't unhexlify buffer."

Regards,
-- 
Daiki Ueno