From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel,gmane.emacs.pretest.bugs Subject: Re: 23.0.50; savehist save invalid syntax Date: Sun, 02 Sep 2007 23:04:20 -0400 Message-ID: References: Reply-To: rms@gnu.org NNTP-Posting-Host: lo.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: sea.gmane.org 1188788740 26355 80.91.229.12 (3 Sep 2007 03:05:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 3 Sep 2007 03:05:40 +0000 (UTC) Cc: emacs-pretest-bug@gnu.org To: Leo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 03 05:05:40 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 1IS2Ft-00050H-VN for ged-emacs-devel@m.gmane.org; Mon, 03 Sep 2007 05:05:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IS2Fs-0003Jq-TY for ged-emacs-devel@m.gmane.org; Sun, 02 Sep 2007 23:05:36 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IS2Et-0002rD-5h for emacs-devel@gnu.org; Sun, 02 Sep 2007 23:04:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IS2Es-0002qO-6c for emacs-devel@gnu.org; Sun, 02 Sep 2007 23:04:34 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IS2Es-0002qF-1A for emacs-devel@gnu.org; Sun, 02 Sep 2007 23:04:34 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IS2Er-00045Z-Ip for emacs-devel@gnu.org; Sun, 02 Sep 2007 23:04:33 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.60) (envelope-from ) id 1IS2Ee-0001AM-0M; Sun, 02 Sep 2007 23:04:20 -0400 In-reply-to: (message from Leo on Sun, 02 Sep 2007 11:38:45 +0100) 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:77634 gmane.emacs.pretest.bugs:19707 Archived-At: It looks like the unreadable data is in saved arguments of commands in command-history. The data are not wrong, so savehist will have to cope with them. I think the best approach is to discard any element of command-history that contains anything unreadable. If the arguments of a command include a mouse event, repeating it in another session won't make much sense anyway. This suggests an implementation: when writing the file, print one element at a time, then immediately try reading it and see if it gets an error. If so, delete the text. Does the patch below give good results? Checking on output, like this, might cause a slowdown. It would be more efficient to check when reading the saved history, but in order to do that, we would have to give up the ability to read it with `load'. That is undesirable, so first let's try this approach. *** savehist.el 25 Jul 2007 11:49:12 -0400 1.19.2.1 --- savehist.el 02 Sep 2007 16:13:15 -0400 *************** *** 309,318 **** (insert ?\n) (dolist (symbol savehist-minibuffer-history-variables) (when (boundp symbol) ! (let ((value (savehist-trim-history (symbol-value symbol)))) (when value ; don't save empty histories ! (prin1 `(setq ,symbol ',value) (current-buffer)) ! (insert ?\n)))))) ;; Save the additional variables. (dolist (symbol savehist-additional-variables) (when (boundp symbol) --- 309,346 ---- (insert ?\n) (dolist (symbol savehist-minibuffer-history-variables) (when (boundp symbol) ! (let ((value (savehist-trim-history (symbol-value symbol))) ! excess-space) (when value ; don't save empty histories ! (insert "(setq ") ! (prin1 symbol (current-buffer)) ! (insert " '(") ! (setq excess-space (point)) ! ;; Print elements of VALUE one by one, carefully. ! (dolist (elt value) ! (let ((start (point))) ! (insert " ") ! (prin1 elt (current-buffer)) ! ;; Try to read the element we just printed. ! (condition-case nil ! (save-excursion ! (goto-char start) ! (read (current-buffer))) ! (error ! ;; If reading it gets an error, comment it out. ! (goto-char start) ! (insert "\n") ! (while (not (eobp)) ! (insert ";;; ") ! (forward-line 1)) ! (insert "\n"))) ! (goto-char (point-max)))) ! ;; Delete the extra space before the first element. ! (save-excursion ! (goto-char excess-space) ! (if (eq (following-char) ?\s) ! (delete-region (point) (1+ (point))))) ! (insert "))\n")))))) ;; Save the additional variables. (dolist (symbol savehist-additional-variables) (when (boundp symbol)