summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2015-07-06 11:55:37 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2015-07-06 11:55:37 -0400
commit2a8dca13a7f5efd36390e5a93e55d3809f325c21 (patch)
tree0cb5402c1baaad967b397e84d0cacdf784f2ae59 /lisp/emacs-lisp
parentc96dd0223c82855485f4666e30161bc151716c7f (diff)
downloademacs-2a8dca13a7f5efd36390e5a93e55d3809f325c21.tar.gz
emacs-2a8dca13a7f5efd36390e5a93e55d3809f325c21.tar.bz2
emacs-2a8dca13a7f5efd36390e5a93e55d3809f325c21.zip
(eieio-persistent-save): Don't ignore `file' arg (bug#20972)
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-save): Don't ignore `file' arg. Always use utf-8-emacs. Use with-temp-buffer and cl-letf.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/eieio-base.el53
1 files changed, 22 insertions, 31 deletions
diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el
index 2e280365a7a..400bdb95c06 100644
--- a/lisp/emacs-lisp/eieio-base.el
+++ b/lisp/emacs-lisp/eieio-base.el
@@ -429,37 +429,28 @@ Optional argument COMMENT is a header line comment."
"Save persistent object THIS to disk.
Optional argument FILE overrides the file name specified in the object
instance."
- (save-excursion
- (let ((b (set-buffer (get-buffer-create " *tmp object write*")))
- (default-directory (file-name-directory (oref this file)))
- (cfn (oref this file)))
- (unwind-protect
- (save-excursion
- (erase-buffer)
- (let ((standard-output (current-buffer)))
- (oset this file
- (if file
- (eieio-persistent-path-relative this file)
- (file-name-nondirectory cfn)))
- (object-write this (oref this file-header-line)))
- (let ((backup-inhibited (not (oref this do-backups)))
- (cs (car (find-coding-systems-region
- (point-min) (point-max)))))
- (unless (eq cs 'undecided)
- (setq buffer-file-coding-system cs))
- ;; Old way - write file. Leaves message behind.
- ;;(write-file cfn nil)
-
- ;; New way - Avoid the vast quantities of error checking
- ;; just so I can get at the special flags that disable
- ;; displaying random messages.
- (write-region (point-min) (point-max)
- cfn nil 1)
- ))
- ;; Restore :file, and kill the tmp buffer
- (oset this file cfn)
- (setq buffer-file-name nil)
- (kill-buffer b)))))
+ (when file (setq file (expand-file-name file)))
+ (with-temp-buffer
+ (let* ((cfn (or file (oref this file)))
+ (default-directory (file-name-directory cfn)))
+ (cl-letf ((standard-output (current-buffer))
+ ((oref this file) ;FIXME: Why change it?
+ (if file
+ ;; FIXME: Makes a name relative to (oref this file),
+ ;; whereas I think it should be relative to cfn.
+ (eieio-persistent-path-relative this file)
+ (file-name-nondirectory cfn))))
+ (object-write this (oref this file-header-line)))
+ (let ((backup-inhibited (not (oref this do-backups)))
+ (coding-system-for-write 'utf-8-emacs))
+ ;; Old way - write file. Leaves message behind.
+ ;;(write-file cfn nil)
+
+ ;; New way - Avoid the vast quantities of error checking
+ ;; just so I can get at the special flags that disable
+ ;; displaying random messages.
+ (write-region (point-min) (point-max) cfn nil 1)
+ ))))
;; Notes on the persistent object:
;; It should also set up some hooks to help it keep itself up to date.