在 emacs 中,有没有办法在不丢失撤消信息的情况下对缓冲区进行十六进制编辑/查看?

Pet*_*r.O 5 emacs binary hex

当我在 emacs 中使用hexl-mode时,它会丢弃缓冲区的撤消信息。
有没有另一种方法可以对缓冲区进行十六进制编辑并保留撤消信息?

如果没有替代的十六进制编辑器,是否有可以查看缓冲区的十六进制查看器?我试过hexview-mode,但它没有查看实际的缓冲区;它查看缓冲区的文件(从磁盘),所以我看不到当前的编辑。

roc*_*cky 2

这是一个将当前缓冲区的内容复制到新缓冲区并在其上运行 hexl-mode 的函数:

(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 Code Online (Sandbox Code Playgroud)

运行与M-: (hexify-buffer-copy)