changeset 82095:b5773fe4ea48

(ps-multibyte-buffer): Docstring fixes. (ps-mule-encode-ethiopic): Make it clear that it's always defined. (ps-mule-prepare-font-for-components, ps-mule-encode-header-string) (ps-mule-encode-bit, ps-mule-encode-ucs2): Use dotimes. (ps-mule-begin-job): Use dolist.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 24 Jul 2007 21:03:23 +0000
parents 76546b143f2d
children 83b2a2d47d12
files lisp/ChangeLog lisp/ps-mule.el
diffstat 2 files changed, 68 insertions(+), 72 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Jul 24 20:49:18 2007 +0000
+++ b/lisp/ChangeLog	Tue Jul 24 21:03:23 2007 +0000
@@ -1,21 +1,28 @@
+2007-07-24  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* ps-mule.el (ps-multibyte-buffer): Docstring fixes.
+	(ps-mule-encode-ethiopic): Make it clear that it's always defined.
+	(ps-mule-prepare-font-for-components, ps-mule-encode-header-string)
+	(ps-mule-encode-bit, ps-mule-encode-ucs2): Use dotimes.
+	(ps-mule-begin-job): Use dolist.
+
 2007-07-24  Michael Albinus  <michael.albinus@gmx.de>
 
 	* subr.el (start-file-process-shell-command)
 	(process-file-shell-command): New defuns.
 
-	* progmodes/compile.el (compilation-start): Apply
-	`start-file-process-shell-command'.
+	* progmodes/compile.el (compilation-start):
+	Apply `start-file-process-shell-command'.
 
 2007-07-24  Alexandre Julliard  <julliard@winehq.org>
 
-	* vc-git.el (vc-git-checkout, vc-directory-exclusion-list): Fix
-	typos.
+	* vc-git.el (vc-git-checkout, vc-directory-exclusion-list): Fix typos.
 
 2007-07-24  Alan Mackenzie  <acm@muc.de>
 
-	* emacs-lisp/bytecomp.el (byte-compile-from-buffer): Initialise
-	byte-compile-unresolved-functions before rather than after a
-	compilation.
+	* emacs-lisp/bytecomp.el (byte-compile-from-buffer):
+	Initialise byte-compile-unresolved-functions before rather than
+	after a compilation.
 	(byte-compile-unresolved-functions): Amplify doc string.
 
 2007-07-24  Glenn Morris  <rgm@gnu.org>
@@ -59,8 +66,7 @@
 	* calendar/cal-bahai.el (list-bahai-diary-entries)
 	* calendar/cal-hebrew.el (list-hebrew-diary-entries)
 	* calendar/cal-islam.el (list-islamic-diary-entries)
-	* calendar/calendar.el (generate-calendar)
-	(generate-calendar-month)
+	* calendar/calendar.el (generate-calendar, generate-calendar-month)
 	* calendar/diary-lib.el (diary-list-entries)
 	(mark-calendar-date-pattern): Use `dotimes' rather than
 	`calendar-for-loop'.
--- a/lisp/ps-mule.el	Tue Jul 24 20:49:18 2007 +0000
+++ b/lisp/ps-mule.el	Tue Jul 24 21:03:23 2007 +0000
@@ -167,28 +167,28 @@
 
 ;;;###autoload
 (defcustom ps-multibyte-buffer nil
-  "*Specifies the multi-byte buffer handling.
+  "Specifies the multi-byte buffer handling.
 
 Valid values are:
 
-  nil                     This is the value to use the default settings which
-			  is by default for printing buffer with only ASCII
-			  and Latin characters.   The default setting can be
-			  changed by setting the variable
+  nil			  This is the value to use the default settings;
+			  by default, this only works to print buffers with
+			  only ASCII and Latin characters.   But this default
+			  setting can be changed by setting the variable
 			  `ps-mule-font-info-database-default' differently.
 			  The initial value of this variable is
 			  `ps-mule-font-info-database-latin' (see
 			  documentation).
 
-  `non-latin-printer'     This is the value to use when you have a Japanese
+  `non-latin-printer'	  This is the value to use when you have a Japanese
 			  or Korean PostScript printer and want to print
 			  buffer with ASCII, Latin-1, Japanese (JISX0208 and
 			  JISX0201-Kana) and Korean characters.  At present,
-			  it was not tested the Korean characters printing.
+			  it was not tested with the Korean characters printing.
 			  If you have a korean PostScript printer, please,
 			  test it.
 
-  `bdf-font'              This is the value to use when you want to print
+  `bdf-font'		  This is the value to use when you want to print
 			  buffer with BDF fonts.  BDF fonts include both latin
 			  and non-latin fonts.  BDF (Bitmap Distribution
 			  Format) is a format used for distributing X's font
@@ -200,7 +200,7 @@
 			  `bdf-directory-list' appropriately (see ps-bdf.el for
 			  documentation of this variable).
 
-  `bdf-font-except-latin' This is like `bdf-font' except that it is used
+  `bdf-font-except-latin' This is like `bdf-font' except that it uses
 			  PostScript default fonts to print ASCII and Latin-1
 			  characters.  This is convenient when you want or
 			  need to use both latin and non-latin characters on
@@ -261,7 +261,7 @@
 
 (defcustom ps-mule-font-info-database-default
   ps-mule-font-info-database-latin
-  "*The default setting to use when `ps-multibyte-buffer' is nil."
+  "The default setting to use when `ps-multibyte-buffer' is nil."
   :type '(symbol :tag "Multi-Byte Buffer Database Font Default")
   :group 'ps-print-font)
 
@@ -417,22 +417,26 @@
 
 (defun ps-mule-encode-bit (string delta)
   (let* ((dim (charset-dimension (char-charset (string-to-char string))))
-	 (len (* (length string) dim))
-	 (str (make-string len 0))
-	 (i 0)
+	 (len (length string))
+	 (str (make-string (* len dim) 0))
 	 (j 0))
     (if (= dim 1)
-	(while (< j len)
-	  (aset str j
-		(+ (nth 1 (split-char (aref string i))) delta))
-	  (setq i (1+ i)
-		j (1+ j)))
-      (while (< j len)
+        ;; (apply 'string
+        ;;        (mapcar (lambda (c) (+ (nth 1 (split-char c)) delta))
+        ;;                string))
+	(dotimes (i len)
+	  (aset str i
+		(+ (nth 1 (split-char (aref string i))) delta)))
+      ;; (mapconcat (lambda (c)
+      ;;              (let ((split (split-char c)))
+      ;;                (string (+ (nth 1 split) delta)
+      ;;                        (+ (nth 2 split) delta))))
+      ;;            string "")
+      (dotimes (i len)
 	(let ((split (split-char (aref string i))))
 	  (aset str j (+ (nth 1 split) delta))
 	  (aset str (1+ j) (+ (nth 2 split) delta))
-	  (setq i (1+ i)
-		j (+ j 2)))))
+	  (setq j (+ j 2)))))
     str))
 
 ;; Special encoding function for Ethiopic.
@@ -455,31 +459,29 @@
   ;; to avoid compilation gripes
   (defvar ccl-encode-ethio-unicode nil))
 
-(if (boundp 'mule-version)
-    ;; bound mule-version
-    (defun ps-mule-encode-ethiopic (string)
-      (ccl-execute-on-string (symbol-value 'ccl-encode-ethio-unicode)
-			     (make-vector 9 nil)
-			     string))
-  ;; unbound mule-version
-  (defun ps-mule-encode-ethiopic (string)
-    string))
+(defalias 'ps-mule-encode-ethiopic
+  (if (boundp 'mule-version)
+      ;; Bound mule-version.
+      (lambda (string)
+        (ccl-execute-on-string (symbol-value 'ccl-encode-ethio-unicode)
+                               (make-vector 9 nil)
+                               string))
+    ;; Unbound mule-version.
+    #'identity))
 
 ;; Special encoding for mule-unicode-* characters.
 (defun ps-mule-encode-ucs2 (string)
   (let* ((len (length string))
 	 (str (make-string (* 2 len) 0))
-	 (i 0)
 	 (j 0)
 	 ch hi lo)
-    (while (< i len)
+    (dotimes (i len)
       (setq ch (encode-char (aref string i) 'ucs)
 	    hi (lsh ch -8)
 	    lo (logand ch 255))
       (aset str j hi)
       (aset str (1+ j) lo)
-      (setq i (1+ i)
-	    j (+ j 2)))
+      (setq j (+ j 2)))
     str))
 
 ;; A charset which we are now processing.
@@ -906,11 +908,8 @@
 ;; The latter form is used if we much change font for the character.
 
 (defun ps-mule-prepare-font-for-components (components font-type)
-  (let ((len (length components))
-	(i 0)
-	elt)
-    (while (< i len)
-      (setq elt (aref components i))
+  (dotimes (i (length components))
+    (let ((elt (aref components i)))
       (if (consp elt)
 	  ;; ELT is a composition rule.
 	  (setq elt (encode-composition-rule elt))
@@ -930,8 +929,7 @@
 	  (if (stringp font)
 	      (setq elt (cons font str) ps-last-font font)
 	    (setq elt str))))
-      (aset components i elt)
-      (setq i (1+ i))))
+      (aset components i elt)))
   components)
 
 (defun ps-mule-plot-components (components tail)
@@ -1363,12 +1361,10 @@
     (if (eq (car ps-mule-header-charsets) 'latin-iso8859-1)
 	;; Latin1 characters can be printed by the standard PostScript
 	;; font.  Converts the other non-ASCII characters to `?'.
-	(let ((len (length string))
-	      (i 0))
-	  (while (< i len)
+	(let ((len (length string)))
+	  (dotimes (i len)
 	    (or (memq (char-charset (aref string i)) '(ascii latin-iso8859-1))
-		(aset string i ??))
-	    (setq i (1+ i)))
+		(aset string i ??)))
 	  (setq string (encode-coding-string string 'iso-latin-1)))
       ;; We must prepare a font for the first non-ASCII and non-Latin1
       ;; character in STRING.
@@ -1383,21 +1379,17 @@
 	    ;; We don't have a proper font, or we can't print them on
 	    ;; header because this kind of charset is not ASCII
 	    ;; compatible.
-	    (let ((len (length string))
-		  (i 0))
-	      (while (< i len)
+	    (let ((len (length string)))
+	      (dotimes (i len)
 		(or (memq (char-charset (aref string i))
 			  '(ascii latin-iso8859-1))
-		    (aset string i ??))
-		(setq i (1+ i)))
+		    (aset string i ??)))
 	      (setq string (encode-coding-string string 'iso-latin-1)))
 	  (let ((charsets (list 'ascii (car ps-mule-header-charsets)))
-		(len (length string))
-		(i 0))
-	    (while (< i len)
+		(len (length string)))
+	    (dotimes (i len)
 	      (or (memq (char-charset (aref string i)) charsets)
-		  (aset string i ??))
-	      (setq i (1+ i))))
+		  (aset string i ??))))
 	  (setq string (ps-mule-string-encoding font-spec string nil t))))))
   string)
 
@@ -1446,7 +1438,7 @@
 or \\[universal-argument] \\[what-cursor-position] will give information about them.\n"))))
 
 	(with-category-table table
-	  (let (string-list idx)
+	  (let (string-list)
 	    (dolist (elt header-footer-list)
 	      (when (stringp elt)
 		(when (string-match "\\cu+" elt)
@@ -1541,14 +1533,12 @@
 	(progn
 	  (ps-mule-prologue-generated)
 	  (ps-mule-init-external-library font-spec)
-	  (let ((font (ps-font-alist 'ps-font-for-text))
-		(ps-current-font 0))
-	    (while font
+	  (let ((ps-current-font 0))
+	    (dolist (font (ps-font-alist 'ps-font-for-text))
 	      ;; Be sure to download a glyph for SPACE in advance.
-	      (ps-mule-prepare-font (ps-mule-get-font-spec 'ascii (car font))
+	      (ps-mule-prepare-font (ps-mule-get-font-spec 'ascii font)
 				    " " 'ascii 'no-setfont)
-	      (setq font (cdr font)
-		    ps-current-font (1+ ps-current-font)))))))
+	      (setq ps-current-font (1+ ps-current-font)))))))
 
   ;; If the header contains non-ASCII and non-Latin1 characters, prepare a font
   ;; and glyphs for the first occurrence of such characters.