5

When I use hexl-mode in emacs, it discards the buffer's undo info.
Is there another way to hex-edit the buffer and yet retain the undo info?

If there is no alternative hex-editor, is there a hex-viewer which can view the buffer? I have tried hexview-mode, but it doesn't view the actual buffer; it views the buffer's file (from disk), so I don't see the current edit.

0

There's nhexl-mode in ELPA, which uses overlays instead of rewriting the buffer, and thus keeps undo info.

2

Here is a function which copies the contents of the current buffer into a new buffer and runs hexl-mode on that:

(defun hexify-buffer-copy()
    "Edit current buffer in hexl mode by copying it"
    (let ((orig-buffer (current-buffer)))
         (switch-to-buffer (create-file-buffer
             (buffer-file-name orig-buffer)))
         (insert-buffer orig-buffer)
         (setq buffer-undo-list nil)
         (hexl-mode)))

Run with M-: (hexify-buffer-copy)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.