branch: externals/colorful-mode commit 40204fa9c93c91d17676f14a36b019ff7551229e Author: Elias G. B. Perez <eg642...@gmail.com> Commit: Elias G. B. Perez <eg642...@gmail.com>
Minor fixes * .elpaignore: Sorting. * CONTRIBUITING.org: Minor changes. * colorful-mode.el: (colorful--latex-gray-to-hex) (colorful--hsl-to-hex): Use `and' instead ignore-errors. (colorful-add-hex-colors, colorful-add-color-names) (colorful-add-rgb-colors, colorful-add-hsl-colors) (colorful-add-latex-colors): Use cl-pushnew instead add-to-list. --- .elpaignore | 2 +- CONTRIBUITING.org | 4 ++-- colorful-mode.el | 29 +++++++++++++++-------------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.elpaignore b/.elpaignore index f56f4d1acf..33272a71b8 100644 --- a/.elpaignore +++ b/.elpaignore @@ -2,5 +2,5 @@ assets test .project CONTRIBUITING.org +COPYING README.org -COPYING \ No newline at end of file diff --git a/CONTRIBUITING.org b/CONTRIBUITING.org index 6d2276160a..32be26c1a2 100644 --- a/CONTRIBUITING.org +++ b/CONTRIBUITING.org @@ -1,8 +1,8 @@ #+title: How to contribute If your contribution is less than 15 lines [see: [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Copyright-Assignment.html][Copyright Assignment]]] -you can open a PR and your contribution will be reviewed and maybe merged -quickly. +you can send a patch and your contribution will be reviewed and maybe +merged quickly. If you want send a patch *you will need assign copyright to FSF*, for this then please email the following information to diff --git a/colorful-mode.el b/colorful-mode.el index 5ef1ee034d..97635d01ed 100644 --- a/colorful-mode.el +++ b/colorful-mode.el @@ -35,10 +35,11 @@ ;;;; Libraries (require 'compat) - (require 'color) -(eval-when-compile (require 'subr-x)) -(eval-when-compile (require 'rx)) +(eval-when-compile + (require 'subr-x) + (require 'rx) + (require 'cl-lib)) ;;;; User Options @@ -332,9 +333,9 @@ RGB must be a string." (string-remove-prefix "rgb(" rgb) (string-remove-prefix "rgba(" rgb)) (rx (one-or-more (any "," " " "\t" "\n" "\r" "\v" "\f"))))) - (r (ignore-errors (/ (colorful--percentage-to-absolute (nth 0 rgb)) 255.0))) - (g (ignore-errors (/ (colorful--percentage-to-absolute (nth 1 rgb)) 255.0))) - (b (ignore-errors (/ (colorful--percentage-to-absolute (nth 2 rgb)) 255.0)))) + (r (and (nth 0 rgb) (/ (colorful--percentage-to-absolute (nth 0 rgb)) 255.0))) + (g (and (nth 1 rgb) (/ (colorful--percentage-to-absolute (nth 1 rgb)) 255.0))) + (b (and (nth 2 rgb) (/ (colorful--percentage-to-absolute (nth 2 rgb)) 255.0)))) (color-rgb-to-hex r g b digit))) (defun colorful--hsl-to-hex (hsl &optional digit) @@ -346,9 +347,9 @@ HSL must be a string." (string-remove-prefix "hsl(" hsl) (string-remove-prefix "hsla(" hsl)) (rx (one-or-more (any "," " " "\t" "\n""\r" "\v" "\f"))))) - (h (ignore-errors (/ (string-to-number (nth 0 hsl)) 360.0))) - (s (ignore-errors (/ (string-to-number (nth 1 hsl)) 100.0))) - (l (ignore-errors (/ (string-to-number (nth 2 hsl)) 100.0))) + (h (and (nth 0 hsl) (/ (string-to-number (nth 0 hsl)) 360.0))) + (s (and (nth 1 hsl) (/ (string-to-number (nth 1 hsl)) 100.0))) + (l (and (nth 2 hsl) (/ (string-to-number (nth 2 hsl)) 100.0))) (rgb (append (color-hsl-to-rgb h s l) `(,digit)))) (apply #'color-rgb-to-hex rgb))) @@ -633,7 +634,7 @@ converted to a Hex color." "Function for add hex colors to `colorful-color-keywords'. This is intended to be used with `colorful-extra-color-keyword-functions'." (dolist (colors colorful-hex-font-lock-keywords) - (add-to-list 'colorful-color-keywords colors t))) + (cl-pushnew colors colorful-color-keywords))) (defvar colorful-color-name-font-lock-keywords `((,(regexp-opt (append @@ -648,7 +649,7 @@ This is intended to be used with `colorful-extra-color-keyword-functions'." "Function for add Color names to `colorful-color-keywords'. This is intended to be used with `colorful-extra-color-keyword-functions'." (dolist (colors colorful-color-name-font-lock-keywords) - (add-to-list 'colorful-color-keywords colors t))) + (cl-pushnew colors colorful-color-keywords))) (defvar colorful-rgb-font-lock-keywords `((,(rx (seq "rgb" (opt "a") "(" (zero-or-more " ") @@ -678,7 +679,7 @@ This is intended to be used with `colorful-extra-color-keyword-functions'." "Function for add CSS RGB colors to `colorful-color-keywords'. This is intended to be used with `colorful-extra-color-keyword-functions'." (dolist (colors colorful-rgb-font-lock-keywords) - (add-to-list 'colorful-color-keywords colors t))) + (cl-pushnew colors colorful-color-keywords))) (defvar colorful-hsl-font-lock-keywords `((,(rx (seq "hsl" (opt "a") "(" (zero-or-more " ") @@ -702,7 +703,7 @@ This is intended to be used with `colorful-extra-color-keyword-functions'." "Function for add CSS HSL colors. This is intended to be used with `colorful-extra-color-keyword-functions'." (dolist (colors colorful-hsl-font-lock-keywords) - (add-to-list 'colorful-color-keywords colors t))) + (cl-pushnew colors colorful-color-keywords))) (defvar colorful-latex-keywords `((,(rx (seq "{" (or "rgb" "RGB") "}{" (zero-or-more " ") @@ -721,7 +722,7 @@ This is intended to be used with `colorful-extra-color-keyword-functions'." "Function for add LaTex rgb/RGB/HTML/Grey colors. This is intended to be used with `colorful-extra-color-keyword-functions'." (dolist (colors colorful-latex-keywords) - (add-to-list 'colorful-color-keywords colors t))) + (cl-pushnew colors colorful-color-keywords))) ;;;; Minor mode defintinions