summaryrefslogtreecommitdiff
path: root/lisp/hexl.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1996-06-10 17:00:06 +0000
committerRichard M. Stallman <rms@gnu.org>1996-06-10 17:00:06 +0000
commit7a9d1e81406ecfafa8ddca06e090b86ef3f658f4 (patch)
tree6698795c5f0209002e86e32df70405a387801154 /lisp/hexl.el
parent491da9fe0791719f1cbb3c40b545e415696bfdcf (diff)
downloademacs-7a9d1e81406ecfafa8ddca06e090b86ef3f658f4.tar.gz
(hexl-mode): Set hexl-max-address early on
and call hexl-goto-address afterward. And call hexlify-buffer even earlier.
Diffstat (limited to 'lisp/hexl.el')
-rw-r--r--lisp/hexl.el32
1 files changed, 17 insertions, 15 deletions
diff --git a/lisp/hexl.el b/lisp/hexl.el
index c7aa33a4c94..710b271701c 100644
--- a/lisp/hexl.el
+++ b/lisp/hexl.el
@@ -163,6 +163,22 @@ You can use \\[hexl-find-file] to visit a file in hexl-mode.
(if (eq major-mode 'hexl-mode)
(error "You are already in hexl mode")
+ (let ((modified (buffer-modified-p))
+ (inhibit-read-only t)
+ (original-point (1- (point)))
+ max-address)
+ (and (eobp) (not (bobp))
+ (setq original-point (1- original-point)))
+ (if (not (or (eq arg 1) (not arg)))
+ ;; if no argument then we guess at hexl-max-address
+ (setq max-address (+ (* (/ (1- (buffer-size)) 68) 16) 15))
+ (setq max-address (1- (buffer-size)))
+ (hexlify-buffer)
+ (set-buffer-modified-p modified))
+ (make-local-variable 'hexl-max-address)
+ (setq hexl-max-address max-address)
+ (hexl-goto-address original-point))
+
;; We do not turn off the old major mode; instead we just
;; override most of it. That way, we can restore it perfectly.
(make-local-variable 'hexl-mode-old-local-map)
@@ -197,21 +213,7 @@ You can use \\[hexl-find-file] to visit a file in hexl-mode.
(make-local-hook 'change-major-mode-hook)
(add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer nil t)
-
- (make-local-variable 'hexl-max-address)
-
- (let ((modified (buffer-modified-p))
- (inhibit-read-only t)
- (original-point (1- (point))))
- (and (eobp) (not (bobp))
- (setq original-point (1- original-point)))
- (if (not (or (eq arg 1) (not arg)))
- ;; if no argument then we guess at hexl-max-address
- (setq hexl-max-address (+ (* (/ (1- (buffer-size)) 68) 16) 15))
- (setq hexl-max-address (1- (buffer-size)))
- (hexlify-buffer)
- (set-buffer-modified-p modified)
- (hexl-goto-address original-point)))))
+))
(defun hexl-after-revert-hook ()
(hexlify-buffer)