aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2018-05-30 20:30:07 +0300
committerEli Zaretskii2018-05-30 20:30:07 +0300
commitaa175a40586c1021549e775b30fb03b4ffb09ac0 (patch)
tree340d10918ffaa4dc85fe0dd6f625de9abf13f614
parentb8e7749b3384ea14ca22be4d3adb8659f462ea06 (diff)
downloademacs-aa175a40586c1021549e775b30fb03b4ffb09ac0.tar.gz
emacs-aa175a40586c1021549e775b30fb03b4ffb09ac0.zip
Adapt hexl-mode to native line-number display
* lisp/hexl.el (hexl-mode-ruler): When display-line-numbers is in effect, adjust offsets and columns to account for the line-number display. (Bug#31595)
-rw-r--r--lisp/hexl.el14
1 files changed, 11 insertions, 3 deletions
diff --git a/lisp/hexl.el b/lisp/hexl.el
index d716405f97a..2c1a7de48a7 100644
--- a/lisp/hexl.el
+++ b/lisp/hexl.el
@@ -1104,8 +1104,15 @@ This function is assumed to be used as callback function for `hl-line-mode'."
1104 "Return a string ruler for Hexl mode." 1104 "Return a string ruler for Hexl mode."
1105 (let* ((highlight (mod (hexl-current-address) 16)) 1105 (let* ((highlight (mod (hexl-current-address) 16))
1106 (s (cdr (assq hexl-bits hexl-rulers))) 1106 (s (cdr (assq hexl-bits hexl-rulers)))
1107 (pos 0)) 1107 (pos 0)
1108 (lnum-width
1109 (if display-line-numbers
1110 (round (line-number-display-width 'columns))
1111 0)))
1108 (set-text-properties 0 (length s) nil s) 1112 (set-text-properties 0 (length s) nil s)
1113 (when (> lnum-width 0)
1114 (setq s (concat (make-string lnum-width ? ) s))
1115 (setq pos (+ pos lnum-width)))
1109 ;; Turn spaces in the header into stretch specs so they work 1116 ;; Turn spaces in the header into stretch specs so they work
1110 ;; regardless of the header-line face. 1117 ;; regardless of the header-line face.
1111 (while (string-match "[ \t]+" s pos) 1118 (while (string-match "[ \t]+" s pos)
@@ -1116,10 +1123,11 @@ This function is assumed to be used as callback function for `hl-line-mode'."
1116 s)) 1123 s))
1117 ;; Highlight the current column. 1124 ;; Highlight the current column.
1118 (let ( (offset (+ (* 2 highlight) (/ (* 8 highlight) hexl-bits))) ) 1125 (let ( (offset (+ (* 2 highlight) (/ (* 8 highlight) hexl-bits))) )
1126 (if (> lnum-width 0) (setq offset (+ offset lnum-width)))
1119 (put-text-property (+ 11 offset) (+ 13 offset) 'face 'highlight s)) 1127 (put-text-property (+ 11 offset) (+ 13 offset) 'face 'highlight s))
1120 ;; Highlight the current ascii column 1128 ;; Highlight the current ascii column
1121 (put-text-property (+ (hexl-ascii-start-column) highlight 1) 1129 (put-text-property (+ (hexl-ascii-start-column) lnum-width highlight 1)
1122 (+ (hexl-ascii-start-column) highlight 2) 1130 (+ (hexl-ascii-start-column) lnum-width highlight 2)
1123 'face 'highlight s) 1131 'face 'highlight s)
1124 s)) 1132 s))
1125 1133