2006-09-11 Daiki Ueno <ueno@unixuser.org>
+ * epa-file.el (epa-file-decode-and-insert): New function which
+ utilizes decode-coding-inserted-region if available.
+ (epa-file-insert-file-contents): Use it.
+
* epg.el (epg--start): Specify --enable-progress-filter in
imitation of GPGME.
(epg-progress-callback-function): Remove a couple of %%'s.
(inhibit-file-name-operation operation))
(apply operation args)))
+(defun epa-file-decode-and-insert (string file visit beg end replace)
+ (if (fboundp 'decode-coding-inserted-region)
+ (save-restriction
+ (narrow-to-region (point) (point))
+ (let ((multibyte enable-multibyte-characters))
+ (set-buffer-multibyte nil)
+ (insert string)
+ (set-buffer-multibyte multibyte)
+ (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)))))
+
(defvar last-coding-system-used)
(defun epa-file-insert-file-contents (file &optional visit beg end replace)
(barf-if-buffer-read-only)
(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)
- (setq length (length string))
+ (save-restriction
+ (narrow-to-region (point) (point))
+ (epa-file-decode-and-insert string file visit beg end replace)
+ (setq length (- (point-max) (point-min))))
(if replace
(delete-region (point) (point-max)))))
(if (and local-copy