summaryrefslogtreecommitdiff
path: root/lisp/hexl.el
diff options
context:
space:
mode:
authorMasatake YAMATO <jet@gyve.org>2004-12-27 11:59:49 +0000
committerMasatake YAMATO <jet@gyve.org>2004-12-27 11:59:49 +0000
commit639b8e4d14cfdc8a14ee514d2a6c7962ca38df43 (patch)
tree3c02d0db00a1f77f4d56ccfabbbf99f557a89815 /lisp/hexl.el
parent8ffc3990aed5a642b8d572bb606f99e274fbed26 (diff)
downloademacs-639b8e4d14cfdc8a14ee514d2a6c7962ca38df43.tar.gz
* hexl.el (hexlify-buffer): Remove fontification here.
Use font lock mechanism instead. (hexl-font-lock-keywords): New font lock kewords. (hexl-mode-old-font-lock-keywords): New variable. (hexl-mode): Store the old font lock keywords. (hexl-mode-exit): Restore the old font lock keywords.
Diffstat (limited to 'lisp/hexl.el')
-rw-r--r--lisp/hexl.el23
1 files changed, 14 insertions, 9 deletions
diff --git a/lisp/hexl.el b/lisp/hexl.el
index f5b83c0afde..af996940f86 100644
--- a/lisp/hexl.el
+++ b/lisp/hexl.el
@@ -111,11 +111,19 @@ Quoting cannot be used, so the arguments cannot themselves contain spaces."
(defvar hexl-mode-old-isearch-search-fun-function)
(defvar hexl-mode-old-require-final-newline)
(defvar hexl-mode-old-syntax-table)
+(defvar hexl-mode-old-font-lock-keywords)
(defvar hexl-ascii-overlay nil
"Overlay used to highlight ASCII element corresponding to current point.")
(make-variable-buffer-local 'hexl-ascii-overlay)
+(defvar hexl-font-lock-keywords
+ '(("^\\([0-9a-f]+:\\).\\{40\\} \\(.+$\\)"
+ ;; "^\\([0-9a-f]+:\\).+ \\(.+$\\)"
+ (1 'hexl-address-area t t)
+ (2 'hexl-ascii-area t t)))
+ "Font lock keywords used in `hexl-mode'.")
+
;; routines
(put 'hexl-mode 'mode-class 'special)
@@ -265,6 +273,11 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode.
(make-local-variable 'require-final-newline)
(setq require-final-newline nil)
+ (make-local-variable 'hexl-mode-old-font-lock-keywords)
+ (setq hexl-mode-old-font-lock-keywords font-lock-defaults)
+ (make-local-variable 'font-lock-defaults)
+ (setq font-lock-defaults '(hexl-font-lock-keywords t))
+
;; Add hooks to rehexlify or dehexlify on various events.
(add-hook 'after-revert-hook 'hexl-after-revert-hook nil t)
@@ -376,6 +389,7 @@ With arg, don't unhexlify buffer."
(setq isearch-search-fun-function hexl-mode-old-isearch-search-fun-function)
(use-local-map hexl-mode-old-local-map)
(set-syntax-table hexl-mode-old-syntax-table)
+ (setq font-lock-defaults hexl-mode-old-font-lock-keywords)
(setq major-mode hexl-mode-old-major-mode)
(force-mode-line-update))
@@ -684,15 +698,6 @@ This discards the buffer's undo information."
(apply 'call-process-region (point-min) (point-max)
(expand-file-name hexl-program exec-directory)
t t nil (split-string hexl-options))
- (save-excursion
- (goto-char (point-min))
- (while (re-search-forward "^[0-9a-f]+:" nil t)
- (put-text-property (match-beginning 0) (match-end 0)
- 'font-lock-face 'hexl-address-area))
- (goto-char (point-min))
- (while (re-search-forward " \\(.+$\\)" nil t)
- (put-text-property (match-beginning 1) (match-end 1)
- 'font-lock-face 'hexl-ascii-area)))
(if (> (point) (hexl-address-to-marker hexl-max-address))
(hexl-goto-address hexl-max-address))))