diff options
| author | Masatake YAMATO | 2004-12-27 11:59:49 +0000 |
|---|---|---|
| committer | Masatake YAMATO | 2004-12-27 11:59:49 +0000 |
| commit | 639b8e4d14cfdc8a14ee514d2a6c7962ca38df43 (patch) | |
| tree | 3c02d0db00a1f77f4d56ccfabbbf99f557a89815 | |
| parent | 8ffc3990aed5a642b8d572bb606f99e274fbed26 (diff) | |
| download | emacs-639b8e4d14cfdc8a14ee514d2a6c7962ca38df43.tar.gz emacs-639b8e4d14cfdc8a14ee514d2a6c7962ca38df43.zip | |
* 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.
| -rw-r--r-- | lisp/hexl.el | 23 |
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." | |||
| 111 | (defvar hexl-mode-old-isearch-search-fun-function) | 111 | (defvar hexl-mode-old-isearch-search-fun-function) |
| 112 | (defvar hexl-mode-old-require-final-newline) | 112 | (defvar hexl-mode-old-require-final-newline) |
| 113 | (defvar hexl-mode-old-syntax-table) | 113 | (defvar hexl-mode-old-syntax-table) |
| 114 | (defvar hexl-mode-old-font-lock-keywords) | ||
| 114 | 115 | ||
| 115 | (defvar hexl-ascii-overlay nil | 116 | (defvar hexl-ascii-overlay nil |
| 116 | "Overlay used to highlight ASCII element corresponding to current point.") | 117 | "Overlay used to highlight ASCII element corresponding to current point.") |
| 117 | (make-variable-buffer-local 'hexl-ascii-overlay) | 118 | (make-variable-buffer-local 'hexl-ascii-overlay) |
| 118 | 119 | ||
| 120 | (defvar hexl-font-lock-keywords | ||
| 121 | '(("^\\([0-9a-f]+:\\).\\{40\\} \\(.+$\\)" | ||
| 122 | ;; "^\\([0-9a-f]+:\\).+ \\(.+$\\)" | ||
| 123 | (1 'hexl-address-area t t) | ||
| 124 | (2 'hexl-ascii-area t t))) | ||
| 125 | "Font lock keywords used in `hexl-mode'.") | ||
| 126 | |||
| 119 | ;; routines | 127 | ;; routines |
| 120 | 128 | ||
| 121 | (put 'hexl-mode 'mode-class 'special) | 129 | (put 'hexl-mode 'mode-class 'special) |
| @@ -265,6 +273,11 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode. | |||
| 265 | (make-local-variable 'require-final-newline) | 273 | (make-local-variable 'require-final-newline) |
| 266 | (setq require-final-newline nil) | 274 | (setq require-final-newline nil) |
| 267 | 275 | ||
| 276 | (make-local-variable 'hexl-mode-old-font-lock-keywords) | ||
| 277 | (setq hexl-mode-old-font-lock-keywords font-lock-defaults) | ||
| 278 | (make-local-variable 'font-lock-defaults) | ||
| 279 | (setq font-lock-defaults '(hexl-font-lock-keywords t)) | ||
| 280 | |||
| 268 | ;; Add hooks to rehexlify or dehexlify on various events. | 281 | ;; Add hooks to rehexlify or dehexlify on various events. |
| 269 | (add-hook 'after-revert-hook 'hexl-after-revert-hook nil t) | 282 | (add-hook 'after-revert-hook 'hexl-after-revert-hook nil t) |
| 270 | 283 | ||
| @@ -376,6 +389,7 @@ With arg, don't unhexlify buffer." | |||
| 376 | (setq isearch-search-fun-function hexl-mode-old-isearch-search-fun-function) | 389 | (setq isearch-search-fun-function hexl-mode-old-isearch-search-fun-function) |
| 377 | (use-local-map hexl-mode-old-local-map) | 390 | (use-local-map hexl-mode-old-local-map) |
| 378 | (set-syntax-table hexl-mode-old-syntax-table) | 391 | (set-syntax-table hexl-mode-old-syntax-table) |
| 392 | (setq font-lock-defaults hexl-mode-old-font-lock-keywords) | ||
| 379 | (setq major-mode hexl-mode-old-major-mode) | 393 | (setq major-mode hexl-mode-old-major-mode) |
| 380 | (force-mode-line-update)) | 394 | (force-mode-line-update)) |
| 381 | 395 | ||
| @@ -684,15 +698,6 @@ This discards the buffer's undo information." | |||
| 684 | (apply 'call-process-region (point-min) (point-max) | 698 | (apply 'call-process-region (point-min) (point-max) |
| 685 | (expand-file-name hexl-program exec-directory) | 699 | (expand-file-name hexl-program exec-directory) |
| 686 | t t nil (split-string hexl-options)) | 700 | t t nil (split-string hexl-options)) |
| 687 | (save-excursion | ||
| 688 | (goto-char (point-min)) | ||
| 689 | (while (re-search-forward "^[0-9a-f]+:" nil t) | ||
| 690 | (put-text-property (match-beginning 0) (match-end 0) | ||
| 691 | 'font-lock-face 'hexl-address-area)) | ||
| 692 | (goto-char (point-min)) | ||
| 693 | (while (re-search-forward " \\(.+$\\)" nil t) | ||
| 694 | (put-text-property (match-beginning 1) (match-end 1) | ||
| 695 | 'font-lock-face 'hexl-ascii-area))) | ||
| 696 | (if (> (point) (hexl-address-to-marker hexl-max-address)) | 701 | (if (> (point) (hexl-address-to-marker hexl-max-address)) |
| 697 | (hexl-goto-address hexl-max-address)))) | 702 | (hexl-goto-address hexl-max-address)))) |
| 698 | 703 | ||