bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Invalid read syntax when using savehist.el


From: Reiner Steib
Subject: Re: Invalid read syntax when using savehist.el
Date: Wed, 28 Nov 2007 23:40:59 +0100
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux)

On Tue, Nov 27 2007, spamfilteraccount@gmail.com wrote:

> On Nov 27, 7:13 am, "spamfilteracco...@gmail.com"
> <spamfilteracco...@gmail.com> wrote:
>> I have savehist turned on and yesterday startup of emacs failed with
>> an invalid read syntax error.
>>
>> Turned out the problem was caused by a kbd macro which savehist stored
>> like this:
>>
>> (setq command-history '( ... (execute-kbd-macro [19 107 (language-
>> change (#<frame ...
>>
>
> BTW, I was switching buffers during execution of  the macro and that's
> why the frame is stored:
>
> (execute-kbd-macro [19 107 (language-change (#<frame  *Minibuf-1*
> 0x18e1c00>)) .... )

The following changes have been made in `savehist.el' since the
release of Emacs 22.1.  I'd guess it should fix your problem.

--8<---------------cut here---------------start------------->8---
--- savehist.el 21 Jan 2007 03:53:11 -0000      1.19
+++ savehist.el 30 Oct 2007 08:24:08 -0000      1.19.2.3
@@ -308,11 +308,42 @@
               (current-buffer))
        (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))))))
+         (when (and (boundp symbol)
+                    (not (memq symbol savehist-ignored-variables)))
+           (let ((value (savehist-trim-history (symbol-value symbol)))
+                 excess-space)
+             (when value               ; Don't save empty histories.
+               (insert "(setq ")
+               (prin1 symbol (current-buffer))
+               (insert " '(")
+               ;; We will print an extra space before the first element.
+               ;; Record where that is.
+               (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)
--8<---------------cut here---------------end--------------->8---

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]