From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/78142 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.gnus.general Subject: Re: shr - span elements with title attribute, tooltip? Date: Mon, 28 Mar 2011 16:07:25 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87sju7hs36.fsf@lifelogs.com> References: <871v1tc82r.fsf@topper.koldfront.dk> <87ei5rkr6b.fsf@lifelogs.com> <8762r3jbq2.fsf@topper.koldfront.dk> <87tyenjb0v.fsf@lifelogs.com> <87wrjjhv8m.fsf@topper.koldfront.dk> <87fwq7j93d.fsf@lifelogs.com> <87sju7htmn.fsf@topper.koldfront.dk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1301346503 9123 80.91.229.12 (28 Mar 2011 21:08:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 28 Mar 2011 21:08:23 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M26453@lists.math.uh.edu Mon Mar 28 23:08:19 2011 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4Jfe-00062p-52 for ding-account@gmane.org; Mon, 28 Mar 2011 23:08:18 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1Q4JfK-0006Fc-F4; Mon, 28 Mar 2011 16:07:58 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1Q4JfJ-0006FS-7J for ding@lists.math.uh.edu; Mon, 28 Mar 2011 16:07:57 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1Q4Jf4-00066W-8D for ding@lists.math.uh.edu; Mon, 28 Mar 2011 16:07:52 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1Q4Jf3-0002Dc-Gs for ding@gnus.org; Mon, 28 Mar 2011 23:07:41 +0200 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Q4Jf1-0005jV-Hg for ding@gnus.org; Mon, 28 Mar 2011 23:07:39 +0200 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 28 Mar 2011 23:07:39 +0200 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 28 Mar 2011 23:07:39 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 73 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6;d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110016 (No Gnus v0.16) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:uU156SvePTOinFPRrGL0SJi1p/U= X-Spam-Score: -0.7 (/) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:78142 Archived-At: --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit On Mon, 28 Mar 2011 22:34:08 +0200 asjo@koldfront.dk (Adam Sjøgren) wrote: AS> When I try that, I get the same colours and the same tooltips as in AS> Firefox. AS> Otherwise I wouldn't have linked to the example. AS> (With the patch applied, of course.) I must be doing something wrong, Adam. I eval-ed your `shr-tag-span' function and the buffer still looks the same. I'd just like to provide a more direct way of viewing the titles *in addition* to tooltips as you had it. See attached patch. AS> On Mon, 28 Mar 2011 15:14:46 -0500, Ted wrote: >> Anyhow, what's wrong with a "toggle-titles" command for shr.el? AS> Nothing, I think you should go for it :-) It would be great if someone who knew shr.el did it similarly to the way `shr-show-alt-text' and `shr-insert-image' work, plus added a way (maybe with display properties) to toggle the titles in the buffer. My first attempt is attached but I think it's overeager: on your example, "M-: (shr-show-title)" shows "Blue" everywhere in the buffer. Thanks Ted --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=shr-titles.patch diff --git a/lisp/shr.el b/lisp/shr.el index 113137a..3a217f8 100644 --- a/lisp/shr.el +++ b/lisp/shr.el @@ -161,6 +161,14 @@ redirects somewhere else." (copy-region-as-kill (point-min) (point-max)) (message "Copied %s" url)))))) +(defun shr-show-title () + "Show the title text of the image under point." + (interactive) + (let ((text (get-text-property (point) 'shr-title))) + (if (not text) + (message "No title under point") + (message "%s" text)))) + (defun shr-show-alt-text () "Show the ALT text of the image under point." (interactive) @@ -896,6 +904,14 @@ ones, in case fg and bg are nil." (shr-indent)) (shr-generic cont)) +(defun shr-tag-span (cont) + (let ((title (cdr (assq :title cont)))) + (shr-generic cont) + (when title + (put-text-property (or start shr-start) (point) 'shr-title title) + (let ((overlay (make-overlay (or start shr-start) (point)))) + (overlay-put overlay 'help-echo title))))) + (defun shr-tag-h1 (cont) (shr-heading cont 'bold 'underline)) --=-=-=--