diff options
| author | Daiki Ueno <ueno@gnu.org> | 2014-01-14 17:41:09 +0900 |
|---|---|---|
| committer | Daiki Ueno <ueno@gnu.org> | 2014-01-14 17:41:09 +0900 |
| commit | 02bf443d2ea21189dc0e8ac0bb741db9fa8fc365 (patch) | |
| tree | 90b2cb1d803dd5a2a8f66e675c210b66c383c586 | |
| parent | 689c9ca51eb4b6496836241b9fb062bf10521568 (diff) | |
| download | emacs-02bf443d2ea21189dc0e8ac0bb741db9fa8fc365.tar.gz | |
* epa-file.el: Respect buffer-file-format when writing
* epa-file.el (epa-file-write-region): Encode the region according
to `buffer-file-format'. Problem reported at:
<http://sourceforge.jp/ticket/browse.php?group_id=2267&tid=32917>.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/epa-file.el | 17 |
2 files changed, 20 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e45b0ba0574..243078ebad4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2014-01-14 Daiki Ueno <ueno@gnu.org> + + * epa-file.el (epa-file-write-region): Encode the region according + to `buffer-file-format'. Problem reported at: + <http://sourceforge.jp/ticket/browse.php?group_id=2267&tid=32917>. + 2014-01-14 Stefan Monnier <monnier@iro.umontreal.ca> * emacs-lisp/edebug.el (edebug--display): Move protective let-binding diff --git a/lisp/epa-file.el b/lisp/epa-file.el index eea458d200d..20d34f82223 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -211,7 +211,8 @@ encryption is used." (recipients (cond ((listp epa-file-encrypt-to) epa-file-encrypt-to) - ((stringp epa-file-encrypt-to) (list epa-file-encrypt-to))))) + ((stringp epa-file-encrypt-to) (list epa-file-encrypt-to)))) + buffer) (epg-context-set-passphrase-callback context (cons #'epa-file-passphrase-callback-function @@ -230,8 +231,18 @@ encryption is used." (unless start (setq start (point-min) end (point-max))) - (epa-file--encode-coding-string (buffer-substring start end) - coding-system)) + (setq buffer (current-buffer)) + (with-temp-buffer + (insert-buffer-substring buffer start end) + ;; Translate the region according to + ;; `buffer-file-format', as `write-region' would. + ;; We can't simply do `write-region' (into a + ;; temporary file) here, since it writes out + ;; decrypted contents. + (format-encode-buffer (with-current-buffer buffer + buffer-file-format)) + (epa-file--encode-coding-string (buffer-string) + coding-system))) (if (or (eq epa-file-select-keys t) (and (null epa-file-select-keys) (not (local-variable-p 'epa-file-encrypt-to |
