Commit f77c618f authored by Chong Yidong's avatar Chong Yidong

(hexl-before-revert-hook): New function.

(hexl-mode): Use it.
(hexl-after-revert-hook): Just call hexl-mode.
(hexl-mode-exit): Remove before-revert-hook.
parent 66d237e2
...@@ -283,6 +283,7 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode. ...@@ -283,6 +283,7 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode.
(setq font-lock-defaults '(hexl-font-lock-keywords t)) (setq font-lock-defaults '(hexl-font-lock-keywords t))
;; Add hooks to rehexlify or dehexlify on various events. ;; 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 'after-revert-hook 'hexl-after-revert-hook nil t)
(add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer nil t) (add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer nil t)
...@@ -317,10 +318,11 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode. ...@@ -317,10 +318,11 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode.
(let ((isearch-search-fun-function nil)) (let ((isearch-search-fun-function nil))
(isearch-search-fun)))) (isearch-search-fun))))
(defun hexl-before-revert-hook ()
(remove-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer t))
(defun hexl-after-revert-hook () (defun hexl-after-revert-hook ()
(setq hexl-max-address (1- (buffer-size))) (hexl-mode))
(hexlify-buffer)
(set-buffer-modified-p nil))
(defvar hexl-in-save-buffer nil) (defvar hexl-in-save-buffer nil)
...@@ -386,6 +388,7 @@ With arg, don't unhexlify buffer." ...@@ -386,6 +388,7 @@ With arg, don't unhexlify buffer."
(or (bobp) (setq original-point (1+ original-point)))) (or (bobp) (setq original-point (1+ original-point))))
(goto-char 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 'after-revert-hook 'hexl-after-revert-hook t)
(remove-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer t) (remove-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer t)
(remove-hook 'post-command-hook 'hexl-follow-ascii-find t) (remove-hook 'post-command-hook 'hexl-follow-ascii-find t)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment