unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Add rainbow-mode
@ 2010-07-27 12:50 Julien Danjou
  2010-07-27 13:19 ` Lennart Borgman
  0 siblings, 1 reply; 19+ messages in thread
From: Julien Danjou @ 2010-07-27 12:50 UTC (permalink / raw)
  To: emacs-devel; +Cc: Julien Danjou

Signed-off-by: Julien Danjou <julien@danjou.info>
---

Hi there,

I'm glad to present rainbow-mode. This is a minor mode that displays color
names with colored background.

This means that if you type #ff0000 it will displays that string, #ff0000,
with a red background.

It supports several major mode, like LaTeX, HTML/CSS, etc. This allows to also
diplays strings like
  \definecolor{blue}{RGB}{0, 0, 255}
in blue for latex, or
  rgb(255, 0, 0)
in red for CSS.

A lot of people found this mode very useful, and I got a ton of feedback in
the last weeks, with several requests to submit rainbow-mode to emacs trunk.

So here it is.

 lisp/ChangeLog       |    4 +
 lisp/rainbow-mode.el |  248 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 252 insertions(+), 0 deletions(-)
 create mode 100644 lisp/rainbow-mode.el

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 52a618e..c3021db 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
+2010-07-27  Julien Danjou  <julien@danjou.info>
+
+	* rainbow-mode.el: New file.
+
 2010-07-26  Daiki Ueno  <ueno@unixuser.org>

 	* epa-mail.el (epa-mail-mode-map): Add alternative key bindings
diff --git a/lisp/rainbow-mode.el b/lisp/rainbow-mode.el
new file mode 100644
index 0000000..700e7c2
--- /dev/null
+++ b/lisp/rainbow-mode.el
@@ -0,0 +1,248 @@
+;;; rainbow-mode.el --- Displays color names with colored background.
+
+;; Copyright (C) 2010 Free Software Foundation, Inc
+
+;; Author: Julien Danjou <julien@danjou.info>
+;; Keywords: faces
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; This minor mode will set background color to strings that matches color
+;; names.
+;; i.e.  #0000ff Will be printed in white with a blue background.
+;;
+
+;;; Code:
+
+(eval-when-compile
+  (require 'cl))
+
+(require 'regexp-opt)
+(require 'faces)
+
+(defgroup rainbow nil
+  "Show color strings with a background color."
+  :tag "Rainbow"
+  :group 'help)
+
+;; Hexadecimal colors
+(defvar rainbow-hexadecimal-colors-font-lock-keywords
+  '(("#[0-9a-fA-F]\\{3\\}[0-9a-fA-F]\\{3\\}?"
+     (0 (rainbow-colorize-itself))))
+  "Font-lock keywords to add for hexadecimal colors.")
+
+;; rgb() colors
+(defvar rainbow-html-rgb-colors-font-lock-keywords
+  '(("rgb(\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*)"
+     (0 (rainbow-colorize-rgb)))
+    ("rgba(\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*[0-9]\\{1,3\\}\s*%?\s*)"
+     (0 (rainbow-colorize-rgb))))
+  "Font-lock keywords to add for RGB colors.")
+
+;; HTML colors name
+(defvar rainbow-html-colors-font-lock-keywords nil
+  "Font-lock keywords to add for HTML colors.")
+(make-variable-buffer-local 'rainbow-html-colors-font-lock-keywords)
+
+(defcustom rainbow-html-colors-alist
+  '(("black" . "#000000")
+    ("silver" . "#C0C0C0")
+    ("gray" . "#808080")
+    ("white" . "#FFFFFF")
+    ("maroon" . "#800000")
+    ("red" . "#FF0000")
+    ("purple" . "#800080")
+    ("fuchsia" . "#FF00FF")
+    ("green" . "#008000")
+    ("lime" . "#00FF00")
+    ("olive" . "#808000")
+    ("yellow" . "#FFFF00")
+    ("navy" . "#000080")
+    ("blue" . "#0000FF")
+    ("teal" . "#008080")
+    ("aqua" . "#00FFFF"))
+  "Alist of HTML colors.
+Each entry should have the form (COLOR-NAME . HEXADECIMAL-COLOR)."
+  :group 'rainbow)
+
+(defcustom rainbow-html-colors-major-mode-list
+  '(html-mode css-mode php-mode nxml-mode xml-mode)
+  "List of major mode where HTML colors are enabled when
+`rainbow-html-colors' is set to auto."
+  :group 'rainbow)
+
+(defcustom rainbow-html-colors 'auto
+  "When to enable HTML colors.
+If set to t, the HTML colors will be enabled.  If set to nil, the
+HTML colors will not be enabled.  If set to auto, the HTML colors
+will be enabled if a major mode has been detected from the
+`rainbow-html-colors-major-mode-list'."
+  :group 'rainbow)
+
+;; X colors
+(defvar rainbow-x-colors-font-lock-keywords
+  `((,(regexp-opt (x-defined-colors) 'words)
+     (0 (rainbow-colorize-itself))))
+  "Font-lock keywords to add for X colors.")
+
+(defcustom rainbow-x-colors-major-mode-list
+  '(emacs-lisp-mode lisp-interaction-mode c-mode c++-mode java-mode)
+  "List of major mode where X colors are enabled when
+`rainbow-x-colors' is set to auto."
+  :group 'rainbow)
+
+(defcustom rainbow-x-colors 'auto
+  "When to enable X colors.
+If set to t, the X colors will be enabled.  If set to nil, the
+X colors will not be enabled.  If set to auto, the X colors
+will be enabled if a major mode has been detected from the
+`rainbow-x-colors-major-mode-list'."
+  :group 'rainbow)
+
+;; LaTeX colors
+(defvar rainbow-latex-rgb-colors-font-lock-keywords
+  '(("{rgb}{\\([0-9.]+\\),\\([0-9.]+\\),\\([0-9.]+\\)}"
+     (0 (rainbow-colorize-rgb-float)))
+    ("{RGB}{\\([0-9]\\{1,3\\}\\),\\([0-9]\\{1,3\\}\\),\\([0-9]\\{1,3\\}\\)}"
+     (0 (rainbow-colorize-rgb)))
+    ("{HTML}{\\([0-9A-Fa-f]\\{6\\}\\)}"
+     (0 (rainbow-colorize-hexadecimal-without-sharp))))
+  "Font-lock keywords to add for X colors.")
+
+(defcustom rainbow-latex-colors-major-mode-list
+  '(latex-mode)
+  "List of major mode where X colors are enabled when
+`rainbow-x-colors' is set to auto."
+  :group 'rainbow)
+
+(defcustom rainbow-latex-colors 'auto
+  "When to enable LaTeX colors.
+If set to t, the LaTeX colors will be enabled. If set to nil, the
+X colors will not be enabled.  If set to auto, the LaTeX colors
+will be enabled if a major mode has been detected from the
+`rainbow-latex-colors-major-mode-list'."
+  :group 'rainbow)
+
+;; Functions
+(defun rainbow-colorize-match (color)
+  "Return a matched string propertized with a face whose
+background is COLOR. The foreground is computed using
+`rainbow-color-luminance', and is either white or black."
+  (put-text-property
+   (match-beginning 0) (match-end 0)
+   'face `((:foreground ,(if (> 128.0 (rainbow-x-color-luminance color))
+                             "white" "black"))
+           (:background ,color))))
+
+(defun rainbow-colorize-itself ()
+  "Colorize a match with itself."
+  (rainbow-colorize-match (match-string-no-properties 0)))
+
+(defun rainbow-colorize-hexadecimal-without-sharp ()
+  "Colorize an hexadecimal colors and prepend # to it."
+  (rainbow-colorize-match (concat "#" (match-string-no-properties 1))))
+
+(defun rainbow-colorize-by-assoc (assoc-list)
+  "Colorize a match with its association from ASSOC-LIST."
+  (rainbow-colorize-match (cdr (assoc (match-string-no-properties 0) assoc-list))))
+
+(defun rainbow-rgb-relative-to-absolute (number)
+  "Convert a relative NUMBER to absolute. If NUMBER is absolute, return NUMBER.
+This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"."
+  (let ((string-length (- (length number) 1)))
+    ;; Is this a number with %?
+    (if (eq (elt number string-length) ?%)
+        (/ (* (string-to-number (substring number 0 string-length)) 255) 100)
+      (string-to-number number))))
+
+(defun rainbow-colorize-rgb ()
+  "Colorize a match with itself."
+  (let ((r (rainbow-rgb-relative-to-absolute (match-string-no-properties 1)))
+        (g (rainbow-rgb-relative-to-absolute (match-string-no-properties 2)))
+        (b (rainbow-rgb-relative-to-absolute (match-string-no-properties 3))))
+    (rainbow-colorize-match (format "#%02X%02X%02X" r g b))))
+
+(defun rainbow-colorize-rgb-float ()
+  "Colorize a match with itself, with relative value."
+  (let ((r (* (string-to-number (match-string-no-properties 1)) 255.0))
+        (g (* (string-to-number (match-string-no-properties 2)) 255.0))
+        (b (* (string-to-number (match-string-no-properties 3)) 255.0)))
+    (rainbow-colorize-match (format "#%02X%02X%02X" r g b))))
+
+(defun rainbow-color-luminance (red green blue)
+  "Calculate the luminance of color composed of RED, BLUE and GREEN."
+  (floor (+ (* .2126 red) (* .7152 green) (* .0722 blue)) 256))
+
+(defun rainbow-x-color-luminance (color)
+  "Calculate the luminance of a color string (e.g. \"#ffaa00\", \"blue\")."
+  (let* ((values (x-color-values color))
+	 (r (car values))
+	 (g (cadr values))
+	 (b (caddr values)))
+    (rainbow-color-luminance r g b)))
+
+(defun rainbow-turn-on ()
+  "Turn on raibow-mode."
+  (font-lock-add-keywords nil
+                          rainbow-hexadecimal-colors-font-lock-keywords)
+  ;; Activate X colors?
+  (when (or (eq rainbow-x-colors t)
+            (and (eq rainbow-x-colors 'auto)
+                 (memq major-mode rainbow-x-colors-major-mode-list)))
+    (font-lock-add-keywords nil
+                            rainbow-x-colors-font-lock-keywords))
+  ;; Activate LaTeX colors?
+  (when (or (eq rainbow-latex-colors t)
+            (and (eq rainbow-latex-colors 'auto)
+                 (memq major-mode rainbow-latex-colors-major-mode-list)))
+    (font-lock-add-keywords nil
+                            rainbow-latex-rgb-colors-font-lock-keywords))
+  ;; Activate HTML colors?
+  (when (or (eq rainbow-html-colors t)
+            (and (eq rainbow-html-colors 'auto)
+                 (memq major-mode rainbow-html-colors-major-mode-list)))
+    (setq rainbow-html-colors-font-lock-keywords
+          `((,(regexp-opt (mapcar 'car rainbow-html-colors-alist) 'words)
+             (0 (rainbow-colorize-by-assoc rainbow-html-colors-alist)))))
+    (font-lock-add-keywords nil
+                            `(,@rainbow-html-colors-font-lock-keywords
+                              ,@rainbow-html-rgb-colors-font-lock-keywords))))
+
+(defun rainbow-turn-off ()
+  "Turn off rainbow-mode."
+  (font-lock-remove-keywords
+   nil
+   `(,@rainbow-hexadecimal-colors-font-lock-keywords
+     ,@rainbow-x-colors-font-lock-keywords
+     ,@rainbow-latex-rgb-colors-font-lock-keywords
+     ,@rainbow-html-colors-font-lock-keywords
+     ,@rainbow-html-rgb-colors-font-lock-keywords)))
+
+;;;###autoload
+(define-minor-mode rainbow-mode
+  "Colorize strings that represent colors.
+This will fontify with colors the string like \"#aabbcc\" or \"blue\"."
+  :lighter " Rbow"
+  (progn
+    (if rainbow-mode
+        (rainbow-turn-on)
+      (rainbow-turn-off))
+    ;; Turn on font lock
+    (font-lock-mode 1)))
+
+(provide 'rainbow-mode)
-- 
1.7.1




^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-07-27 12:50 [PATCH] Add rainbow-mode Julien Danjou
@ 2010-07-27 13:19 ` Lennart Borgman
  2010-07-27 13:44   ` Drew Adams
  0 siblings, 1 reply; 19+ messages in thread
From: Lennart Borgman @ 2010-07-27 13:19 UTC (permalink / raw)
  To: Julien Danjou, Niels Giesen; +Cc: emacs-devel

Hi Julien,

There is (since two years) a minor mode, css-color-mode in
css-color.el written by Niels Giesen, in nXhtml which can do the same
thing and quite a bit more. Perhaps you and Niels can coordinate your
efforts? (Some things might need a bit work in css-color.el, for
example the handling of undo could be a bit better.)

See http://bazaar.launchpad.net/~nxhtml/nxhtml/main/files/head:/util/


On Tue, Jul 27, 2010 at 2:50 PM, Julien Danjou <julien@danjou.info> wrote:
> Signed-off-by: Julien Danjou <julien@danjou.info>
> ---
>
> Hi there,
>
> I'm glad to present rainbow-mode. This is a minor mode that displays color
> names with colored background.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH] Add rainbow-mode
  2010-07-27 13:19 ` Lennart Borgman
@ 2010-07-27 13:44   ` Drew Adams
  2010-07-30 17:13     ` Ted Zlatanov
  0 siblings, 1 reply; 19+ messages in thread
From: Drew Adams @ 2010-07-27 13:44 UTC (permalink / raw)
  To: 'Lennart Borgman', 'Julien Danjou',
	'Niels Giesen'
  Cc: emacs-devel

> > I'm glad to present rainbow-mode. This is a minor mode that 
> > displays color names with colored background.
>
> There is (since two years) a minor mode, css-color-mode in
> css-color.el written by Niels Giesen...
> See http://bazaar.launchpad.net/~nxhtml/nxhtml/main/files/head:/util/

See also: http://www.emacswiki.org/emacs/HexColour. 




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-07-27 13:44   ` Drew Adams
@ 2010-07-30 17:13     ` Ted Zlatanov
  2010-07-30 22:11       ` Lennart Borgman
  0 siblings, 1 reply; 19+ messages in thread
From: Ted Zlatanov @ 2010-07-30 17:13 UTC (permalink / raw)
  To: emacs-devel

On Tue, 27 Jul 2010 06:44:50 -0700 "Drew Adams" <drew.adams@oracle.com> wrote: 

>> > I'm glad to present rainbow-mode. This is a minor mode that 
>> > displays color names with colored background.
>> 
>> There is (since two years) a minor mode, css-color-mode in
>> css-color.el written by Niels Giesen...
>> See http://bazaar.launchpad.net/~nxhtml/nxhtml/main/files/head:/util/

DA> See also: http://www.emacswiki.org/emacs/HexColour. 

I looked at all of them and rainbow-mode seems to be a superset of their
functionality (except for highlighting "blue" in blue, for instance).
It's definitely more configurable and smarter about the major mode.  The
name may have to change so it's clearer what it does: visual-color.el,
perhaps?

I'd like to see it become part of Emacs; it would be useful to me and
probably many others.

Ted




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-07-30 17:13     ` Ted Zlatanov
@ 2010-07-30 22:11       ` Lennart Borgman
  2010-07-30 22:59         ` Wojciech Meyer
  2010-08-02 14:46         ` Ted Zlatanov
  0 siblings, 2 replies; 19+ messages in thread
From: Lennart Borgman @ 2010-07-30 22:11 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: emacs-devel

2010/7/30 Ted Zlatanov <tzz@lifelogs.com>:
> On Tue, 27 Jul 2010 06:44:50 -0700 "Drew Adams" <drew.adams@oracle.com> wrote:
>
>>> > I'm glad to present rainbow-mode. This is a minor mode that
>>> > displays color names with colored background.
>>>
>>> There is (since two years) a minor mode, css-color-mode in
>>> css-color.el written by Niels Giesen...
>>> See http://bazaar.launchpad.net/~nxhtml/nxhtml/main/files/head:/util/
>
> DA> See also: http://www.emacswiki.org/emacs/HexColour.
>
> I looked at all of them and rainbow-mode seems to be a superset of their
> functionality (except for highlighting "blue" in blue, for instance).
> It's definitely more configurable and smarter about the major mode.  The
> name may have to change so it's clearer what it does: visual-color.el,
> perhaps?

I do not think rainbow-mode has all the functionality in
css-color-mode (but I only glanced at rainbow-mode so I am not quite
sure). Are you really sure of this?

> I'd like to see it become part of Emacs; it would be useful to me and
> probably many others.
>
> Ted
>
>
>



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-07-30 22:11       ` Lennart Borgman
@ 2010-07-30 22:59         ` Wojciech Meyer
  2010-07-30 23:41           ` Lennart Borgman
  2010-08-02 14:46         ` Ted Zlatanov
  1 sibling, 1 reply; 19+ messages in thread
From: Wojciech Meyer @ 2010-07-30 22:59 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: Ted Zlatanov, emacs-devel

Lennart Borgman <lennart.borgman@gmail.com> writes:

> 2010/7/30 Ted Zlatanov <tzz@lifelogs.com>:
>> On Tue, 27 Jul 2010 06:44:50 -0700 "Drew Adams" <drew.adams@oracle.com> wrote:
>>
>>>> > I'm glad to present rainbow-mode. This is a minor mode that
>>>> > displays color names with colored background.
>>>>
>>>> There is (since two years) a minor mode, css-color-mode in
>>>> css-color.el written by Niels Giesen...
>>>> See http://bazaar.launchpad.net/~nxhtml/nxhtml/main/files/head:/util/
>>
>> DA> See also: http://www.emacswiki.org/emacs/HexColour.

>>
>> I looked at all of them and rainbow-mode seems to be a superset of their
>> functionality (except for highlighting "blue" in blue, for instance).
>> It's definitely more configurable and smarter about the major mode.  The
>> name may have to change so it's clearer what it does: visual-color.el,
>> perhaps?

I checked this as well, it looks like `rainbow-mode' is mode sensitive
(among other things to consider).

>
> I do not think rainbow-mode has all the functionality in
> css-color-mode (but I only glanced at rainbow-mode so I am not quite
> sure). Are you really sure of this?

I've looked at it too, it has a lot of functionality (including hs[vl]-rgb
conversions). And defines more colours. However it is more heavy weight
and CSS specific.

If I have a right to vote, I would try to include some funcionality from
`css-color-mode' into `rainbow-mode', because of both of them have
potential, and rainbow-mode seems to be more generic...


>
>> I'd like to see it become part of Emacs; it would be useful to me and
>> probably many others.
>>
>> Ted
>>
>>
>>

I think it would be a right thing to do, but also see above.

Just mine two cents.

Wojciech



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-07-30 22:59         ` Wojciech Meyer
@ 2010-07-30 23:41           ` Lennart Borgman
  2010-07-31  0:39             ` Wojciech Meyer
  0 siblings, 1 reply; 19+ messages in thread
From: Lennart Borgman @ 2010-07-30 23:41 UTC (permalink / raw)
  To: Wojciech Meyer; +Cc: Ted Zlatanov, emacs-devel

On Sat, Jul 31, 2010 at 12:59 AM, Wojciech Meyer
<wojciech.meyer@googlemail.com> wrote:
>
> If I have a right to vote, I would try to include some funcionality from
> `css-color-mode' into `rainbow-mode', because of both of them have
> potential, and rainbow-mode seems to be more generic...

In what way is rainbow-mode more generic?



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-07-30 23:41           ` Lennart Borgman
@ 2010-07-31  0:39             ` Wojciech Meyer
  0 siblings, 0 replies; 19+ messages in thread
From: Wojciech Meyer @ 2010-07-31  0:39 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: Ted Zlatanov, Wojciech Meyer, emacs-devel

Lennart Borgman <lennart.borgman@gmail.com> writes:

> On Sat, Jul 31, 2010 at 12:59 AM, Wojciech Meyer
> <wojciech.meyer@googlemail.com> wrote:
>>
>> If I have a right to vote, I would try to include some funcionality from
>> `css-color-mode' into `rainbow-mode', because of both of them have
>> potential, and rainbow-mode seems to be more generic...
>
> In what way is rainbow-mode more generic?

OK, I tried to run it actually, and no, it does not require anything
else then turning on the minor mode dependent on a fontlock.  Generic
meant, that `css-color' module name is a just little bit
misleading. Also, rainbow mode seems to support among CSS, LaTeX and
HTML.

Wojciech



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-07-30 22:11       ` Lennart Borgman
  2010-07-30 22:59         ` Wojciech Meyer
@ 2010-08-02 14:46         ` Ted Zlatanov
  2010-08-02 16:06           ` Lennart Borgman
  1 sibling, 1 reply; 19+ messages in thread
From: Ted Zlatanov @ 2010-08-02 14:46 UTC (permalink / raw)
  To: emacs-devel

On Sat, 31 Jul 2010 00:11:16 +0200 Lennart Borgman <lennart.borgman@gmail.com> wrote: 

LB> 2010/7/30 Ted Zlatanov <tzz@lifelogs.com>:
>> On Tue, 27 Jul 2010 06:44:50 -0700 "Drew Adams" <drew.adams@oracle.com> wrote:
>> 
>>>> > I'm glad to present rainbow-mode. This is a minor mode that
>>>> > displays color names with colored background.
>>>> 
>>>> There is (since two years) a minor mode, css-color-mode in
>>>> css-color.el written by Niels Giesen...
>>>> See http://bazaar.launchpad.net/~nxhtml/nxhtml/main/files/head:/util/
>> 
DA> See also: http://www.emacswiki.org/emacs/HexColour.
>> 
>> I looked at all of them and rainbow-mode seems to be a superset of their
>> functionality (except for highlighting "blue" in blue, for instance).
>> It's definitely more configurable and smarter about the major mode.  The
>> name may have to change so it's clearer what it does: visual-color.el,
>> perhaps?

LB> I do not think rainbow-mode has all the functionality in
LB> css-color-mode (but I only glanced at rainbow-mode so I am not quite
LB> sure). Are you really sure of this?

I agree it doesn't have all the CSS-specific functionality.  Is there
something specific you need?

rainbow-mode.el is more generally useful and can support the
CSS-specific code, whereas css-color-mode.el can't support tex-mode for
instance.  So my vote is still for rainbow-mode.el.

Ted




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-08-02 14:46         ` Ted Zlatanov
@ 2010-08-02 16:06           ` Lennart Borgman
  2010-08-02 16:49             ` Wojciech Meyer
  0 siblings, 1 reply; 19+ messages in thread
From: Lennart Borgman @ 2010-08-02 16:06 UTC (permalink / raw)
  To: Ted Zlatanov, Niels Giesen; +Cc: emacs-devel

2010/8/2 Ted Zlatanov <tzz@lifelogs.com>:
>
> LB> I do not think rainbow-mode has all the functionality in
> LB> css-color-mode (but I only glanced at rainbow-mode so I am not quite
> LB> sure). Are you really sure of this?
>
> I agree it doesn't have all the CSS-specific functionality.  Is there
> something specific you need?

I would be glad to get Niels comments on this. I do not think there is
much that is very css-specific. (For example the conversion between
different color notations could be useful in other places).

> rainbow-mode.el is more generally useful and can support the
> CSS-specific code, whereas css-color-mode.el can't support tex-mode for
> instance.

I am surprised to read that, but then perhaps functionality from the
both minor modes should be merged?



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-08-02 16:06           ` Lennart Borgman
@ 2010-08-02 16:49             ` Wojciech Meyer
  2010-08-04  8:05               ` Niels Giesen
  0 siblings, 1 reply; 19+ messages in thread
From: Wojciech Meyer @ 2010-08-02 16:49 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: Ted Zlatanov, emacs-devel, Niels Giesen

<lennart.borgman@gmail.com> wrote:
> 2010/8/2 Ted Zlatanov <tzz@lifelogs.com>:
>>
>> LB> I do not think rainbow-mode has all the functionality in
>> LB> css-color-mode (but I only glanced at rainbow-mode so I am not quite
>> LB> sure). Are you really sure of this?
>>
>> I agree it doesn't have all the CSS-specific functionality.  Is there
>> something specific you need?
>
> I would be glad to get Niels comments on this. I do not think there is
> much that is very css-specific. (For example the conversion between
> different color notations could be useful in other places).

I have seen HSV and HSL conversions, pluss css-color-mode works
in every mode. The name is a bit specific only.

>
>> rainbow-mode.el is more generally useful and can support the
>> CSS-specific code, whereas css-color-mode.el can't support tex-mode for
>> instance.
>
> I am surprised to read that, but then perhaps functionality from the
> both minor modes should be merged?

Yes, I think it should be.

Wojciech



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-08-02 16:49             ` Wojciech Meyer
@ 2010-08-04  8:05               ` Niels Giesen
  2010-08-04 14:11                 ` Ted Zlatanov
  0 siblings, 1 reply; 19+ messages in thread
From: Niels Giesen @ 2010-08-04  8:05 UTC (permalink / raw)
  To: Wojciech Meyer; +Cc: Ted Zlatanov, Lennart Borgman, emacs-devel

Hi all,

Sorry for chiming in this late, but I had little time. So here are my thoughts.

This morning I finally got a chance to look at rainbow-mode. I must
say I like the clearness of the code. I definitely want to see wether
css-color.el can learn from it.

It seems rainbow-mode is less css-specific or more generic in that it
also handles LaTeX colors and x-defined-colors. On the other hand,
rainbow-mode does not handle all color notations valid in css (no
hsl()).

Css-color-mode currently only handles colors that are (also) valid css-colors.

In my view, the biggest plus of css-color are the conversions, whereas
the biggest plus of rainbow-mode is the automatic handling of
major-modes.

I would be open to add support for more color notations, possibly
user-configurable.

We may make `css-color-type-circle' buffer-local and use
rainbow-mode's handling of major modes to set the appropriate ring.

This means adding appropriate conversion functions, and bailing out
when the ring contains just one type (i.e., new type == old type).

We could opt to still do font-locking of all color notations
regardless of the major-mode, or split up font-lock-keywords the same
way that rainbow-mode does.


Regards,

Niels.

On Mon, Aug 2, 2010 at 6:49 PM, Wojciech Meyer
<wojciech.meyer@googlemail.com> wrote:
> <lennart.borgman@gmail.com> wrote:
>> 2010/8/2 Ted Zlatanov <tzz@lifelogs.com>:
>>>
>>> LB> I do not think rainbow-mode has all the functionality in
>>> LB> css-color-mode (but I only glanced at rainbow-mode so I am not quite
>>> LB> sure). Are you really sure of this?
>>>
>>> I agree it doesn't have all the CSS-specific functionality.  Is there
>>> something specific you need?
>>
>> I would be glad to get Niels comments on this. I do not think there is
>> much that is very css-specific. (For example the conversion between
>> different color notations could be useful in other places).
>
> I have seen HSV and HSL conversions, pluss css-color-mode works
> in every mode. The name is a bit specific only.
>
>>
>>> rainbow-mode.el is more generally useful and can support the
>>> CSS-specific code, whereas css-color-mode.el can't support tex-mode for
>>> instance.
>>
>> I am surprised to read that, but then perhaps functionality from the
>> both minor modes should be merged?
>
> Yes, I think it should be.
>
> Wojciech
>



-- 
http://pft.github.com



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-08-04  8:05               ` Niels Giesen
@ 2010-08-04 14:11                 ` Ted Zlatanov
  2010-08-04 15:17                   ` Chong Yidong
                                     ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Ted Zlatanov @ 2010-08-04 14:11 UTC (permalink / raw)
  To: emacs-devel; +Cc: Julien Danjou

On Wed, 4 Aug 2010 10:05:00 +0200 Niels Giesen <niels.giesen@gmail.com> wrote: 

NG> This morning I finally got a chance to look at rainbow-mode. I must
NG> say I like the clearness of the code. I definitely want to see wether
NG> css-color.el can learn from it.

NG> It seems rainbow-mode is less css-specific or more generic in that it
NG> also handles LaTeX colors and x-defined-colors. On the other hand,
NG> rainbow-mode does not handle all color notations valid in css (no
NG> hsl()).

Even if rainbow-mode.el were included in Emacs with the HSL/HSV
conversions, it sounds like you still want to continue developing
css-color.el (which is fine, of course).  Woijciech and Lennart wanted
to merge the two; it seems unlikely based on your comments.

Right now rainbow-mode.el seems like a better fit for Emacs because it's
more generally useful.  Do you have objections to that, or do you want
some time to add the features you mentioned to css-color.el and then we
can reevaluate things?

Julien, do you have any comments on the HSV/HSL conversions or any other
part of this conversation?

Ted




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-08-04 14:11                 ` Ted Zlatanov
@ 2010-08-04 15:17                   ` Chong Yidong
  2010-08-09  8:47                   ` Julien Danjou
  2010-08-10 14:00                   ` Julien Danjou
  2 siblings, 0 replies; 19+ messages in thread
From: Chong Yidong @ 2010-08-04 15:17 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: Julien Danjou, emacs-devel

Ted Zlatanov <tzz@lifelogs.com> writes:

> Even if rainbow-mode.el were included in Emacs with the HSL/HSV
> conversions, it sounds like you still want to continue developing
> css-color.el (which is fine, of course).  Woijciech and Lennart wanted
> to merge the two; it seems unlikely based on your comments.
>
> Right now rainbow-mode.el seems like a better fit for Emacs because it's
> more generally useful.  Do you have objections to that, or do you want
> some time to add the features you mentioned to css-color.el and then we
> can reevaluate things?
>
> Julien, do you have any comments on the HSV/HSL conversions or any other
> part of this conversation?

I've added rainbow-mode to the Emacs 24 package repository.  Duplication
does not bother me, since neither css-color and rainbow-mode are very
large, but whether the developers of css-color and rainbow-mode want to
collaborate is up to them.  Assuming the packages don't end up merging,
I am open to adding css-color to the repository as well.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-08-04 14:11                 ` Ted Zlatanov
  2010-08-04 15:17                   ` Chong Yidong
@ 2010-08-09  8:47                   ` Julien Danjou
  2010-08-10 14:00                   ` Julien Danjou
  2 siblings, 0 replies; 19+ messages in thread
From: Julien Danjou @ 2010-08-09  8:47 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: emacs-devel

On Wed, Aug 04 2010, Ted Zlatanov wrote:

> Julien, do you have any comments on the HSV/HSL conversions or any other
> part of this conversation?

I never heard of HSV/HSL (I'm not a web dev), but it seems trivial to
add support for that in rainbow mode, so I'll do it ASAP.

IMHO, we could merge both modes. I think I'll try to grab useful ideas
or pieces from css-color-mode. :-)

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



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-08-04 14:11                 ` Ted Zlatanov
  2010-08-04 15:17                   ` Chong Yidong
  2010-08-09  8:47                   ` Julien Danjou
@ 2010-08-10 14:00                   ` Julien Danjou
  2010-08-10 15:54                     ` Ted Zlatanov
  2010-08-10 16:00                     ` Lennart Borgman
  2 siblings, 2 replies; 19+ messages in thread
From: Julien Danjou @ 2010-08-10 14:00 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: emacs-devel


On Wed, Aug 04 2010, Ted Zlatanov wrote:

> Julien, do you have any comments on the HSV/HSL conversions or any other
> part of this conversation?

FWIW, I've added hsl() and hsla() support to rainbow-mode.

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



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-08-10 14:00                   ` Julien Danjou
@ 2010-08-10 15:54                     ` Ted Zlatanov
  2010-08-10 16:00                     ` Lennart Borgman
  1 sibling, 0 replies; 19+ messages in thread
From: Ted Zlatanov @ 2010-08-10 15:54 UTC (permalink / raw)
  To: emacs-devel

On Tue, 10 Aug 2010 16:00:25 +0200 Julien Danjou <julien@danjou.info> wrote: 

JD> On Wed, Aug 04 2010, Ted Zlatanov wrote:

>> Julien, do you have any comments on the HSV/HSL conversions or any other
>> part of this conversation?

JD> FWIW, I've added hsl() and hsla() support to rainbow-mode.

Wonderful.  One of the maintainers will have to push it to the
elpa.gnu.org repo.  Thanks for your work.

Ted




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-08-10 14:00                   ` Julien Danjou
  2010-08-10 15:54                     ` Ted Zlatanov
@ 2010-08-10 16:00                     ` Lennart Borgman
  2010-08-10 18:06                       ` Julien Danjou
  1 sibling, 1 reply; 19+ messages in thread
From: Lennart Borgman @ 2010-08-10 16:00 UTC (permalink / raw)
  To: Julien Danjou; +Cc: Ted Zlatanov, emacs-devel

On Tue, Aug 10, 2010 at 4:00 PM, Julien Danjou <julien@danjou.info> wrote:
>
> On Wed, Aug 04 2010, Ted Zlatanov wrote:
>
> > Julien, do you have any comments on the HSV/HSL conversions or any other
> > part of this conversation?
>
> FWIW, I've added hsl() and hsla() support to rainbow-mode.


Sounds good.

However in css-color-mode there is also support for interactively
changing the colors. I think it is useful (but it needs some work
regarding buffer undo).



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] Add rainbow-mode
  2010-08-10 16:00                     ` Lennart Borgman
@ 2010-08-10 18:06                       ` Julien Danjou
  0 siblings, 0 replies; 19+ messages in thread
From: Julien Danjou @ 2010-08-10 18:06 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: Ted Zlatanov, emacs-devel

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

On Tue, Aug 10 2010, Lennart Borgman wrote:

> However in css-color-mode there is also support for interactively
> changing the colors. I think it is useful (but it needs some work
> regarding buffer undo).

Still on my todo, if that's not too much work / too ugly.

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

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2010-08-10 18:06 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-27 12:50 [PATCH] Add rainbow-mode Julien Danjou
2010-07-27 13:19 ` Lennart Borgman
2010-07-27 13:44   ` Drew Adams
2010-07-30 17:13     ` Ted Zlatanov
2010-07-30 22:11       ` Lennart Borgman
2010-07-30 22:59         ` Wojciech Meyer
2010-07-30 23:41           ` Lennart Borgman
2010-07-31  0:39             ` Wojciech Meyer
2010-08-02 14:46         ` Ted Zlatanov
2010-08-02 16:06           ` Lennart Borgman
2010-08-02 16:49             ` Wojciech Meyer
2010-08-04  8:05               ` Niels Giesen
2010-08-04 14:11                 ` Ted Zlatanov
2010-08-04 15:17                   ` Chong Yidong
2010-08-09  8:47                   ` Julien Danjou
2010-08-10 14:00                   ` Julien Danjou
2010-08-10 15:54                     ` Ted Zlatanov
2010-08-10 16:00                     ` Lennart Borgman
2010-08-10 18:06                       ` Julien Danjou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).