Gnus development mailing list
 help / color / mirror / Atom feed
From: asjo@koldfront.dk (Adam Sjøgren)
To: emacs-devel@gnu.org
Cc: ding@gnus.org
Subject: shr.el: add linebreaks to mouse-over tooltips (title attributes)
Date: Fri, 12 Dec 2014 22:29:21 +0100	[thread overview]
Message-ID: <877fxwr1zi.fsf@topper.koldfront.dk> (raw)

When reading nntp+news.gwene.org:gwene.com.xkcd there are often long
title attributes on the comic image, and when shown on one line, the
text does not fit on my tiny screen.

I guess the correct solution would be for Emacs to wrap the "help-echo"
to fit the screen automatically.

The second best thing would be if shr.el wrapped the text to fit the
screen.

And here is what I crudely whipped up, a regex to sort-of-wrap at 72
chars:

--- shr.el.orig	2014-12-12 22:21:34.271477782 +0100
+++ shr.el	2014-12-12 22:20:44.652962400 +0100
@@ -1248,10 +1248,13 @@
 	  (put-text-property start (point) 'image-displayer
 			     (shr-image-displayer shr-content-function))
 	  (put-text-property start (point) 'help-echo
-			     (or (cdr (assq :title cont))
-				 alt)))
+			     (shr-linebreak (or (cdr (assq :title cont))
+				 alt))))
 	(setq shr-state 'image)))))
 
+(defun shr-linebreak (line)
+  (replace-regexp-in-string "\\(.\\{72\\}\s\\)" "\\1\n" line))
+
 (defun shr-tag-pre (cont)
   (let ((shr-folding-mode 'none))
     (shr-ensure-newline)

-- 
 "If you don't run, you rust."                                Adam Sjøgren
                                                         asjo@koldfront.dk




             reply	other threads:[~2014-12-12 21:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-12 21:29 Adam Sjøgren [this message]
2014-12-13 15:24 ` 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=877fxwr1zi.fsf@topper.koldfront.dk \
    --to=asjo@koldfront.dk \
    --cc=ding@gnus.org \
    --cc=emacs-devel@gnu.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).