[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hexl-mode and scroll-down
From: |
Eli Zaretskii |
Subject: |
Re: hexl-mode and scroll-down |
Date: |
Mon, 2 Apr 2001 15:29:14 +0200 (IST) |
On Sun, 1 Apr 2001, robert wrote:
> I'm seeing this in a bare session on a variety of binary files. I
> load the file in fundamental mode (looks as if I wasn't clear on this
> bit!) scroll down a couple of times, then the next-line's and then
> scroll up. Get the error every time
Ah, I see the message now. Please try the change below and tell me if it
solves the problem:
--- lisp/hexl.e~0 Wed Oct 11 19:29:08 2000
+++ lisp/hexl.el Mon Apr 2 15:11:28 2001
@@ -541,18 +541,30 @@
(hexl-scroll-up (- arg)))
(defun hexl-scroll-up (arg)
- "Scroll hexl buffer window upward ARG lines; or near full window if no ARG."
+ "Scroll hexl buffer window upward ARG lines; or near full window if no ARG.
+If there's no byte at the target address, move to the first or last line."
(interactive "P")
(if (null arg)
(setq arg (1- (window-height)))
(setq arg (prefix-numeric-value arg)))
- (let ((movement (* arg 16))
- (address (hexl-current-address)))
- (if (or (> (+ address movement) hexl-max-address)
- (< (+ address movement) 0))
- (message "Out of hexl region.")
- (hexl-goto-address (+ address movement))
- (recenter 0))))
+ (let* ((movement (* arg 16))
+ (address (hexl-current-address))
+ (dest (+ address movement)))
+ (cond
+ ;; If possible, try to stay at the same offset from the beginning
+ ;; of the 16-byte group, even if we move to the first or last
+ ;; group.
+ ((and (> dest hexl-max-address)
+ (>= (% hexl-max-address 16) (% address 16)))
+ (setq dest (+ (logand hexl-max-address -16) (% address 16))))
+ ((> dest hexl-max-address)
+ (setq dest hexl-max-address))
+ ((< dest 0)
+ (setq dest (% address 16))))
+ (if (/= dest (+ address movement))
+ (message "Out of hexl region."))
+ (hexl-goto-address dest)
+ (recenter 0)))
(defun hexl-beginning-of-1k-page ()
"Go to beginning of 1k boundary."