From 467d4faa2d8022074d8fb550f26123d2eed216c1 Mon Sep 17 00:00:00 2001 From: ueno Date: Thu, 1 Jun 2006 06:17:21 +0000 Subject: [PATCH] * epa-file.el (epa-file-insert-file-contents): Support partial read. --- ChangeLog | 4 ++++ epa-file.el | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1b360b6..c91f0ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-06-01 Daiki Ueno + + * epa-file.el (epa-file-insert-file-contents): Support partial read. + 2006-05-30 Hiroya Murata * epa-file.el (epa-file-write-region): Encode the plain text with diff --git a/epa-file.el b/epa-file.el index 2c123c3..3ebf50b 100644 --- a/epa-file.el +++ b/epa-file.el @@ -73,8 +73,8 @@ (defvar last-coding-system-used) (defun epa-file-insert-file-contents (file &optional visit beg end replace) (barf-if-buffer-read-only) - (if (or beg end) - (error "Can't read the file partially.")) + (if (and visit (or beg end)) + (error "Attempt to visit less than an entire file")) (setq file (expand-file-name file)) (let ((local-copy (epa-file-run-real-handler #'file-local-copy (list file))) (context (epg-make-context)) @@ -90,14 +90,17 @@ (if replace (goto-char (point-min))) (condition-case error - (setq string (decode-coding-string - (epg-decrypt-file context file nil) - (or coding-system-for-read 'undecided))) + (setq string (epg-decrypt-file context file nil)) (error (if (setq entry (assoc file epa-file-passphrase-alist)) (setcdr entry nil)) (signal 'file-error (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)) -- 1.7.10.4