[mew-dist 23628] format strings

Tatsuya Kinoshita tats at example.com
2003年 5月 12日 (月) 09:23:35 JST


message()やerror()で、最初の引数がformat stringであることをもっと
意識するようにしてみました。

直接メッセージ文字列を置かずに変数や関数で文字列を表しているとこ
ろでは、最初の引数として"%s"を置きました。("%"が含まれていても処
理できるように)

また、「(message (format ...))」というふうにformat stringとしての
評価が二重になっている個所も修正しています。

-- tats

 This patch is written by Tatsuya Kinoshita.  Copyright is disclaimed.

Index: mew-addrbook.el
===================================================================
RCS file: /cvsmew/mew/mew-addrbook.el,v
retrieving revision 1.26
diff -u -r1.26 mew-addrbook.el
--- mew-addrbook.el	2003/03/26 10:47:56	1.26
+++ mew-addrbook.el	2003/05/11 23:46:09
@@ -449,7 +449,7 @@
        ((and name (string-match "^\"[^\"]*[^\000-\177]" name))
 	(setq errmsg "Remove quote around non-ASCII Name")))))
     (if errmsg
-	(message errmsg)
+	(message "%s" errmsg)
       (save-excursion
 	(setq buf (find-file-noselect
 		   (expand-file-name mew-addrbook-file mew-conf-path)))
Index: mew-attach.el
===================================================================
RCS file: /cvsmew/mew/mew-attach.el,v
retrieving revision 1.31
diff -u -r1.31 mew-attach.el
--- mew-attach.el	2003/03/31 14:16:24	1.31
+++ mew-attach.el	2003/05/11 23:46:10
@@ -338,7 +338,7 @@
 	     (mew-encode-syntax-single tofile (list ct) nil nil nil 'cdp)))
       (mew-encode-syntax-print mew-encode-syntax)
       (if mew-attach-move-next-after-copy (mew-attach-next))
-      (if msg (message msg)))))
+      (if msg (message "%s" msg)))))
 
 (defun mew-attach-link (&optional from to)
   "Link a file with a symbolic link on '.' in attachments.
@@ -441,6 +441,7 @@
 		(if (not (y-or-n-p "Are you ready? "))
 		    (message "Nothing is recoded")
 		  (message
+		   "%s"
 		   (substitute-command-keys
 		    "Type '\\[keyboard-quit]' to finish recording..."))
 		  (mew-plet
@@ -450,6 +451,7 @@
 			  (nth 1 mew-prog-audio2)))))
 	    (quit
 	     (message
+	      "%s"
 	      (substitute-command-keys
 	       "Type '\\[keyboard-quit]' to finish recording...done"))
 	     (setq recorded t)
Index: mew-cache.el
===================================================================
RCS file: /cvsmew/mew/mew-cache.el,v
retrieving revision 1.19
diff -u -r1.19 mew-cache.el
--- mew-cache.el	2003/03/29 00:34:37	1.19
+++ mew-cache.el	2003/05/11 23:46:10
@@ -185,7 +185,7 @@
       (mew-decode-syntax-set))
     ;;
     (set-buffer cbuf)
-    (if errormsg (if no-err (message errormsg) (error errormsg)))
+    (if errormsg (if no-err (message "%s" errormsg) (error "%s" errormsg)))
     cache)) ;; retrun value
 
 (defun mew-cache-clean-up ()
Index: mew-complete.el
===================================================================
RCS file: /cvsmew/mew/mew-complete.el,v
retrieving revision 1.59
diff -u -r1.59 mew-complete.el
--- mew-complete.el	2003/01/16 11:03:29	1.59
+++ mew-complete.el	2003/05/11 23:46:11
@@ -533,6 +533,7 @@
       (mew-complete-window-show all)
       (if (and (mew-characterp EXPAND-CHAR) (funcall fhit cmp ALIST))
 	  (message
+	   "%s"
 	   (substitute-command-keys
 	    "To expand '%s', type '%c' then '\\<mew-draft-header-map>\\[mew-draft-header-comp]'.")
 	   cmp EXPAND-CHAR)))
Index: mew-edit.el
===================================================================
RCS file: /cvsmew/mew/mew-edit.el,v
retrieving revision 1.91
diff -u -r1.91 mew-edit.el
--- mew-edit.el	2003/04/10 07:15:51	1.91
+++ mew-edit.el	2003/05/11 23:46:12
@@ -443,7 +443,7 @@
 	    (message "Nothing was processed")
 	  (mew-touch-folder folder)
 	  (setq ret (list mstr (int-to-string (1- m)))))))
-      (if errmsg (error errmsg))
+      (if errmsg (error "%s" errmsg))
       ret)))
 
 (defun mew-summary-burst-part (part folder newmsg &optional num)
Index: mew-encode.el
===================================================================
RCS file: /cvsmew/mew/mew-encode.el,v
retrieving revision 1.68
diff -u -r1.68 mew-encode.el
--- mew-encode.el	2003/04/04 09:06:37	1.68
+++ mew-encode.el	2003/05/11 23:46:14
@@ -354,7 +354,7 @@
 	  (mew-smtp-encode-message pnm case resentp fcc privacy signer headerp)
 	(error
 	 (mew-encode-undo)
-	 (message (mew-tinfo-get-encode-err))
+	 (message "%s" (mew-tinfo-get-encode-err))
 	 (setq ret nil))))
     ret))
 
@@ -425,7 +425,7 @@
 	  (mew-nntp2-encode-message pnm case fcc privacy signer headerp)
 	(error
 	 (mew-encode-undo)
-	 (message (mew-tinfo-get-encode-err))
+	 (message "%s" (mew-tinfo-get-encode-err))
 	 (setq ret nil))))
     ret))
 
Index: mew-local.el
===================================================================
RCS file: /cvsmew/mew/mew-local.el,v
retrieving revision 1.74
diff -u -r1.74 mew-local.el
--- mew-local.el	2003/04/08 13:07:31	1.74
+++ mew-local.el	2003/05/11 23:46:14
@@ -386,7 +386,7 @@
      (if (and (mew-folder-imapp bnm)
 	      (not (mew-folder-imap-queuep)))
 	 (if (mew-local-get-rttl pnm)
-	     (message (substitute-command-keys "\\<mew-summary-mode-map>Type '\\[mew-summary-ls]' to override invalid messages"))
+	     (message "%s" (substitute-command-keys "\\<mew-summary-mode-map>Type '\\[mew-summary-ls]' to override invalid messages"))
 	   ;; This folder has been just created.
 	   ;; Ideally scan should not be called. But there is no way
 	   ;; to avoid the call.
Index: mew-mule.el
===================================================================
RCS file: /cvsmew/mew/mew-mule.el,v
retrieving revision 1.16
diff -u -r1.16 mew-mule.el
--- mew-mule.el	2003/01/21 03:57:27	1.16
+++ mew-mule.el	2003/05/11 23:46:15
@@ -36,7 +36,7 @@
     (if (null ecsdb)
 	(setq ret (mew-charset-m17n))
       (setq ret (mew-cs-to-charset (mew-ecsdb-cs ecsdb)))) ;; not hcs
-    (if (interactive-p) (message ret)) ;; for debug
+    (if (interactive-p) (message "%s" ret)) ;; for debug
     ret))
 
 (defun mew-ecsdb-guess-region (beg end)
Index: mew-nntp2.el
===================================================================
RCS file: /cvsmew/mew/mew-nntp2.el,v
retrieving revision 1.49
diff -u -r1.49 mew-nntp2.el
--- mew-nntp2.el	2003/02/18 15:39:25	1.49
+++ mew-nntp2.el	2003/05/11 23:46:15
@@ -175,11 +175,11 @@
        (setq errmsg "Cannot connect to the NNTP server")
        (mew-nntp2-set-error pnm errmsg)
        (setq pro nil)
-       (message errmsg))
+       (message "%s" errmsg))
       (error
        (setq errmsg (format "%s, %s" (nth 1 emsg) (nth 2 emsg)))
        (setq pro nil)
-       (message errmsg)))
+       (message "%s" errmsg)))
     (if tm (cancel-timer tm))
     pro))
 
Index: mew-smtp.el
===================================================================
RCS file: /cvsmew/mew/mew-smtp.el,v
retrieving revision 1.71
diff -u -r1.71 mew-smtp.el
--- mew-smtp.el	2003/04/07 04:22:21	1.71
+++ mew-smtp.el	2003/05/11 23:46:16
@@ -316,12 +316,12 @@
        (setq errmsg "Cannot connect to the SMTP server")
        (mew-smtp-set-error pnm errmsg)
        (setq pro nil)
-       (message errmsg))
+       (message "%s" errmsg))
       (error
        (setq errmsg (format "%s, %s" (nth 1 emsg) (nth 2 emsg)))
        (mew-smtp-set-error pnm errmsg)
        (setq pro nil)
-       (message errmsg)))
+       (message "%s" errmsg)))
     (if tm (cancel-timer tm))
     pro))
 
Index: mew-summary.el
===================================================================
RCS file: /cvsmew/mew/mew-summary.el,v
retrieving revision 1.159
diff -u -r1.159 mew-summary.el
--- mew-summary.el	2003/04/09 04:05:11	1.159
+++ mew-summary.el	2003/05/11 23:46:17
@@ -294,7 +294,8 @@
     nil) ;; not exclusive
    ((processp mew-summary-buffer-process)
     (or no-msg
-	(message (substitute-command-keys
+	(message "%s"
+		 (substitute-command-keys
 		  "\\<mew-summary-mode-map>Another process is running. Try later or type \\[mew-summary-kill-subprocess] to kill it")))
     nil) ;; not exclusive
    (t t))) ;; exclusive
Index: mew-summary2.el
===================================================================
RCS file: /cvsmew/mew/mew-summary2.el,v
retrieving revision 1.20
diff -u -r1.20 mew-summary2.el
--- mew-summary2.el	2003/04/23 09:16:13	1.20
+++ mew-summary2.el	2003/05/11 23:46:18
@@ -220,6 +220,7 @@
 		   (mew-summary-display-raw fld msg mew-file-max-size)
 		   (setq prefetch t)
 		   (message
+		    "%s"
 		    (substitute-command-keys
 		     "Too large, truncated. To see the entire message, type '\\<mew-summary-mode-map>\\[mew-summary-analyze-again]'"))))
 		(t
@@ -251,7 +252,7 @@
 	 (if (mew-xinfo-get-decode-err)
 	     (message "MIME decoding error: %s" (mew-xinfo-get-decode-err)))
 	 (if (mew-xinfo-get-action)
-	     (message (mew-xinfo-get-action)))
+	     (message "%s" (mew-xinfo-get-action)))
 	 (mew-message-mode-line fld msg)
 	 (select-window win)
 	 ;; summary buffer
Index: mew-summary4.el
===================================================================
RCS file: /cvsmew/mew/mew-summary4.el,v
retrieving revision 1.90
diff -u -r1.90 mew-summary4.el
--- mew-summary4.el	2003/04/11 04:44:44	1.90
+++ mew-summary4.el	2003/05/11 23:46:19
@@ -357,9 +357,9 @@
 	  (command (read-string "Command: ")))
      (while (not (mew-which-exec command))
        (setq command (read-string "Command: ")))
-     (message (format "Executing %s for %s..." command msg))
+     (message "Executing %s for %s..." command msg)
      (call-process command nil nil nil file)
-     (message (format "Executing %s for %s...done" command msg)))))
+     (message "Executing %s for %s...done" command msg))))
 
 (defun mew-summary-cmd-msgs ()
   "Executing an external command specifying messages
@@ -369,9 +369,9 @@
    (let ((command (read-string "Command: ")))
      (while (not (mew-which-exec command))
        (setq command (read-string "Command: ")))
-     (message (format "Executing %s ..." command))
+     (message "Executing %s ..." command)
      (apply 'call-process command nil nil nil FILES)
-     (message (format "Executing %s ...done" command)))))
+     (message "Executing %s ...done" command))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
@@ -467,7 +467,7 @@
 	      (if (or (mew-ct-imagep ct) (mew-ct-modelp ct))
 		  (funcall (nth 1 program) cache begin end params fname)
 		(funcall (nth 1 program) cache begin end params)))
-	  (message (substitute-command-keys "Use '\\<mew-summary-mode-map>\\[mew-summary-execute-command]' or \\[universal-argument] \\<mew-summary-mode-map>\\[mew-summary-execute-external]'"))))
+	  (message "%s" (substitute-command-keys "Use '\\<mew-summary-mode-map>\\[mew-summary-execute-command]' or \\[universal-argument] \\<mew-summary-mode-map>\\[mew-summary-execute-external]'"))))
        (t
 	(cond
 	 ((listp program)



Mew-dist メーリングリストの案内