From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel,gmane.emacs.pretest.bugs Subject: RE: 23.0.50; savehist save invalid syntax Date: Sun, 9 Sep 2007 20:01:37 -0700 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0007_01C7F31C.3ABA7300" X-Trace: sea.gmane.org 1189394770 24941 80.91.229.12 (10 Sep 2007 03:26:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 10 Sep 2007 03:26:10 +0000 (UTC) Cc: emacs-pretest-bug@gnu.org, rms@gnu.org, sdl.web@gmail.com To: "Andreas Schwab" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 10 13:25:57 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IUh1z-0001BE-Ts for ged-emacs-devel@m.gmane.org; Mon, 10 Sep 2007 13:02:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IUZXd-0007Bc-E8 for ged-emacs-devel@m.gmane.org; Sun, 09 Sep 2007 23:02:25 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IUZXa-00079R-6q for emacs-devel@gnu.org; Sun, 09 Sep 2007 23:02:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IUZXZ-00077w-9y for emacs-devel@gnu.org; Sun, 09 Sep 2007 23:02:21 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IUZXZ-00077W-2s for emacs-devel@gnu.org; Sun, 09 Sep 2007 23:02:21 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IUZXY-0006qn-En for emacs-devel@gnu.org; Sun, 09 Sep 2007 23:02:20 -0400 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IUZXB-0003Ax-RS for emacs-pretest-bug@gnu.org; Sun, 09 Sep 2007 23:01:58 -0400 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1IUZXU-0006pT-Dg for emacs-pretest-bug@gnu.org; Sun, 09 Sep 2007 23:02:19 -0400 Original-Received: from rgminet01.oracle.com ([148.87.113.118]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IUZXO-0006nf-Ez; Sun, 09 Sep 2007 23:02:11 -0400 Original-Received: from rgmgw2.us.oracle.com (rgmgw2.us.oracle.com [138.1.186.111]) by rgminet01.oracle.com (Switch-3.2.4/Switch-3.1.6) with ESMTP id l8A327B6007155; Sun, 9 Sep 2007 21:02:07 -0600 Original-Received: from acsmt350.oracle.com (acsmt350.oracle.com [141.146.40.150]) by rgmgw2.us.oracle.com (Switch-3.2.4/Switch-3.2.4) with ESMTP id l8A1T4Jh030245; Sun, 9 Sep 2007 21:02:06 -0600 Original-Received: from dhcp-amer-csvpn-gw1-141-144-64-101.vpn.oracle.com by acsmt351.oracle.com with ESMTP id 3197843901189393292; Sun, 09 Sep 2007 20:01:32 -0700 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-Detected-Kernel: Linux 2.4-2.6 X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:78401 gmane.emacs.pretest.bugs:19810 Archived-At: This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C7F31C.3ABA7300 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit > > 1. The most common problem I've run into here is that > > strings with text properties are printed so that they > > cannot be read - for example: > > #("foobar" 0 6 (face font-lock-comment-face)). > > That string can be read back just fine. Hmm, you're right. It must have been something else with # that was sometimes getting into my saved histories and provoking a load error. But what's odd is that deleting those strings seemed to remove the error. Oh well, I must have missed something along the way. I looked a bit closer at the rest as well, and I think that `savehist-prin1-readable' needs to actually read what it prints (like it did before Davis's patch). It should raise an error (hence remove the written entry and return nil) if either the write or the read fails. Emacs 20 serves as a good test for this, because it has a bug: If you do `M-x cancel-debug-on-entry RET', then Emacs 20 inserts this invalid entry in the `command-history': (cancel-debug-on-entry ') - note the quote mark before the right paren. This provoked a read error at load time, but the attached patch correctly does not include that invalid entry in the saved `command-history'. [savehist.el does not actually work with Emacs 20, for other reasons (e.g. md5), but I have a version that does work, and I used that to test `savehist-prin1-readable'.] The attached patch fixes this and the other problems that I noted earlier (and it does not remove text properties). HTH - Drew ------=_NextPart_000_0007_01C7F31C.3ABA7300 Content-Type: application/octet-stream; name="savehist-2007-09-09b.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="savehist-2007-09-09b.patch" *** savehist-CVS-2007-09-09a.el Sun Sep 9 09:32:10 2007=0A= --- savehist-patched-2007-09-09b.el Sun Sep 9 19:49:06 2007=0A= ***************=0A= *** 79,86 ****=0A= =0A= (defcustom savehist-additional-variables ()=0A= "*List of additional variables to save.=0A= ! Each element is a symbol whose value will be persisted across Emacs=0A= ! sessions that use savehist. The contents of variables should be=0A= printable with the Lisp printer. You don't need to add minibuffer=0A= history variables to this list, all minibuffer histories will be=0A= saved automatically as long as `savehist-save-minibuffer-history' is=0A= --- 79,86 ----=0A= =0A= (defcustom savehist-additional-variables ()=0A= "*List of additional variables to save.=0A= ! Each element is a symbol whose value is persisted across Emacs=0A= ! sessions that use `savehist'. The contents of variables should be=0A= printable with the Lisp printer. You don't need to add minibuffer=0A= history variables to this list, all minibuffer histories will be=0A= saved automatically as long as `savehist-save-minibuffer-history' is=0A= ***************=0A= *** 118,124 ****=0A= :type 'file=0A= :group 'savehist)=0A= =0A= ! (defcustom savehist-file-modes #o600=0A= "*Default permissions of the history file.=0A= This is decimal, not octal. The default is 384 (0600 in octal).=0A= Set to nil to use the default permissions that Emacs uses, typically=0A= --- 118,124 ----=0A= :type 'file=0A= :group 'savehist)=0A= =0A= ! (defcustom savehist-file-modes 384 ; Octal: #o600=0A= "*Default permissions of the history file.=0A= This is decimal, not octal. The default is 384 (0600 in octal).=0A= Set to nil to use the default permissions that Emacs uses, typically=0A= ***************=0A= *** 237,243 ****=0A= is deducted from the contents of the file."=0A= (savehist-mode 1)=0A= ;; Old versions of savehist distributed with XEmacs didn't save=0A= ! ;; savehist-minibuffer-history-variables. If that variable is nil=0A= ;; after loading the file, try to intuit the intended value.=0A= (when (null savehist-minibuffer-history-variables)=0A= (setq savehist-minibuffer-history-variables=0A= --- 237,243 ----=0A= is deducted from the contents of the file."=0A= (savehist-mode 1)=0A= ;; Old versions of savehist distributed with XEmacs didn't save=0A= ! ;; `savehist-minibuffer-history-variables'. If that variable is nil=0A= ;; after loading the file, try to intuit the intended value.=0A= (when (null savehist-minibuffer-history-variables)=0A= (setq savehist-minibuffer-history-variables=0A= ***************=0A= *** 299,327 ****=0A= (print-string-length nil)=0A= (print-level nil)=0A= (print-readably t)=0A= ! (print-quoted t))=0A= ;; Save the minibuffer histories, along with the value of=0A= ;; savehist-minibuffer-history-variables itself.=0A= (when savehist-save-minibuffer-history=0A= (prin1 `(setq savehist-minibuffer-history-variables=0A= ! ',savehist-minibuffer-history-variables)=0A= ! (current-buffer))=0A= (insert ?\n)=0A= (dolist (symbol savehist-minibuffer-history-variables)=0A= (when (boundp symbol)=0A= (let ((value (savehist-trim-history (symbol-value symbol))))=0A= ! (when value ; don't save empty histories=0A= ! (prin1 `(setq ,symbol ',value) (current-buffer))=0A= ! (insert ?\n))))))=0A= ;; Save the additional variables.=0A= (dolist (symbol savehist-additional-variables)=0A= (when (boundp symbol)=0A= ! (let ((value (symbol-value symbol)))=0A= ! (when (savehist-printable value)=0A= ! (prin1 `(setq ,symbol ',value) (current-buffer))=0A= ! (insert ?\n))))))=0A= ! ;; If autosaving, avoid writing if nothing has changed since the=0A= ! ;; last write.=0A= (let ((checksum (md5 (current-buffer) nil nil = savehist-no-conversion)))=0A= (unless (and auto-save (equal checksum savehist-last-checksum))=0A= ;; Set file-precious-flag when saving the buffer because we=0A= --- 299,328 ----=0A= (print-string-length nil)=0A= (print-level nil)=0A= (print-readably t)=0A= ! (print-quoted t)=0A= ! (print-unreadable-function t)=0A= ! (standard-output (current-buffer)))=0A= ;; Save the minibuffer histories, along with the value of=0A= ;; savehist-minibuffer-history-variables itself.=0A= (when savehist-save-minibuffer-history=0A= (prin1 `(setq savehist-minibuffer-history-variables=0A= ! ',savehist-minibuffer-history-variables))=0A= (insert ?\n)=0A= (dolist (symbol savehist-minibuffer-history-variables)=0A= (when (boundp symbol)=0A= (let ((value (savehist-trim-history (symbol-value symbol))))=0A= ! (when value ; Don't save empty histories.=0A= ! (insert "(setq ") (prin1 symbol) (insert " '(")=0A= ! (while value=0A= ! (savehist-prin1-readable (car value))=0A= ! (setq value (cdr value)) (insert " "))=0A= ! (insert "))\n"))))))=0A= ;; Save the additional variables.=0A= (dolist (symbol savehist-additional-variables)=0A= (when (boundp symbol)=0A= ! (savehist-prin1-readable `(setq ,symbol ',(symbol-value = symbol)))=0A= ! (insert ?\n))))=0A= ! ;; If autosaving, avoid writing if nothing has changed since the = last write.=0A= (let ((checksum (md5 (current-buffer) nil nil = savehist-no-conversion)))=0A= (unless (and auto-save (equal checksum savehist-last-checksum))=0A= ;; Set file-precious-flag when saving the buffer because we=0A= ***************=0A= *** 340,347 ****=0A= (defun savehist-autosave ()=0A= "Save the minibuffer history if it has been modified since the last = save.=0A= Does nothing if `savehist-mode' is off."=0A= ! (when savehist-mode=0A= ! (savehist-save t)))=0A= =0A= (defun savehist-trim-history (value)=0A= "Retain only the first `history-length' items in VALUE.=0A= --- 341,347 ----=0A= (defun savehist-autosave ()=0A= "Save the minibuffer history if it has been modified since the last = save.=0A= Does nothing if `savehist-mode' is off."=0A= ! (condition-case nil (when savehist-mode (savehist-save t)) (error = nil)))=0A= =0A= (defun savehist-trim-history (value)=0A= "Retain only the first `history-length' items in VALUE.=0A= ***************=0A= *** 355,380 ****=0A= (loop repeat history-length collect (pop value))=0A= value))=0A= =0A= ! (defun savehist-printable (value)=0A= ! "Return non-nil if VALUE is printable."=0A= ! (cond=0A= ! ;; Quick response for oft-encountered types known to be printable.=0A= ! ((stringp value))=0A= ! ((numberp value))=0A= ! ((symbolp value))=0A= ! (t=0A= ! ;; For others, check explicitly.=0A= ! (with-temp-buffer=0A= (condition-case nil=0A= ! (let ((print-readably t) (print-level nil))=0A= ! ;; Print the value into a buffer...=0A= (prin1 value (current-buffer))=0A= ! ;; ...and attempt to read it.=0A= ! (read (point-min-marker))=0A= ! ;; The attempt worked: the object is printable.=0A= t)=0A= ! ;; The attempt failed: the object is not printable.=0A= ! (error nil))))))=0A= =0A= (defun savehist-minibuffer-hook ()=0A= (unless (or (eq minibuffer-history-variable t)=0A= --- 355,372 ----=0A= (loop repeat history-length collect (pop value))=0A= value))=0A= =0A= ! (defun savehist-prin1-readable (value)=0A= ! "Print VALUE in the current buffer, but only if it's also readable.=0A= ! Return non-nil if it was printed."=0A= ! (let ((opoint (copy-marker (point)))=0A= ! (opoint-cpy (copy-marker (point))))=0A= (condition-case nil=0A= ! (progn ;;$$$ (when (stringp value) (setq value (format "%s" value)))=0A= (prin1 value (current-buffer))=0A= ! (read opoint)=0A= t)=0A= ! (error (delete-region opoint-cpy (point))=0A= ! nil))))=0A= =0A= (defun savehist-minibuffer-hook ()=0A= (unless (or (eq minibuffer-history-variable t)=0A= =0A= Diff finished at Sun Sep 09 19:50:32=0A= ------=_NextPart_000_0007_01C7F31C.3ABA7300 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ------=_NextPart_000_0007_01C7F31C.3ABA7300--