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

Re: text-propertiy の重複



>>>>>> In [emacs-w3m : No.08415] 長さん wrote:

>> 週末にブラッシュアップしたいと思います。

>>>>> In [emacs-w3m : No.08417] 山岡 wrote:

> よろしくお願いします。

すみませんが、その際 w3m-e21.el と w3m-e23.el に添付したパッチを
当てておいて下さい。画像の表示をトグルするときに、今のままだとま
ずいので (画像の下に隠れるテキストが underline の属性を持ってい
ると画像のど真ん中を水平線が貫いてしまうので、それを消すための処
理です)。

2005-10-14  Katsumi Yamaoka  <yamaoka@jpl.org>

	* w3m-e21.el (w3m-insert-image): Make it work with a face text
	property whose value is a list.
	(w3m-remove-image): Remove useless text property.

#v+
--- emacs-w3m/w3m-e21.el~	2005-07-05 23:35:57 +0000
+++ emacs-w3m/w3m-e21.el	2005-10-14 02:32:27 +0000
@@ -247,7 +247,9 @@
 (defun w3m-insert-image (beg end image &rest args)
   "Display image on the current buffer.
 Buffer string between BEG and END are replaced with IMAGE."
-  (let ((face (get-text-property beg 'face)))
+  (let ((faces (get-text-property beg 'face))
+	(idx 0)
+	orig len face)
     (add-text-properties beg end (list 'display image
 				       'intangible image
 				       'invisible nil))
@@ -258,17 +260,26 @@
     ;; if it has an image as a text property is the feature of Emacs 21.
     ;; However, that behavior is not welcome to the w3m buffers, so we do
     ;; to fix it with the following stuffs.
-    (when (and face
-	       (face-underline-p face))
-      (put-text-property beg end 'face nil)
-      (put-text-property beg end 'w3m-underline-face face))))
+    (when faces
+      (unless (listp faces)
+	(setq faces (list faces)))
+      (setq orig (copy-sequence faces)
+	    len (length orig))
+      (while (< idx len)
+	(when (face-underline-p (setq face (nth idx orig)))
+	  (setq faces (delq face faces)))
+	(setq idx (1+ idx)))
+      (when (< (length faces) len)
+	(put-text-property beg end 'face faces)
+	(put-text-property beg end 'w3m-faces-with-underline orig)))))
 
 (defun w3m-remove-image (beg end)
   "Remove an image which is inserted between BEG and END."
   (remove-text-properties beg end '(display nil intangible nil))
-  (let ((underline (get-text-property beg 'w3m-underline-face)))
+  (let ((underline (get-text-property beg 'w3m-faces-with-underline)))
     (when underline
-      (put-text-property beg end 'face underline))))
+      (add-text-properties
+       beg end (list 'face underline 'w3m-faces-with-underline nil)))))
 
 (defun w3m-image-type-available-p (image-type)
   "Return non-nil if an image with IMAGE-TYPE can be displayed inline."
--- emacs-w3m/w3m-e23.el~	2005-07-05 23:35:57 +0000
+++ emacs-w3m/w3m-e23.el	2005-10-14 02:32:27 +0000
@@ -173,7 +173,9 @@
 (defun w3m-insert-image (beg end image &rest args)
   "Display image on the current buffer.
 Buffer string between BEG and END are replaced with IMAGE."
-  (let ((face (get-text-property beg 'face)))
+  (let ((faces (get-text-property beg 'face))
+	(idx 0)
+	orig len face)
     (add-text-properties beg end (list 'display image
 				       'intangible image
 				       'invisible nil))
@@ -184,17 +186,26 @@
     ;; if it has an image as a text property is the feature of Emacs 21.
     ;; However, that behavior is not welcome to the w3m buffers, so we do
     ;; to fix it with the following stuffs.
-    (when (and face
-	       (face-underline-p face))
-      (put-text-property beg end 'face nil)
-      (put-text-property beg end 'w3m-underline-face face))))
+    (when faces
+      (unless (listp faces)
+	(setq faces (list faces)))
+      (setq orig (copy-sequence faces)
+	    len (length orig))
+      (while (< idx len)
+	(when (face-underline-p (setq face (nth idx orig)))
+	  (setq faces (delq face faces)))
+	(setq idx (1+ idx)))
+      (when (< (length faces) len)
+	(put-text-property beg end 'face faces)
+	(put-text-property beg end 'w3m-faces-with-underline orig)))))
 
 (defun w3m-remove-image (beg end)
   "Remove an image which is inserted between BEG and END."
   (remove-text-properties beg end '(display nil intangible nil))
-  (let ((underline (get-text-property beg 'w3m-underline-face)))
+  (let ((underline (get-text-property beg 'w3m-faces-with-underline)))
     (when underline
-      (put-text-property beg end 'face underline))))
+      (add-text-properties
+       beg end (list 'face underline 'w3m-faces-with-underline nil)))))
 
 (defun w3m-image-type-available-p (image-type)
   "Return non-nil if an image with IMAGE-TYPE can be displayed inline."
#v-