;;; hfy-cmap.el --- Fallback colour name -> rgb mapping for `htmlfontify'
-;; Copyright (C) 2002, 2003, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2003, 2009-2012 Free Software Foundation, Inc.
;; Emacs Lisp Archive Entry
;; Package: htmlfontify
;; Description: fallback code for colour name -> rgb mapping
;; URL: http://rtfm.etla.org/emacs/htmlfontify/
;; Last-Updated: Sat 2003-02-15 03:49:32 +0000
+;; Package: htmlfontify
;; This file is part of GNU Emacs.
(defun hfy-rgb-file ()
"Return a fully qualified path to the X11 style rgb.txt file."
- (catch 'rgb-file
- (mapcar
- (lambda (DIR)
- (let ((rgb-file (concat DIR "/rgb.txt")))
- (if (file-readable-p rgb-file)
- (throw 'rgb-file rgb-file) nil)) ) hfy-rgb-load-path) nil))
+ (locate-file "rgb.txt" hfy-rgb-load-path))
(defconst hfy-rgb-regex
"^\\s-*\\([0-9]+\\)\\s-+\\([0-9]+\\)\\s-+\\([0-9]+\\)\\s-+\\(.+\\)\\s-*$")
+;;;###autoload
(defun htmlfontify-load-rgb-file (&optional file)
"Load an X11 style rgb.txt FILE.
Search `hfy-rgb-load-path' if FILE is not specified.
(read-file-name "rgb.txt \(equivalent\) file: " "" nil t (hfy-rgb-file))))
(let ((rgb-buffer nil)
(end-of-rgb 0)
- (rgb-txt nil)
- (ff 255.0))
+ (rgb-txt nil))
(if (and (setq rgb-txt (or file (hfy-rgb-file)))
(file-readable-p rgb-txt))
- (save-excursion
- (setq rgb-buffer (find-file-noselect rgb-txt 'nowarn))
- (set-buffer rgb-buffer)
- (goto-char (point-min))
+ (with-current-buffer
+ (setq rgb-buffer (find-file-noselect rgb-txt 'nowarn))
+ (goto-char (point-min))
(htmlfontify-unload-rgb-file)
(while (/= end-of-rgb 1)
(if (looking-at hfy-rgb-regex)
(setq hfy-rgb-txt-colour-map
(cons (list (match-string 4)
- (string-to-int (match-string 1))
- (string-to-int (match-string 2))
- (string-to-int (match-string 3)))
+ (string-to-number (match-string 1))
+ (string-to-number (match-string 2))
+ (string-to-number (match-string 3)))
hfy-rgb-txt-colour-map)) )
(setq end-of-rgb (forward-line)))
- (kill-buffer rgb-buffer))
- )
- )
- )
+ (kill-buffer rgb-buffer)))))
(defun htmlfontify-unload-rgb-file ()
+ "Unload the current color name -> rgb translation map."
(interactive)
(setq hfy-rgb-txt-colour-map nil))
+;;;###autoload
(defun hfy-fallback-colour-values (colour-string)
- (cdr (assoc-ignore-case colour-string (or hfy-rgb-txt-colour-map
- hfy-fallback-colour-map))) )
+ "Use a fallback method for obtaining the rgb values for a color."
+ (cdr (assoc-string colour-string (or hfy-rgb-txt-colour-map
+ hfy-fallback-colour-map))) )
(provide 'hfy-cmap)
-;;; hfy-cmap.el ends here
+;; Local Variables:
+;; generated-autoload-file: "htmlfontify.el"
+;; End:
+
+;;; hfy-cmap.el ends here