summaryrefslogtreecommitdiff
path: root/lisp/hexl.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2020-10-11 17:08:25 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2020-10-11 17:08:25 -0400
commit562686ca60ca4a5de48ba37b7a8ec98c9eb66550 (patch)
tree2937f39be8ae77aa882506f9c722350e4d347d82 /lisp/hexl.el
parentdb7b4dbe946e09d0bcb211aff446ba72feab3b47 (diff)
downloademacs-562686ca60ca4a5de48ba37b7a8ec98c9eb66550.tar.gz
* lisp/hexl.el: Fix behavior with variable-pitch `header-line` face
(hexl-ascii-region): Don't inherit from the `header-line`. (hexl-font-lock-keywords): Fix text alignment. (hexl-mode): Set `font-lock-extra-managed-props` accordingly.
Diffstat (limited to 'lisp/hexl.el')
-rw-r--r--lisp/hexl.el21
1 files changed, 17 insertions, 4 deletions
diff --git a/lisp/hexl.el b/lisp/hexl.el
index 0c31d964577..5d813c410c2 100644
--- a/lisp/hexl.el
+++ b/lisp/hexl.el
@@ -93,7 +93,15 @@ as that will override any bit grouping options set here."
"Face used in address area of Hexl mode buffer.")
(defface hexl-ascii-region
- '((t (:inherit header-line)))
+ ;; Copied from `header-line`. We used to inherit from it, but that
+ ;; looks awful when the headerline is given a variable-pitch font or
+ ;; (even worse) a 3D look.
+ '((((class color grayscale) (background light))
+ :background "grey90" :foreground "grey20"
+ :box nil)
+ (((class color grayscale) (background dark))
+ :background "grey20" :foreground "grey90"
+ :box nil))
"Face used in ASCII area of Hexl mode buffer.")
(defvar-local hexl-max-address 0
@@ -209,10 +217,14 @@ as that will override any bit grouping options set here."
(make-variable-buffer-local 'hexl-ascii-overlay)
(defvar hexl-font-lock-keywords
- '(("^\\([0-9a-f]+:\\).\\{40\\} \\(.+$\\)"
- ;; "^\\([0-9a-f]+:\\).+ \\(.+$\\)"
+ '(("^\\([0-9a-f]+:\\)\\( \\).\\{39\\}\\( \\)\\(.+$\\)"
+ ;; "^\\([0-9a-f]+:\\).+ \\(.+$\\)"v
(1 'hexl-address-region t t)
- (2 'hexl-ascii-region t t)))
+ ;; If `hexl-address-region' is using a variable-pitch font, the
+ ;; rest of the line isn't naturally aligned, so align them by hand.
+ (2 '(face nil display (space :align-to 10)))
+ (3 '(face nil display (space :align-to 51)))
+ (4 'hexl-ascii-region t t)))
"Font lock keywords used in `hexl-mode'.")
(defun hexl-rulerize (string bits)
@@ -362,6 +374,7 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode.
(setq-local font-lock-defaults '(hexl-font-lock-keywords t))
+ (setq-local font-lock-extra-managed-props '(display))
(setq-local revert-buffer-function #'hexl-revert-buffer-function)
(add-hook 'change-major-mode-hook #'hexl-maybe-dehexlify-buffer nil t)