From: hmurata Date: Sat, 30 Jul 2005 08:36:14 +0000 (+0000) Subject: (elmo-safe-filename): Rewrite to replace X-Git-Tag: wl-2_15_3~63 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58dbc68628fd3a4e3f044d5717a00fac62f05c4d;p=elisp%2Fwanderlust.git (elmo-safe-filename): Rewrite to replace `"' (double quote) into "_Q_". --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 9c1d4d9..a6f9a81 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,8 @@ +2005-07-30 Hiroya Murata + + * elmo-util.el (elmo-safe-filename): Rewrite to replace + `"' (double quote) into "_Q_". + 2005-07-18 Hiroya Murata * elmo-net.el (elmo-net-quote-chars): Abolish. diff --git a/elmo/elmo-util.el b/elmo/elmo-util.el index 8953d0f..877fe51 100644 --- a/elmo/elmo-util.el +++ b/elmo/elmo-util.el @@ -1041,12 +1041,25 @@ Emacs 19.28 or earlier does not have `unintern'." (setq dest (cons (cons name body) dest)))) dest))) -(defun elmo-safe-filename (folder) - (elmo-replace-in-string - (elmo-replace-in-string - (elmo-replace-in-string folder "/" " ") - ":" "__") - "|" "_or_")) +(defun elmo-safe-filename (filename) + (let* ((replace-alist '(("/" . " ") + (":" . "__") + ("|" . "_or_") + ("\"" . "_Q_"))) + (regexp (concat "[" + (regexp-quote (mapconcat 'car replace-alist "")) + "]")) + (rest filename) + converted) + (while (string-match regexp rest) + (setq converted (concat converted + (substring rest 0 (match-beginning 0)) + (cdr (assoc (substring rest + (match-beginning 0) + (match-end 0)) + replace-alist))) + rest (substring rest (match-end 0)))) + (concat converted rest))) (defvar elmo-filename-replace-chars nil)