GNU bug report logs -
#25525
25.1.90; add color highlighting to css mode
Previous Next
Reported by: Tom Tromey <tom <at> tromey.com>
Date: Wed, 25 Jan 2017 08:08:01 UTC
Severity: wishlist
Tags: patch
Found in version 25.1.90
Done: Tom Tromey <tom <at> tromey.com>
Bug is archived. No further changes may be made.
Full log
Message #86 received at 25525 <at> debbugs.gnu.org (full text, mbox):
On Apr 20 2017, Tom Tromey <tom <at> tromey.com> wrote:
> +(defun css--named-color (str)
> + "Check whether STR, seen at point, is CSS named color.
> +Returns STR if it is a valid color. Special care is taken
> +to exclude some SCSS contructs."
> + (when-let ((color (assoc str css--color-map)))
> + (save-excursion
> + ;; We still have the match from the caller of
> + ;; css--compute-color.
> + (goto-char (match-beginning 0))
> + (forward-comment (- (point)))
> + (skip-chars-backward "@[:alpha:]")
> + (unless (looking-at-p "@\\(mixin\\|include\\)")
> + (cdr color)))))
> +
> +(defun css--compute-color ()
> + "Return the CSS color at point.
> +Point should be just after the start of a CSS color, as recognized
> +by `css--colors-regexp'. This function will either return the color,
> +as a hex RGB string; or `nil' if no color could be recognized. When
> +this function returns, point will be at the end of the recognized
> +color."
> + (let ((match (downcase (match-string 0))))
> + (cond
> + ((eq (aref match 0) ?#)
> + (css--hex-color match))
> + ((member match '("rgb(" "rgba("))
> + (css--rgb-color))
> + ((member match '("hsl(" "hsla("))
> + (css--hsl-color))
> + ;; Evaluate to the color if the name is found.
> + ((css--named-color match)))))
It would be better to pass the match string as an argument instead of
depending on the caller to establish a match.
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
This bug report was last modified 8 years and 80 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.