emacs-devel
[Top][All Lists]
Advanced

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

Re: 23.0.50; hexl-mode and auto-revert-mode incompatibilities


From: martin rudalics
Subject: Re: 23.0.50; hexl-mode and auto-revert-mode incompatibilities
Date: Mon, 21 Jan 2008 14:38:24 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

>   If I open a file in emacs, enable both hexl-mode and
> auto-revert-mode in its buffer and then modify the content of the file
> externally, the buffer gets refreshed but its content seems... rather
> littered. C-l doesn't fix it.
>
>   I have similar problems with "auto-revert-tail-mode", but not when I
> revert the buffer "manually" with M-x revert-buffer.
>
>   It seems that when the buffer gets refreshed, it behaves as if
> hexl-mode was not here (for instance with auto-revert-tail-mode, it
> just appends the text, without printing the hex values) but I'm not
> sure about what's going on here.

It's because `auto-revert-mode' doesn't reset the major mode when
reverting the buffer and `hexl-mode' does nothing when the buffer is
already in `hexl-mode'.  Does the attached patch give good results?
*** hexl.el.~1.115.~    Sat Oct 27 12:07:12 2007
--- hexl.el     Mon Jan 21 14:32:58 2008
***************
*** 136,141 ****
--- 136,143 ----
  
  (put 'hexl-mode 'mode-class 'special)
  
+ (defvar hexl-revert nil)
+ 
  ;;;###autoload
  (defun hexl-mode (&optional arg)
    "\\<hexl-mode-map>A mode for editing binary files in hex dump format.
***************
*** 211,217 ****
  
  \\[describe-bindings] for advanced commands."
    (interactive "p")
!   (unless (eq major-mode 'hexl-mode)
      (let ((modified (buffer-modified-p))
          (inhibit-read-only t)
          (original-point (- (point) (point-min))))
--- 213,219 ----
  
  \\[describe-bindings] for advanced commands."
    (interactive "p")
!   (unless (and (eq major-mode 'hexl-mode) (not hexl-revert))
      (let ((modified (buffer-modified-p))
          (inhibit-read-only t)
          (original-point (- (point) (point-min))))
***************
*** 322,328 ****
    (remove-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer t))
  
  (defun hexl-after-revert-hook ()
!   (hexl-mode))
  
  (defvar hexl-in-save-buffer nil)
  
--- 324,331 ----
    (remove-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer t))
  
  (defun hexl-after-revert-hook ()
!   (let ((hexl-revert t))
!     (hexl-mode)))
  
  (defvar hexl-in-save-buffer nil)
  

reply via email to

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