branch: externals/colorful-mode commit 1831140c9008369d9ceb339fd956c8f18d26d204 Author: Elias G. B. Perez <eg642...@gmail.com> Commit: Elias G. B. Perez <eg642...@gmail.com>
Release 1.0.2 This is a minor release with little changes. * .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 ++-- README.org | 5 ++++- colorful-mode.el | 31 ++++++++++++++++--------------- 4 files changed, 23 insertions(+), 19 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/README.org b/README.org index bcf6303b68..7d856d2ee4 100644 --- a/README.org +++ b/README.org @@ -1,4 +1,4 @@ -#+title: [[./assets/colorful-mode-logo.svg]] +#+title: colorful-mode #+subtitle: Preview any color in your buffer in real time. #+author: Elias G. Perez #+language: en @@ -7,10 +7,13 @@ #+texinfo_dir_title: colorful-mode: (colorful-mode). #+texinfo_dir_desc: Preview color hexs in your buffer +[[./assets/colorful-mode-logo.svg]] + #+BEGIN_QUOTE Preview any color in your buffer in real time. #+END_QUOTE +#+html: <a href="https://elpa.gnu.org/packages/colorful-mode.html"><img alt="GNU ELPA" src="https://elpa.gnu.org/packages/colorful-mode.svg"/></a> #+html: <a href="https://jcs-emacs.github.io/jcs-elpa/"><img alt="JCS ELPA" src="https://raw.githubusercontent.com/jcs-emacs/badges/master/elpa/v/colorful-mode.svg"> #+html: <img src="https://raw.githubusercontent.com/DevelopmentCool2449/emacs-svg-badges/main/elisp_logo_warning.svg" align="right" width="10%"> diff --git a/colorful-mode.el b/colorful-mode.el index 5ef1ee034d..20c40d77d4 100644 --- a/colorful-mode.el +++ b/colorful-mode.el @@ -7,7 +7,7 @@ ;; Package-Requires: ((emacs "28.1") (compat "29.1.4.4")) ;; Homepage: https://github.com/DevelopmentCool2449/colorful-mode ;; Keywords: faces, tools, matching -;; Version: 1.0.0 +;; Version: 1.0.2 ;; This file is part of GNU Emacs. @@ -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