summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2001-04-03 14:13:46 +0000
committerEli Zaretskii <eliz@gnu.org>2001-04-03 14:13:46 +0000
commitd565f6aa3f475edc638be1a4f9d97110804e0f1f (patch)
tree30802efe310884f01d7ea3624f6e18fdeca34fc8
parentb3f6107b74cab06c5017e957a1075bae7a0e27a0 (diff)
downloademacs-d565f6aa3f475edc638be1a4f9d97110804e0f1f.tar.gz
(hexl-scroll-up): If scrolling gets outside the hexl
region, position point on the first or last 16-byte group. (hexl-mode-map): Bind C-Home and C-End to hexl-beginning-of-buffer and hexl-end-of-buffer. Bind End and Home to hexl-end-of-line and hexl-beginning-of-line.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/hexl.el37
2 files changed, 34 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 186220017cf..3516ae019d7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2001-04-03 Eli Zaretskii <eliz@is.elta.co.il>
+
+ * hexl.el (hexl-scroll-up): If scrolling gets outside the hexl
+ region, position point on the first or last 16-byte group.
+ (hexl-mode-map): Bind C-Home and C-End to hexl-beginning-of-buffer
+ and hexl-end-of-buffer. Bind End and Home to hexl-end-of-line and
+ hexl-beginning-of-line.
+
2001-04-03 Gerd Moellmann <gerd@gnu.org>
* startup.el (fancy-splash-head): Use splash8.xpm for color
diff --git a/lisp/hexl.el b/lisp/hexl.el
index 293226a15d2..a2ddded9fe3 100644
--- a/lisp/hexl.el
+++ b/lisp/hexl.el
@@ -336,7 +336,7 @@ Ask the user for confirmation."
(defun hexl-current-address (&optional validate)
"Return current hexl-address."
(interactive)
- (let ((current-column (- (% (point) 68) 11))
+ (let ((current-column (- (% (point) 68) 11))
(hexl-address 0))
(if (< current-column 0)
(if validate
@@ -541,18 +541,30 @@ With prefix arg N, puts point N bytes of the way from the true beginning."
(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."
@@ -772,7 +784,7 @@ Customize the variable `hexl-follow-ascii' to disable this feature."
(defun hexl-follow-ascii-find ()
"Find and highlight the ASCII element corresponding to current point."
- (let ((pos (+ 51
+ (let ((pos (+ 51
(- (point) (current-column))
(mod (hexl-current-address) 16))))
(move-overlay hexl-ascii-overlay pos (1+ pos))
@@ -792,7 +804,10 @@ Customize the variable `hexl-follow-ascii' to disable this feature."
(define-key hexl-mode-map [M-right] 'hexl-forward-short)
(define-key hexl-mode-map [next] 'hexl-scroll-up)
(define-key hexl-mode-map [prior] 'hexl-scroll-down)
- (define-key hexl-mode-map [home] 'hexl-beginning-of-buffer)
+ (define-key hexl-mode-map [home] 'hexl-beginning-of-line)
+ (define-key hexl-mode-map [end] 'hexl-end-of-line)
+ (define-key hexl-mode-map [C-home] 'hexl-beginning-of-buffer)
+ (define-key hexl-mode-map [C-end] 'hexl-end-of-buffer)
(define-key hexl-mode-map [deletechar] 'undefined)
(define-key hexl-mode-map [deleteline] 'undefined)
(define-key hexl-mode-map [insertline] 'undefined)