From: Ted Zlatanov <tzz@lifelogs.com>
To: ding@gnus.org
Subject: Re: shr - span elements with title attribute, tooltip?
Date: Mon, 28 Mar 2011 16:07:25 -0500 [thread overview]
Message-ID: <87sju7hs36.fsf@lifelogs.com> (raw)
In-Reply-To: <87sju7htmn.fsf@topper.koldfront.dk>
[-- Attachment #1: Type: text/plain, Size: 1029 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: shr-titles.patch --]
[-- Type: text/x-diff, Size: 1042 bytes --]
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))
next prev parent reply other threads:[~2011-03-28 21:07 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-27 7:54 Adam Sjøgren
2011-03-27 8:32 ` [PATCH] Show title attribute of span elements as mouse over text Adam Sjøgren
2011-03-28 18:58 ` shr - span elements with title attribute, tooltip? Ted Zlatanov
2011-03-28 19:17 ` Adam Sjøgren
2011-03-28 19:33 ` Ted Zlatanov
2011-03-28 19:59 ` Adam Sjøgren
2011-03-28 20:14 ` Ted Zlatanov
2011-03-28 20:34 ` Adam Sjøgren
2011-03-28 21:02 ` Adam Sjøgren
2011-03-28 21:07 ` Ted Zlatanov [this message]
2011-03-29 17:52 ` Lars Magne Ingebrigtsen
2011-03-29 18:07 ` Ted Zlatanov
2011-03-29 18:23 ` Lars Magne Ingebrigtsen
2011-03-29 18:46 ` Ted Zlatanov
2011-03-29 19:04 ` Lars Magne Ingebrigtsen
2011-03-29 19:16 ` Ted Zlatanov
2011-03-29 19:35 ` Lars Magne Ingebrigtsen
2011-03-29 19:50 ` Ted Zlatanov
2011-03-29 20:15 ` Lars Magne Ingebrigtsen
2011-03-29 21:31 ` Lars Magne Ingebrigtsen
2011-03-30 6:05 ` Adam Sjøgren
2011-03-30 13:13 ` Ted Zlatanov
2011-03-30 13:39 ` Richard Riley
2011-03-30 19:02 ` Ted Zlatanov
2011-04-03 12:10 ` Lars Magne Ingebrigtsen
2011-03-29 21:15 ` Adam Sjøgren
2011-03-29 21:09 ` Adam Sjøgren
2011-03-30 0:58 ` Kevin Ryde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sju7hs36.fsf@lifelogs.com \
--to=tzz@lifelogs.com \
--cc=ding@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).