emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hexl-find-file is sloooow


From: Masatake YAMATO
Subject: Re: hexl-find-file is sloooow
Date: Wed, 22 Dec 2004 15:51:07 +0900 (JST)

>     It seems that fontification takes long time.
>     As far as I can remember the area fontification is introduced by me.
>     Do you want to turn off the fortification?
> 
> Could the fontification be made lazy?

I've introduced hexl-font-lock-keywords.
It becomes much faster.

However, I've met a trouble. When I do M-x hexl-find-file
on the file already loaded into emacs, hexl-font-lock-keywords
is not affected.

e.g.
        C-x C-f foo.c
        M-x hexl-find-file foo.c

Could you give me hints?

One more issue is that the regular expression used in
hexl-font-lock-keywords becomes ugly. I've given fixed column length
in it. Without fixed column length, it is difficult to fortify the
line which is not aliened to 16 bytes like:

  00132010: 0cc3 3096 9df3 59a4 327f a3fb 279d f7f7  ..0...Y.2...'...
                                                  ^Aliened. OK.
  00132020: 2500 a12a 00                             %..*.
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^Empty. Not aliened.

Masatake YAMATO

Index: hexl.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/hexl.el,v
retrieving revision 1.90
diff -u -r1.90 hexl.el
--- hexl.el     21 Nov 2004 00:38:34 -0000      1.90
+++ hexl.el     22 Dec 2004 06:39:52 -0000
@@ -111,11 +111,19 @@
 (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 @@
     (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 @@
   (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 @@
     (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))))
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]