emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hexl-mode's offer to "Convert contents back to binary format?" doesn


From: Chris Moore
Subject: Re: hexl-mode's offer to "Convert contents back to binary format?" doesn't
Date: Tue, 16 Jan 2007 18:02:26 +0100

On 1/14/07, Richard Stallman <address@hidden> wrote:
It seems that hexl-mode needs to set up
revert-buffer-insert-file-contents-function
so that it will hexlify the new contents.

Would someone please do that and ack?

There's a lot of code in revert-buffer which doesn't get used if you
set up revert-buffer-insert-file-contents-function.  Code which checks
for conditions like "File %s no longer exists!" and "File %s no longer
readable!"

The following patch fixes the problem:

--- old/hexl.el 2007-01-11 23:32:03.000000000 +0100
+++ hexl.el     2007-01-16 17:46:16.000000000 +0100
@@ -283,6 +283,7 @@
    (setq font-lock-defaults '(hexl-font-lock-keywords t))

    ;; Add hooks to rehexlify or dehexlify on various events.
+    (add-hook 'before-revert-hook 'hexl-before-revert-hook nil t)
    (add-hook 'after-revert-hook 'hexl-after-revert-hook nil t)

    (add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer nil t)
@@ -317,10 +318,11 @@
    (let ((isearch-search-fun-function nil))
      (isearch-search-fun))))

+(defun hexl-before-revert-hook ()
+  (remove-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer t))
+
(defun hexl-after-revert-hook ()
-  (setq hexl-max-address (1- (buffer-size)))
-  (hexlify-buffer)
-  (set-buffer-modified-p nil))
+  (hexl-mode))

(defvar hexl-in-save-buffer nil)

@@ -386,6 +388,7 @@
          (or (bobp) (setq original-point (1+ original-point))))
        (goto-char original-point)))

+  (remove-hook 'before-revert-hook 'hexl-before-revert-hook t)
  (remove-hook 'after-revert-hook 'hexl-after-revert-hook t)
  (remove-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer t)
  (remove-hook 'post-command-hook 'hexl-follow-ascii-find t)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]