From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#20972: 25.0.50; eieio-persistent broken Date: Sat, 04 Jul 2015 15:16:36 -0400 Message-ID: References: <874mlltqyp.fsf@xing.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1436037444 21605 80.91.229.3 (4 Jul 2015 19:17:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 4 Jul 2015 19:17:24 +0000 (UTC) Cc: 20972@debbugs.gnu.org To: Jan Tatarik Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 04 21:17:13 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZBSw4-0001AY-QE for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Jul 2015 21:17:13 +0200 Original-Received: from localhost ([::1]:45062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZBSw3-0008V5-Gu for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Jul 2015 15:17:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZBSvy-0008U7-Nb for bug-gnu-emacs@gnu.org; Sat, 04 Jul 2015 15:17:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZBSvu-0001cL-M9 for bug-gnu-emacs@gnu.org; Sat, 04 Jul 2015 15:17:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38513) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZBSvu-0001cB-Hz for bug-gnu-emacs@gnu.org; Sat, 04 Jul 2015 15:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZBSvu-00055D-1X for bug-gnu-emacs@gnu.org; Sat, 04 Jul 2015 15:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Jul 2015 19:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20972 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20972-submit@debbugs.gnu.org id=B20972.143603740419507 (code B ref 20972); Sat, 04 Jul 2015 19:17:01 +0000 Original-Received: (at 20972) by debbugs.gnu.org; 4 Jul 2015 19:16:44 +0000 Original-Received: from localhost ([127.0.0.1]:39959 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZBSva-00054W-A2 for submit@debbugs.gnu.org; Sat, 04 Jul 2015 15:16:44 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:47195) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZBSvY-00054M-Vv for 20972@debbugs.gnu.org; Sat, 04 Jul 2015 15:16:41 -0400 Original-Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id t64JGbM3007155; Sat, 4 Jul 2015 15:16:38 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id B9D3F660ED; Sat, 4 Jul 2015 15:16:36 -0400 (EDT) In-Reply-To: <874mlltqyp.fsf@xing.com> (Jan Tatarik's message of "Fri, 03 Jul 2015 13:34:22 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5357=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5357> : inlines <3321> : streams <1466264> : uri <1976603> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:104711 Archived-At: > ;; In theory, calling it like this should override the :file slot > ;; defined in eieio-persistent > (eieio-persistent-save (test-persist :slot "foo") "/tmp/test.eieio") Indeed, the code seems completely broken in this respect (it mostly ignores the `file' argument, tho not completely). I'm not 100% sure what the code *should* do, but can you try the patch below for you use case and confirm that it does the right thing for you? Stefan diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index 2e28036..400bdb9 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.