From: ueno Date: Mon, 11 Sep 2006 04:08:07 +0000 (+0000) Subject: * epa-file.el (epa-file-decode-and-insert): New function which X-Git-Tag: epg-0_0_6~25 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb8fcf4366538e21ba0cbddf6b8f9afdc917e6d0;p=elisp%2Fepg.git * 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. --- diff --git a/ChangeLog b/ChangeLog index 48e1111..7edd188 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-09-11 Daiki Ueno + * 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. diff --git a/epa-file.el b/epa-file.el index 4a59d8d..2b47373 100644 --- a/epa-file.el +++ b/epa-file.el @@ -70,6 +70,21 @@ (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) @@ -98,15 +113,11 @@ (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