Gnus development mailing list
 help / color / mirror / Atom feed
From: "Adam Sjøgren" <asjo@koldfront.dk>
To: ding@gnus.org
Cc: "Adam Sjøgren" <asjo@koldfront.dk>
Subject: [PATCH] (shr-urlify): show title attribute as well as URL, if provided. (shr-tag-a): pass title to shr-urlify.
Date: Sat,  4 Dec 2010 22:44:37 +0100	[thread overview]
Message-ID: <1291499077-1619-1-git-send-email-asjo@koldfront.dk> (raw)
In-Reply-To: <87ei9xjlfj.fsf@topper.koldfront.dk>

Try to put a patch where my mouth is.

---
 lisp/shr.el |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/lisp/shr.el b/lisp/shr.el
index 69973fb..e8522a7 100644
--- a/lisp/shr.el
+++ b/lisp/shr.el
@@ -506,13 +506,14 @@ START, and END."
 
 (autoload 'widget-convert-button "wid-edit")
 
-(defun shr-urlify (start url)
-  (widget-convert-button
-   'url-link start (point)
-   :help-echo url
-   :keymap shr-map
-   url)
-  (put-text-property start (point) 'shr-url url))
+(defun shr-urlify (start url &optional title)
+  (let ((help-text (if title (format "%s (%s)" title url) url)))
+    (widget-convert-button
+     'url-link start (point)
+     :help-echo help-text
+     :keymap shr-map
+     url)
+    (put-text-property start (point) 'shr-url url)))
 
 (defun shr-encode-url (url)
   "Encode URL."
@@ -631,10 +632,11 @@ text will be inserted at start."
 
 (defun shr-tag-a (cont)
   (let ((url (cdr (assq :href cont)))
+        (title (cdr (assq :title cont)))
 	(start (point))
 	shr-start)
     (shr-generic cont)
-    (shr-urlify (or shr-start start) url)))
+    (shr-urlify (or shr-start start) url title)))
 
 (defun shr-tag-object (cont)
   (let ((start (point))
-- 
1.7.2.3




  reply	other threads:[~2010-12-04 21:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-04 21:08 shr - support for title attribute on <a> elements? Adam Sjøgren
2010-12-04 21:44 ` Adam Sjøgren [this message]
2010-12-04 21:59 ` [PATCH] (shr-urlify): show title attribute as well as URL, if provided. (shr-tag-a): pass title to shr-urlify Adam Sjøgren
2010-12-04 22:25   ` Lars Magne Ingebrigtsen
2010-12-04 22:55     ` Adam Sjøgren
2010-12-04 23:00       ` www.gnus.org (Was: (shr-urlify): show title attribute as well as URL, if provided. (shr-tag-a): pass title to shr-urlify.) Adam Sjøgren
2010-12-04 23:33         ` www.gnus.org Lars Magne Ingebrigtsen
2010-12-04 23:32       ` (shr-urlify): show title attribute as well as URL, if provided. (shr-tag-a): pass title to shr-urlify Lars Magne Ingebrigtsen

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=1291499077-1619-1-git-send-email-asjo@koldfront.dk \
    --to=asjo@koldfront.dk \
    --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).