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: Tue, 22 Jan 2008 14:50:31 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

  It does for auto-revert-mode (everything seems to work fine), however
with auto-revert-tail-mode it's even more broken. When I append to a
file externally and both auto-revert-tail-mode and hexl-mode are
activated, first emacs tells me:
"Converting to hexl format discards undo info; ok? (y or n)",
and when I answer "yes" the buffer fills with gibberish.

Sorry, my attempt was too simplistic.  Please try again with the
attached patch.  I think something better is needed, but an
important first step would be to test whether revert-buffer works
correctly whenever the file changes.
*** autorevert.el       Thu Jan 10 19:25:18 2008
--- autorevert.el       Tue Jan 22 14:24:16 2008
***************
*** 412,417 ****
--- 412,419 ----
         (not (memq major-mode
                  global-auto-revert-ignore-modes)))))
  
+ (defvar auto-revert-tail-is-revert-buffer nil)
+ 
  (defun auto-revert-handler ()
    "Revert current buffer, if appropriate.
  This is an internal function used by Auto-Revert Mode."
***************
*** 448,454 ****
                    (= (window-point window) (point-max))
                    (push window eoblist)))
           'no-mini t))
!       (if auto-revert-tail-mode
            (auto-revert-tail-handler size)
          ;; Bind buffer-read-only in case user has done C-x C-q,
          ;; so as not to forget that.  This gives undesirable results
--- 450,457 ----
                    (= (window-point window) (point-max))
                    (push window eoblist)))
           'no-mini t))
!       (if (and auto-revert-tail-mode
!                (not auto-revert-tail-is-revert-buffer))
            (auto-revert-tail-handler size)
          ;; Bind buffer-read-only in case user has done C-x C-q,
          ;; so as not to forget that.  This gives undesirable results

*** hexl.el     Thu Jan 10 19:25:24 2008
--- hexl.el     Tue Jan 22 14:27:52 2008
***************
*** 136,141 ****
--- 136,144 ----
  
  (put 'hexl-mode 'mode-class 'special)
  
+ (defvar auto-revert-tail-is-revert-buffer)
+ (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))))
--- 214,220 ----
  
  \\[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))))
***************
*** 249,254 ****
--- 252,259 ----
      (setq hexl-mode-old-mode-name mode-name)
      (setq mode-name "Hexl")
  
+     (set (make-local-variable 'auto-revert-tail-is-revert-buffer) t)
+ 
      (set (make-local-variable 'hexl-mode-old-isearch-search-fun-function)
         isearch-search-fun-function)
      (set (make-local-variable 'isearch-search-fun-function)
***************
*** 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)
  
--- 327,334 ----
    (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)
  
***************
*** 388,393 ****
--- 394,401 ----
          (or (bobp) (setq original-point (1+ original-point))))
        (goto-char original-point)))
  
+   (setq auto-revert-tail-is-revert-buffer nil)
+ 
    (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)


reply via email to

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