views:

63

answers:

2

I want to write a function, similar hexl-find-file, that will open a gzipped file and show the contents in the hexl-mode. How would I do that?

+2  A: 

Does this work for you?

(require 'jka-compr)
(defun hexl-find-file ()
  "call find file and then jump into hexl mode"
  (interactive)
  (call-interactively 'find-file)
  (hexl-mode 1))

The 'jka-compr provides the seamless compressed file handling, and the 'hexl-find-file just opens the file and turns on hexl-mode.

Trey Jackson
A: 

Turn on auto-compression-mode before you run hexl-find-file?

,----[ C-h f auto-compression-mode RET ]
| `auto-compression-mode' is an interactive compiled Lisp function
|   -- loaded from "/usr/share/xemacs21/xemacs-packages/lisp/os-utils/auto-autoloads"
| (auto-compression-mode &optional ARG)
| 
| Documentation:
| Toggle automatic file compression and uncompression.
| With prefix argument ARG, turn auto compression on if positive, else off.
| Returns the new status of auto compression (non-nil means on).
| 
| Invoked with:
| 
| M-x auto-compression-mode
`----
asjo
So, that doesn't actually work. `auto-compression-mode` is great, but hexl-find-file pointed at a GZipped file will open the compressed file for hex editing, rather than the original, uncompressed file. I tested this with GNU Emacs 23.2.1 on OS X.
R. P. Dillon
I wouldn't have posted the answer without testing it first. It works as expected (the gzip'ed file is unzipped before displayed in hexl-mode) in XEmacs 21.5 (Debian GNU/Linux).
asjo