* shr.el: add linebreaks to mouse-over tooltips (title attributes)
@ 2014-12-12 21:29 Adam Sjøgren
2014-12-13 15:24 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 2+ messages in thread
From: Adam Sjøgren @ 2014-12-12 21:29 UTC (permalink / raw
To: emacs-devel; +Cc: ding
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: shr.el: add linebreaks to mouse-over tooltips (title attributes)
2014-12-12 21:29 shr.el: add linebreaks to mouse-over tooltips (title attributes) Adam Sjøgren
@ 2014-12-13 15:24 ` Lars Magne Ingebrigtsen
0 siblings, 0 replies; 2+ messages in thread
From: Lars Magne Ingebrigtsen @ 2014-12-13 15:24 UTC (permalink / raw
To: Adam Sjøgren; +Cc: ding, emacs-devel
asjo@koldfront.dk (Adam Sjøgren) writes:
> 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:
Thanks; I've now committed something similar, but which make it fold
between words.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-13 15:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-12 21:29 shr.el: add linebreaks to mouse-over tooltips (title attributes) Adam Sjøgren
2014-12-13 15:24 ` Lars Magne Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.