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.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Peter.O
  • 32,426
  • 28
  • 115
  • 163

2 Answers2

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)

rocky
  • 1,978
  • 11
  • 23
0

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

jpkotta
  • 413
  • 2
  • 6
  • 18