* epa-file.el (epa-file-insert-file-contents): Use
authorueno <ueno>
Sun, 10 Sep 2006 02:41:36 +0000 (02:41 +0000)
committerueno <ueno>
Sun, 10 Sep 2006 02:41:36 +0000 (02:41 +0000)
decode-coding-inserted-region if available.

ChangeLog
epa-file.el

index 2118027..93107b0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-10  Daiki Ueno  <ueno@unixuser.org>
+
+       * epa-file.el (epa-file-insert-file-contents): Use
+       decode-coding-inserted-region if available.
+
 2006-09-05  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
 
        * epg-config.el (epg-configuration): Fixed the last change;
index 4a59d8d..d02e789 100644 (file)
                     (cons "Opening input file" (cdr error)))))
          (if (or beg end)
              (setq string (substring string (or beg 0) end)))
-         (setq string
-               (decode-coding-string string
-                                     (or coding-system-for-read 'undecided)))
          (if (boundp 'last-coding-system-used)
              (set-buffer-file-coding-system last-coding-system-used)
            (set-buffer-file-coding-system default-buffer-file-coding-system))
          (save-excursion
-           (insert string)
+           (if (and (null coding-system-for-read)
+                    (fboundp 'decode-coding-inserted-region))
+               (save-restriction
+                 (narrow-to-region (point) (point))
+                 (insert string)
+                 (decode-coding-inserted-region
+                  (point-min) (point-max)
+                  (substring file 0 (string-match epa-file-name-regexp file))
+                  visit beg end replace))
+             (insert (decode-coding-string string (or coding-system-for-read
+                                                      'undecided))))
            (setq length (length string))
            (if replace
                (delete-region (point) (point-max)))))