emacs-devel
[Top][All Lists]
Advanced

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

Re: 23.0.50; savehist save invalid syntax


From: Richard Stallman
Subject: Re: 23.0.50; savehist save invalid syntax
Date: Sun, 02 Sep 2007 23:04:20 -0400

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)




reply via email to

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