From: "David Kågedal" <davidk@lysator.liu.se>
To: Xavier Maillard <zedek@gnu.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-blame.el: pick a set of random colors for each git-blame turn
Date: Wed, 28 Mar 2007 14:02:53 +0200 [thread overview]
Message-ID: <871wj94lua.fsf@morpheus.local> (raw)
In-Reply-To: <200703281031.l2SAVhj7004802@localhost.localdomain> (Xavier Maillard's message of "Wed, 28 Mar 2007 12:31:43 +0200")
Xavier Maillard <zedek@gnu.org> writes:
> I thought it would be cool to have different set of colors for each
> git-blame-mode. Function `git-blame-new-commit' does this for us
> picking when possible, a random colors based on the set we build on
> startup. When it fails, `git-blame-ancient-color' will be used. We
> also take care not to use the same color more than once (thank you
> David Kågedal).
Closer, but still no cigar :-)
> (defun git-blame-new-commit (hash src-line res-line num-lines)
> (save-excursion
> (set-buffer git-blame-file)
> (let ((info (gethash hash git-blame-cache))
> (inhibit-point-motion-hooks t)
> - (inhibit-modification-hooks t))
> + (inhibit-modification-hooks t)
> + (colors git-blame-colors))
> (when (not info)
> - (let ((color (pop git-blame-colors)))
> - (unless color
> - (setq color git-blame-ancient-color))
> - (setq info (list hash src-line res-line num-lines
> + ;; Assign a random color to each new commit info
> + ;; Take care not to select the same color multiple times
> + (let ((color (if colors
> + (git-blame-random-pop colors)
> + git-blame-ancient-color)))
> + (setq info (list hash src-line res-line num-lines
> (git-describe-commit hash)
> (cons 'color color))))
> (puthash hash info git-blame-cache))
You are still making a copy of the list head pointer (colors ->
git-blame-colors), and then you do (git-blame-random-pop colors).
This will not update git-blame-colors if the first element was popped,
which means that you will keep reusing that color. Since you really
do want to always update the buffer-local git-blame-colors, I don't
see why you bind a local variable and work with that instead.
And the last diff line is whitespace-only. You replaced eight spaces
with a TAB.
--
David Kågedal
next prev parent reply other threads:[~2007-03-28 12:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-26 21:01 [PATCH 2/2] git-blame.el: pick a set of random colors when blaming Xavier Maillard
2007-03-27 8:44 ` David Kågedal
2007-03-27 15:31 ` Xavier Maillard
2007-03-28 8:49 ` David Kågedal
2007-03-27 21:51 ` [PATCH] git-blame.el: pick a set of random colors for each git-blame turn Xavier Maillard
2007-03-28 9:15 ` David Kågedal
2007-03-28 10:29 ` Xavier Maillard
2007-03-28 10:31 ` Xavier Maillard
2007-03-28 12:02 ` David Kågedal [this message]
2007-03-28 16:44 ` Xavier Maillard
2007-03-29 9:26 ` David Kågedal
2007-03-29 9:59 ` Xavier Maillard
-- strict thread matches above, loose matches on Subject: below --
2007-03-27 20:09 Xavier Maillard
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=871wj94lua.fsf@morpheus.local \
--to=davidk@lysator.liu.se \
--cc=git@vger.kernel.org \
--cc=zedek@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 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.