From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/85348 Path: news.gmane.org!not-for-mail From: asjo@koldfront.dk (Adam =?utf-8?Q?Sj=C3=B8gren?=) Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: shr.el: add linebreaks to mouse-over tooltips (title attributes) Date: Fri, 12 Dec 2014 22:29:21 +0100 Organization: koldfront - analysis & revolution, Copenhagen, Denmark Message-ID: <877fxwr1zi.fsf@topper.koldfront.dk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1418419802 23720 80.91.229.3 (12 Dec 2014 21:30:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Dec 2014 21:30:02 +0000 (UTC) Cc: ding@gnus.org To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 12 22:29:55 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XzXma-0007Dc-Hq for ged-emacs-devel@m.gmane.org; Fri, 12 Dec 2014 22:29:52 +0100 Original-Received: from localhost ([::1]:59531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzXma-0004GJ-4E for ged-emacs-devel@m.gmane.org; Fri, 12 Dec 2014 16:29:52 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzXmR-0004GC-Kr for emacs-devel@gnu.org; Fri, 12 Dec 2014 16:29:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XzXmL-0000Bl-If for emacs-devel@gnu.org; Fri, 12 Dec 2014 16:29:43 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:36903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzXmL-0000BU-C2 for emacs-devel@gnu.org; Fri, 12 Dec 2014 16:29:37 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XzXmK-0006k5-FA for emacs-devel@gnu.org; Fri, 12 Dec 2014 22:29:36 +0100 Original-Received: from 2505ds5-by.0.fullrate.dk ([89.150.142.116]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Dec 2014 22:29:36 +0100 Original-Received: from asjo by 2505ds5-by.0.fullrate.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Dec 2014 22:29:36 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 35 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 2505ds5-by.0.fullrate.dk OpenPGP: id=49D0746121BDE416; url=http://asjo.koldfront.dk/gpg.asc Mail-Follow-Up-To: never X-Now-Playing: Dogs On The Run, Southern Accents (Tom Petty And The Heartbreakers) X-Face: )qY&CseJ?.:=8F#^~GcSA?F=9eu'{KAFfL1C3/A&:nE?PW\i65"ba0NS)97, Q(^@xk}n4Ou rPuR#V8I(J_@~H($[ym:`K_+]*kjvW>xH5jbgLBVFGXY:(#4P>zVBklLbdL&XxL\M)%T}3S/IS9lMJ ^St'=VZBR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:179964 gmane.emacs.gnus.general:85348 Archived-At: 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