Gnus development mailing list
 help / color / mirror / Atom feed
From: Julien Danjou <julien@danjou.info>
To: ding@gnus.org
Subject: Re: [gnus git]  branch master updated: =2= shr: colorize only in one place ; shr: shr-colorize-region fix and stylesheet color retrieval fix
Date: Mon, 06 Dec 2010 17:17:14 +0100	[thread overview]
Message-ID: <sa3y682dgfp.fsf@cigue.easter-eggs.fr> (raw)
In-Reply-To: <m38w02yjq0.fsf@quimbies.gnus.org> (Lars Magne Ingebrigtsen's message of "Mon, 06 Dec 2010 17:00:39 +0100")

[-- Attachment #1: Type: text/plain, Size: 1925 bytes --]

On Mon, Dec 06 2010, Lars Magne Ingebrigtsen wrote:
> Let's see...  yup:
>
>     (when (and style
> 	       (string-match "color" style))
>       (setq shr-stylesheet (nconc (shr-parse-style style)
> 				  shr-stylesheet)))
>
> We add our stuff to what our parent(s) had...

I think you're cheating. :)

Yes you are inheriting, I did not change that code, but the parent did
not set the background-color in shr-styleshset. It does now that I
changed some code to things like:

 (defun shr-tag-font (cont)
-  (let ((start (point))
-        (color (cdr (assq :color cont))))
-    (shr-generic cont)
-    (shr-colorize-region start (point) color)))
+  (let* ((start (point))
+         (color (cdr (assq :color cont)))
+         (shr-stylesheet (if color
+                             `((color . ,fgcolor) ,@shr-stylesheet)
+                           shr-stylesheet)))
+    (shr-generic cont)))

OTOH, there was a subtle bug. You wrote:
        (shr-stylesheet (list (cons :color fgcolor)
                              (cons :background-color bgcolor))))

Initially, where as it should have been 'color and 'background-color
(: vs quote).
So maybe I fixed too much stuff because of that. ;)

>     (let ((color (cdr (assq 'color shr-stylesheet)))
> 	  (background (cdr (assq 'background-color
> 				 shr-stylesheet))))
>       (when (and shr-stylesheet
> 		 (or color background))
> 	(shr-colorize-region start (point) color background)))))
>
> ... and then use it.
>         
> Should work, I think.  Well, actually, it's rendering things too much --
> it should have a (and (string-match "color" style)) in there, too,
> probably.

shr-colorize-region does nothing if both colors are nil, so I don't
think there is too much to optimize here, unless assq is considered to
be slow (I don't know).

-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

  parent reply	other threads:[~2010-12-06 16:17 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1PPcjn-0002Xs-00@quimby.gnus.org>
2010-12-06 15:24 ` Lars Magne Ingebrigtsen
2010-12-06 15:26   ` Lars Magne Ingebrigtsen
2010-12-06 15:54   ` Julien Danjou
2010-12-06 16:00     ` Lars Magne Ingebrigtsen
2010-12-06 16:03       ` Lars Magne Ingebrigtsen
2010-12-06 16:18         ` Julien Danjou
2010-12-06 16:25           ` Lars Magne Ingebrigtsen
2010-12-06 16:36             ` Julien Danjou
2010-12-06 16:41               ` Lars Magne Ingebrigtsen
2010-12-06 16:55                 ` Lars Magne Ingebrigtsen
2010-12-06 17:32                   ` colourising newlines (was: [gnus git] branch master updated: =2= shr: colorize only in one place ; shr: shr-colorize-region fix and stylesheet color retrieval fix) Lars Magne Ingebrigtsen
2010-12-14 23:51                     ` colourising newlines Ted Zlatanov
2010-12-15 19:30                       ` Lars Magne Ingebrigtsen
2010-12-15 21:03                         ` Ted Zlatanov
2010-12-15 21:30                           ` Lars Magne Ingebrigtsen
2010-12-15 21:40                             ` Ted Zlatanov
2010-12-16 15:54                               ` Lars Magne Ingebrigtsen
2010-12-16 20:43                                 ` Ted Zlatanov
2010-12-16 20:25                             ` Eric S Fraga
2010-12-17 16:43                               ` Lars Magne Ingebrigtsen
2010-12-18 19:20                                 ` Eric S Fraga
2011-01-19 22:24                             ` Ted Zlatanov
2011-01-22  3:02                               ` Lars Ingebrigtsen
2011-01-24 19:46                                 ` Ted Zlatanov
2010-12-06 16:17       ` Julien Danjou [this message]
2010-12-06 16:22         ` [gnus git] branch master updated: =2= shr: colorize only in one place ; shr: shr-colorize-region fix and stylesheet color retrieval fix Lars Magne Ingebrigtsen
2010-12-06 16:27           ` Lars Magne Ingebrigtsen
2010-12-06 16:48             ` Julien Danjou
2010-12-06 17:26               ` Lars Magne Ingebrigtsen
2010-12-06 17:30                 ` Julien Danjou
2010-12-06 17:33                   ` Lars Magne Ingebrigtsen
2010-12-06 16:33           ` Julien Danjou
2010-12-06 16:36             ` 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=sa3y682dgfp.fsf@cigue.easter-eggs.fr \
    --to=julien@danjou.info \
    --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).