[Mew-dist 2764] Re: property or overlay
SAKAI Kiyotaka
ksakai at example.com
1997年 10月 28日 (火) 13:25:20 JST
>> In article <19971027190227U.kazu at example.com>, Kazu Yamamoto (山本和彦) <Kazu at example.com> writes:
> overlay を使うと make-overlay しないといけませんよね?
property を使用した場合もそれなりにオーバーヘッドがありますし、また、
実際に表示するのにかかる時間に比べたらどちらも充分に小さいはずですので、
どちらを使っても時間的にはほとんど変わらないと思います。
> この関数のオーバヘッドが小さく(たくさん overlay を作っても平気)、
> XEmacs も同様の機能があって差が吸収できるなら、overlay でも構いませ
> ん。
mew-env.el を見てもらえば分かりますが、overlay は XEmacs では extent
という概念になっていて、extentp, make-extent, set-extent-endpoints,
set-extent-property という関数で操作することができます。
URL の色付けと header の色付けを overlay で行うためのパッチを付けてお
きます。昨日、送ったパッチの後に当てて下さい。
マークの色付けに関しては、マークの動作の仕様が property の動作にマッチ
していているため property で行なった方が楽だと思いますし、Summary
buffer から cut & paste で持っていくことはまずないと思いますので、今の
ままのコードの方がいいかと思います。
--
酒井 清隆 (E-mail: ksakai at example.com)
Index: mew-env.el
===================================================================
RCS file: /home/cvsroot/mew-1.92/mew-env.el,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mew-env.el
--- mew-env.el 1997/10/27 01:01:56 1.1.1.1
+++ mew-env.el 1997/10/28 02:12:49
@@ -57,21 +57,21 @@
(or (find-face 'underline)
(progn (make-face 'underline)
(set-face-underline-p 'underline t)))
- (fset 'mew-property-p (symbol-function 'extentp))
- (fset 'mew-property-make (symbol-function 'make-extent))
- (defun mew-property-move (overlay beg end &optional buffer)
+ (fset 'mew-overlay-p (symbol-function 'extentp))
+ (fset 'mew-overlay-make (symbol-function 'make-extent))
+ (defun mew-overlay-move (overlay beg end &optional buffer)
(set-extent-endpoints overlay beg end))
- (defun mew-property-put (overlay prop value)
+ (defun mew-overlay-put (overlay prop value)
(set-extent-property overlay prop value))
(fset 'mew-buffer-substring (symbol-function 'buffer-substring))
(defun mew-mark () (mark t))
)
(mew-temacs-p
(require 'faces)
- (fset 'mew-property-p (symbol-function 'overlayp))
- (fset 'mew-property-make (symbol-function 'make-overlay))
- (fset 'mew-property-move (symbol-function 'move-overlay))
- (fset 'mew-property-put (symbol-function 'overlay-put))
+ (fset 'mew-overlay-p (symbol-function 'overlayp))
+ (fset 'mew-overlay-make (symbol-function 'make-overlay))
+ (fset 'mew-overlay-move (symbol-function 'move-overlay))
+ (fset 'mew-overlay-put (symbol-function 'overlay-put))
(require 'easymenu)
(if (fboundp 'buffer-substring-no-properties)
(fset 'mew-buffer-substring
Index: mew-highlight.el
===================================================================
RCS file: /home/cvsroot/mew-1.92/mew-highlight.el,v
retrieving revision 1.2
diff -u -r1.2 mew-highlight.el
--- mew-highlight.el 1997/10/28 02:02:33 1.2
+++ mew-highlight.el 1997/10/28 04:01:59
@@ -155,30 +155,31 @@
"A function to highlight the cursor line in Summary and Virtual mode."
(if mew-opt-highlight-cursor-line
(let ((buffer-read-only nil))
- (if (mew-property-p mew-property-cursor-line)
- (mew-property-move mew-property-cursor-line
- (save-excursion (beginning-of-line) (point))
- (save-excursion (end-of-line) (point)))
- (setq mew-property-cursor-line
- (mew-property-make
+ (if (mew-overlay-p mew-overlay-cursor-line)
+ (mew-overlay-move mew-overlay-cursor-line
+ (save-excursion (beginning-of-line) (point))
+ (save-excursion (end-of-line) (point)))
+ (setq mew-overlay-cursor-line
+ (mew-overlay-make
(save-excursion (beginning-of-line) (point))
(save-excursion (end-of-line) (point))))
- (mew-property-put mew-property-cursor-line 'face
- mew-highlight-cursor-line-face)
+ (mew-overlay-put mew-overlay-cursor-line 'face
+ mew-highlight-cursor-line-face)
))))
(defun mew-highlight-url ()
"A function to highlight URL in Message mode."
(if mew-opt-highlight-url
(let ((url-regex mew-opt-highlight-url-regex)
- (buffer-read-only nil))
+ (buffer-read-only nil)
+ overlay)
(save-excursion
(goto-char (point-min))
(while (re-search-forward url-regex mew-bold-url-size t)
- (put-text-property (match-beginning 0) (match-end 0)
- 'face mew-highlight-url-face)
- (put-text-property (match-beginning 0) (match-end 0)
- 'mouse-face mew-highlight-url-mouse-face))))))
+ (setq overlay (mew-overlay-make (match-beginning 0) (match-end 0)))
+ (mew-overlay-put overlay 'face mew-highlight-url-face)
+ (mew-overlay-put overlay 'mouse-face mew-highlight-url-mouse-face)
+ )))))
(defun mew-highlight-mark-region (beg end)
(interactive "r")
@@ -226,7 +227,7 @@
(goto-char beg)
(let ((keywords mew-highlight-header-keywords)
(buffer-read-only nil)
- key beg1 end1 beg2 end2 assoc)
+ key beg1 end1 beg2 end2 assoc overlay)
(while (not (eobp))
(looking-at "^\\([^:]+:\\)[ \t]*")
(setq beg1 (match-beginning 1))
@@ -236,10 +237,12 @@
(forward-line)
(if (setq assoc (mew-assoc-match2 key keywords 0))
(progn
- (put-text-property beg1 end1 'face (nth 1 assoc))
+ (setq overlay (mew-overlay-make beg1 end1))
+ (mew-overlay-put overlay 'face (nth 1 assoc))
(while (looking-at "[ \t]+") (forward-line))
(setq end2 (1- (point)))
- (put-text-property beg2 end2 'face (nth 2 assoc)))
+ (setq overlay (mew-overlay-make beg2 end2))
+ (mew-overlay-put overlay 'face (nth 2 assoc)))
(while (looking-at "[ \t]") (forward-line)))))))))
;;
@@ -263,8 +266,8 @@
(let ((buffer-read-only nil) xface)
(while (re-search-forward
"^X-Face: *\\(.*\\(\n[ \t].*\\)*\\)\n" end t)
- (mew-property-put
- (mew-property-make
+ (mew-overlay-put
+ (mew-overlay-make
(match-beginning 0) (match-end 0))
'invisible t)
(setq xface (highlight-headers-x-face-to-pixmap
@@ -274,8 +277,8 @@
(goto-char beg)
(if (re-search-forward "^\\(From:\\).*" end t)
(set-extent-begin-glyph
- (mew-property-make (match-end 1)
- (match-end 1))
+ (mew-overlay-make (match-end 1)
+ (match-end 1))
xface))))))))
)))
(t
Index: mew.el
===================================================================
RCS file: /home/cvsroot/mew-1.92/mew.el,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mew.el
--- mew.el 1997/10/27 01:01:57 1.1.1.1
+++ mew.el 1997/10/28 02:22:23
@@ -364,7 +364,7 @@
(defvar mew-decode-syntax nil)
(defvar mew-decode-error nil)
(defvar mew-encode-syntax nil)
-(defvar mew-property-cursor-line nil)
+(defvar mew-overlay-cursor-line nil)
(mapcar
(function make-variable-buffer-local)
@@ -383,7 +383,7 @@
'mew-encode-syntax
'mew-decode-syntax
'mew-decode-error
- 'mew-property-cursor-line
+ 'mew-overlay-cursor-line
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Mew-dist メーリングリストの案内