Subject: bug#4941: hexl mode update (variable word size in hexl mode)

From: Vivek Dasmohapatra <[email-masked]>
Date: Fri, 13 Apr 2012 01:39:51 +0100 (BST)

> `-mode' functions don't usually take additional arguments to control
> setup, so I think having a defcustom here is fine.  I've applied your
> patch to the Emacs trunk.

As I noted earlier, a user found a bug in the display code when
editing files in hexl - the hex portion of the display would get
scrambled when the word size was <> 16 bits.

The attached patch should fix that problem.
--- a/lisp/hexl.el
+++ b/lisp/hexl.el
@@ -249,7 +249,6 @@ as that will override any bit grouping options set here."
 (defun hexl-line-displen ()
   "The length of a hexl display line (varies with `hexl-bits')."
   (+ 60 (/ 128 (or hexl-bits 16))))
-;; --
 
 (defun hexl-mode--minor-mode-p (var)
   (memq var '(ruler-mode hl-line-mode)))
@@ -964,11 +963,7 @@ CH must be a unibyte character whose value is between 0 and 255."
       (error "Invalid character 0x%x -- must be in the range [0..255]" ch))
   (let ((address (hexl-current-address t)))
     (while (> num 0)
-      (let ((hex-position
-	     (+ (* (/ address 16) (hexl-line-displen))
-		10 (point-min)
-		(* 2 (% address 16))
-		(/ (% address 16) 2)))
+      (let ((hex-position (hexl-address-to-marker address))
 	    (ascii-position
 	     (+ (* (/ address 16) (hexl-line-displen)) 
                 (hexl-ascii-start-column)