;;; nf-rgb.el --- rgb.txt parsing and display ;; Author: Noah Friedman ;; Created: 2023-10-25 ;; Public domain. ;; $Id: nf-rgb.el,v 1.2 2023/11/05 00:43:12 friedman Exp $ ;;; Commentary: ;;; Code: (defvar nf-color-alist nil) (defconst nf-rgb-color-regex "^[ \t]*\\([0-9]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\(.+\\)[ \t]*$") (defun nf-rgb-parse-buffer (buffer) (save-current-buffer (set-buffer buffer) (save-excursion (goto-char (point-min)) (let ((alist nil)) (while (re-search-forward nf-rgb-color-regex nil t) (push (list (match-string 4) (string-to-number (match-string 1)) (string-to-number (match-string 2)) (string-to-number (match-string 3))) alist)) alist)))) (defun nf-rgb-parse-file (file) (with-temp-buffer (insert-file-contents file) (nf-rgb-parse-buffer (current-buffer)))) (defun nf-rgb-color-names (alist) (mapcar 'car alist)) (defun nf-list-colors-display () (interactive) (let ((x-colors (nf-rgb-color-names nf-color-alist))) (list-colors-display))) (provide 'nf-rgb) ;; nf-rgb.el ends here