diff options
| author | Daiki Ueno | 2014-01-14 17:41:09 +0900 |
|---|---|---|
| committer | Daiki Ueno | 2014-01-14 17:41:09 +0900 |
| commit | 02bf443d2ea21189dc0e8ac0bb741db9fa8fc365 (patch) | |
| tree | 90b2cb1d803dd5a2a8f66e675c210b66c383c586 /lisp/epa-file.el | |
| parent | 689c9ca51eb4b6496836241b9fb062bf10521568 (diff) | |
| download | emacs-02bf443d2ea21189dc0e8ac0bb741db9fa8fc365.tar.gz emacs-02bf443d2ea21189dc0e8ac0bb741db9fa8fc365.zip | |
* 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>.
Diffstat (limited to 'lisp/epa-file.el')
| -rw-r--r-- | lisp/epa-file.el | 17 |
1 files changed, 14 insertions, 3 deletions
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." | |||
| 211 | (recipients | 211 | (recipients |
| 212 | (cond | 212 | (cond |
| 213 | ((listp epa-file-encrypt-to) epa-file-encrypt-to) | 213 | ((listp epa-file-encrypt-to) epa-file-encrypt-to) |
| 214 | ((stringp epa-file-encrypt-to) (list epa-file-encrypt-to))))) | 214 | ((stringp epa-file-encrypt-to) (list epa-file-encrypt-to)))) |
| 215 | buffer) | ||
| 215 | (epg-context-set-passphrase-callback | 216 | (epg-context-set-passphrase-callback |
| 216 | context | 217 | context |
| 217 | (cons #'epa-file-passphrase-callback-function | 218 | (cons #'epa-file-passphrase-callback-function |
| @@ -230,8 +231,18 @@ encryption is used." | |||
| 230 | (unless start | 231 | (unless start |
| 231 | (setq start (point-min) | 232 | (setq start (point-min) |
| 232 | end (point-max))) | 233 | end (point-max))) |
| 233 | (epa-file--encode-coding-string (buffer-substring start end) | 234 | (setq buffer (current-buffer)) |
| 234 | coding-system)) | 235 | (with-temp-buffer |
| 236 | (insert-buffer-substring buffer start end) | ||
| 237 | ;; Translate the region according to | ||
| 238 | ;; `buffer-file-format', as `write-region' would. | ||
| 239 | ;; We can't simply do `write-region' (into a | ||
| 240 | ;; temporary file) here, since it writes out | ||
| 241 | ;; decrypted contents. | ||
| 242 | (format-encode-buffer (with-current-buffer buffer | ||
| 243 | buffer-file-format)) | ||
| 244 | (epa-file--encode-coding-string (buffer-string) | ||
| 245 | coding-system))) | ||
| 235 | (if (or (eq epa-file-select-keys t) | 246 | (if (or (eq epa-file-select-keys t) |
| 236 | (and (null epa-file-select-keys) | 247 | (and (null epa-file-select-keys) |
| 237 | (not (local-variable-p 'epa-file-encrypt-to | 248 | (not (local-variable-p 'epa-file-encrypt-to |