emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/lisp ChangeLog hfy-cmap.el htmlfontify.el


From: Stefan Monnier
Subject: [Emacs-diffs] emacs/lisp ChangeLog hfy-cmap.el htmlfontify.el
Date: Thu, 19 Nov 2009 20:47:44 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        09/11/19 20:47:43

Modified files:
        lisp           : ChangeLog hfy-cmap.el htmlfontify.el 

Log message:
        * 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.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.16672&r2=1.16673
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/hfy-cmap.el?cvsroot=emacs&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/htmlfontify.el?cvsroot=emacs&r1=1.1&r2=1.2

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.16672
retrieving revision 1.16673
diff -u -b -r1.16672 -r1.16673
--- ChangeLog   19 Nov 2009 20:21:01 -0000      1.16672
+++ ChangeLog   19 Nov 2009 20:47:40 -0000      1.16673
@@ -1,3 +1,18 @@
+2009-11-19  Stefan Monnier  <address@hidden>
+
+       * 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.
+
 2009-11-19  Vivek Dasmohapatra  <address@hidden>
 
        * htmlfontify.el, hfy-cmap.el: New files.

Index: hfy-cmap.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/hfy-cmap.el,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- hfy-cmap.el 19 Nov 2009 20:21:03 -0000      1.1
+++ hfy-cmap.el 19 Nov 2009 20:47:43 -0000      1.2
@@ -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,35 +813,30 @@
     (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
+       (with-current-buffer
          (setq rgb-buffer (find-file-noselect rgb-txt 'nowarn))
-         (set-buffer rgb-buffer)
          (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
+  (cdr (assoc-string colour-string (or hfy-rgb-txt-colour-map
                                            hfy-fallback-colour-map))) )
 
 (provide 'hfy-cmap)

Index: htmlfontify.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/htmlfontify.el,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- htmlfontify.el      19 Nov 2009 20:21:04 -0000      1.1
+++ htmlfontify.el      19 Nov 2009 20:47:43 -0000      1.2
@@ -813,6 +813,7 @@
 TAG is an Emacs font attribute key (eg :underline).
 VAL is ignored."
   (list
+   ;; FIXME: Why not '("text-decoration" . "underline")?  --Stef
    (cond ((eq tag :underline     ) (cons "text-decoration" "underline"   ))
          ((eq tag :overline      ) (cons "text-decoration" "overline"    ))
          ((eq tag :strike-through) (cons "text-decoration" "line-through")))))
@@ -1085,7 +1086,6 @@
   ;;(message "hfy-face-to-css");;DBUG
   (let ((css-list nil)
         (css-text nil)
-        (style    nil)
         (seen     nil))
     ;;(message "(hfy-face-to-style %S)" fn)
     (setq css-list (hfy-face-to-style fn))
@@ -1206,7 +1206,6 @@
           (face-name   (hfy-p-to-face (text-properties-at p)))
           ;; (face-name    (hfy-get-face-at p))
           (prop-seen    nil)
-          (found-face   nil)
           (extra-props  nil)
           (text-props   (text-properties-at p)))
       ;;(message "face-name: %S" face-name)
@@ -1315,7 +1314,6 @@
                                (t                 p)))
                      (if (memq p prop-seen) nil ;; noop
                        (setq prop-seen   (cons p prop-seen)
-                             found-face  t
                              extra-props (cons p (cons v extra-props)))) ))))))
          overlay-data)
         ;;(message "+ %d: %s; %S" p face-name extra-props)
@@ -1340,7 +1338,6 @@
         ;; Make the font stack stay:
         ;;(hfy-tmpfont-stack nil)
         (fn         nil)
-        (css        nil)
         (style      nil))
     (save-excursion
       (goto-char pt)
@@ -1459,13 +1456,12 @@
   (let* ((name (concat (buffer-name) hfy-extn))
          (src               (buffer-file-name))
          (buf  (get-buffer-create        name)))
-    (save-excursion
-      (set-buffer buf)
-      (if src (setq buffer-file-name (concat src hfy-extn))
-        (if (string-match "^.*/\\([^/]*\\)$" name)
+    (with-current-buffer buf
             (setq buffer-file-name
-                  (concat default-directory "/" (match-string 1 name)))
-          (setq buffer-file-name (concat default-directory "/" name) )))
+            (if src (concat src hfy-extn)
+              (expand-file-name (if (string-match "^.*/\\([^/]*\\)$" name)
+                                    (match-string 1 name)
+                                  name))))
       buf)))
 
 (defun hfy-lookup (face style)
@@ -1602,10 +1598,7 @@
 SRCDIR, if set, is the directory being htmlfontified.
 FILE, if set, is the file name."
   (if srcdir (setq srcdir (directory-file-name srcdir)))
-  (let* ( (in-style                    nil)
-          (invis-buttons               nil)
-          (orig-buffer    (current-buffer))
-          (html-buffer        (hfy-buffer))
+  (let* ( (html-buffer        (hfy-buffer))
           (css-sheet                   nil)
           (css-map                     nil)
           (invis-ranges                nil)
@@ -1848,9 +1841,8 @@
 
 (defun hfy-text-p (srcdir file)
   "Is SRCDIR/FILE text? Uses `hfy-istext-command' to determine this."
-  (let (cmd rsp)
-    (setq cmd (format hfy-istext-command (concat srcdir "/" file))
-          rsp (shell-command-to-string    cmd))
+  (let* ((cmd (format hfy-istext-command (expand-file-name file srcdir)))
+         (rsp (shell-command-to-string    cmd)))
     (if (string-match "text" rsp) t nil)))
 
 ;; open a file, check fontification, if fontified, write a fontified copy
@@ -1867,9 +1859,8 @@
         (source nil)
         (html   nil))
     (cd srcdir)
-    (save-excursion
-      (setq source (find-file-noselect file))
-      (set-buffer   source)
+    (with-current-buffer (setq source (find-file-noselect file))
+      ;; FIXME: Shouldn't this use expand-file-name?  --Stef
       (setq target (concat dstdir "/" file))
       (hfy-make-directory (hfy-dirname target))
       (if (not (hfy-opt 'skip-refontification)) (hfy-force-fontification))
@@ -1942,6 +1933,8 @@
 first character of TAG.\n
 See also: `hfy-relstub', `hfy-index-file'`'."
   ;;(message "hfy-href-stub");;DBUG
+  ;; FIXME: Why not use something like
+  ;; (file-relative-name (if ...) (file-name-directory this-file)) ?  --Stef
   (concat
    (hfy-relstub this-file)
    (if (= 1 (length def-files)) (car def-files)
@@ -1965,6 +1958,7 @@
 (defun hfy-word-regex (string)
   "Return a regex that matches STRING as the first `match-string', with non
 word characters on either side."
+  ;; FIXME: Should this use [^$[:alnum:]_] instead?  --Stef
   (concat "[^$A-Za-z_0-9]\\(" (regexp-quote string) "\\)[^A-Za-z_0-9]"))
 
 ;; mark all tags for hyperlinking, except the tags at
@@ -2092,8 +2086,7 @@
     (clrhash cache-hash)
 
     ;; cache the TAG => ((file line point) (file line point) ... ) entries:
-    (save-excursion
-      (set-buffer buffer)
+    (with-current-buffer buffer
       (goto-char (point-min))
 
       (while (and (looking-at "^\x0c") (= 0 (forward-line 1)))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]