+(defun hexl-mode-ruler ()
+ "Return a string ruler for hexl mode."
+ (let* ((highlight (mod (hexl-current-address) 16))
+ (s " 87654321 0011 2233 4455 6677 8899 aabb ccdd eeff 0123456789abcdef")
+ (pos 0))
+ (set-text-properties 0 (length s) nil s)
+ ;; Turn spaces in the header into stretch specs so they work
+ ;; regardless of the header-line face.
+ (while (string-match "[ \t]+" s pos)
+ (setq pos (match-end 0))
+ (put-text-property (match-beginning 0) pos 'display
+ ;; Assume fixed-size chars
+ `(space :align-to ,(1- pos))
+ s))
+ ;; Highlight the current column.
+ (put-text-property (+ 11 (/ (* 5 highlight) 2))
+ (+ 13 (/ (* 5 highlight) 2))
+ 'face 'highlight s)
+ ;; Highlight the current ascii column
+ (put-text-property (+ 13 39 highlight) (+ 13 40 highlight)
+ 'face 'highlight s)
+ s))
+