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

Re: turn off vicious `alt' text truncation



From: jidanni@xxxxxxxxxxx said
Subject: [emacs-w3m:10604] turn off vicious `alt' text truncation
Message-ID: <87y6xdcvtk.fsf@xxxxxxxxxxx>
Date: Thu, 15 Jan 2009 07:27:35 +0800

> How do I stop the truncation of `alt' texts?
> 
> My dotfiles can be seen in http://jidanni.org/comp/configuration/
> (I don't want to set w3m-treat-image-size to nil, otherwise
> I'll again have [emacs-w3m:10567] vertically worded webpages)

I tried to write the following patch.

(1) Put the 'full alt text' on new 'w3m-image-alt' property.
(2) Print the content of 'w3m-image-alt' at the same time
    printing URL.

How about you?

-- 
Hideyuki SHIRAI (mailto:shirai@xxxxxxxxxxx)
Index: w3m-util.el
===================================================================
RCS file: /cvsroot/w3m-shirai/emacs-w3m/w3m-util.el,v
retrieving revision 1.118
diff -u -r1.118 w3m-util.el
--- w3m-util.el	13 Nov 2008 00:25:54 -0000	1.118
+++ w3m-util.el	15 Jan 2009 08:23:03 -0000
@@ -211,6 +211,15 @@
       `(get-text-property ,position 'w3m-image)
     `(w3m-get-text-property-around 'w3m-image)))
 
+(defmacro w3m-image-alt (&optional position)
+  "Return the value of the `w3m-image-alt' property at the given POSITION.
+NOTE: If POSITION is omitted, it searches for the property in one
+character before and behind the current position, and point will move
+to the position where the property exists."
+  (if position
+      `(get-text-property ,position 'w3m-image-alt)
+    `(w3m-get-text-property-around 'w3m-image-alt)))
+
 (defmacro w3m-submit (&optional position)
   "Return the value of the `w3m-submit' property at the given POSITION.
 NOTE: If POSITION is omitted, it searches for the property in one
Index: w3m.el
===================================================================
RCS file: /cvsroot/w3m-shirai/emacs-w3m/w3m.el,v
retrieving revision 1.1202
diff -u -r1.1202 w3m.el
--- w3m.el	13 Jan 2009 00:15:15 -0000	1.1202
+++ w3m.el	15 Jan 2009 08:23:03 -0000
@@ -3576,6 +3576,7 @@
       (w3m-parse-attributes (src
 			     (width :integer)
 			     (height :integer)
+			     title
 			     usemap)
 	(delete-region start end)
 	(setq src (w3m-expand-url (w3m-decode-anchor-string src)))
@@ -3586,12 +3587,13 @@
 					 'w3m-image-size
 					 (when (or width height)
 					   (cons width height))
+					 'w3m-image-alt title
 					 'w3m-image-usemap usemap
 					 'w3m-image-status 'off
 					 'w3m-image-redundant upper))
 	   (unless (w3m-action start)
 	     ;; No need to use `w3m-add-text-properties' here.
-	     (w3m-add-face-property start end 
+	     (w3m-add-face-property start end
 				    (if (w3m-anchor start)
 					'w3m-image-anchor
 				      'w3m-image))
@@ -6706,10 +6708,16 @@
   (let ((deactivate-mark nil)
 	(url (if interactive-p
 		 (or (w3m-anchor) (w3m-image))
-	       (or (w3m-anchor (point)) (w3m-image (point))))))
+	       (or (w3m-anchor (point)) (w3m-image (point)))))
+	(alt (or (if interactive-p
+		     (w3m-image-alt)
+		   (w3m-image-alt (point))))))
     (when (or url interactive-p)
       (and url interactive-p (kill-new url))
-      (w3m-message "%s"
+      (w3m-message "%s%s"
+		   (if alt
+		       (format "%s: " alt)
+		     "")
 		   (or (w3m-url-readable-string url)
 		       (and (w3m-action) "There is a form")
 		       "There is no url")))))