diff lisp/hfy-cmap.el @ 106128:ed77a6edfaa1

* hfy-cmap.el (hfy-rgb-file): Use locate-file. (htmlfontify-load-rgb-file): Remove unnused var `ff'. Use with-current-buffer and string-to-number. (hfy-fallback-colour-values): Use assoc-string. * htmlfontify.el (hfy-face-to-css): Remove unused var `style'. (hfy-face-at): Remove unused var `found-face'. (hfy-compile-stylesheet): Remove unused var `css'. (hfy-fontify-buffer): Remove unused vars `in-style', `invis-button', and `orig-buffer'. (hfy-buffer, hfy-copy-and-fontify-file, hfy-parse-tags-buffer): Use with-current-buffer. (hfy-text-p): Use expand-file-name and fewer setq.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 19 Nov 2009 20:47:40 +0000
parents 10d66efa4c61
children 3b90f039f42b
line wrap: on
line diff
--- a/lisp/hfy-cmap.el	Thu Nov 19 20:22:03 2009 +0000
+++ b/lisp/hfy-cmap.el	Thu Nov 19 20:47:40 2009 +0000
@@ -798,12 +798,7 @@
 
 (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-*$")
@@ -818,36 +813,31 @@
     (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 ()
   (interactive)
   (setq hfy-rgb-txt-colour-map nil))
 
 (defun hfy-fallback-colour-values (colour-string)
-  (cdr (assoc-ignore-case colour-string (or hfy-rgb-txt-colour-map
-					    hfy-fallback-colour-map))) )
+  (cdr (assoc-string colour-string (or hfy-rgb-txt-colour-map
+                                       hfy-fallback-colour-map))) )
 
 (provide 'hfy-cmap)
 ;;; hfy-cmap.el ends here