all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Richard Stallman <rms@gnu.org>
To: Leo <sdl.web@gmail.com>
Cc: emacs-pretest-bug@gnu.org
Subject: Re: 23.0.50; savehist save invalid syntax
Date: Sun, 02 Sep 2007 23:04:20 -0400	[thread overview]
Message-ID: <E1IS2Ee-0001AM-0M@fencepost.gnu.org> (raw)
In-Reply-To: <m2d4x18i8a.fsf@cam.ac.uk> (message from Leo on Sun, 02 Sep 2007 11:38:45 +0100)

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)

  parent reply	other threads:[~2007-09-03  3:04 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-02 10:38 23.0.50; savehist save invalid syntax Leo
2007-09-02 13:21 ` Drew Adams
2007-09-03  3:04 ` Richard Stallman [this message]
2007-09-04 22:48   ` Davis Herring
2007-09-05  3:20     ` Stefan Monnier
2007-09-05  6:16     ` Richard Stallman
2007-09-05 18:16       ` Davis Herring
2007-09-06  5:00         ` Richard Stallman
2007-09-09 21:58         ` Drew Adams
2007-09-09 23:14           ` Andreas Schwab
2007-09-10  3:01             ` Drew Adams
2007-09-10  3:07               ` Drew Adams
2007-09-10 22:11               ` Davis Herring
2007-09-10 23:42                 ` Drew Adams
2007-09-10 23:54               ` Richard Stallman
2007-09-11 20:27                 ` Davis Herring
2007-09-10 21:59           ` Davis Herring
2007-09-10 23:42             ` Drew Adams
2007-09-11  0:55               ` Davis Herring
2007-09-11  1:11                 ` Stefan Monnier
2007-09-11 21:06                   ` [Released] " Davis Herring
2007-09-11 21:29                     ` Stefan Monnier
2007-09-14  7:04                     ` Richard Stallman
2007-09-11  1:18                 ` Drew Adams
2007-09-05 19:57       ` Leo
2007-10-18 21:08 ` Leo
2007-10-19  8:15   ` Leo
2007-10-19 14:01     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1IS2Ee-0001AM-0M@fencepost.gnu.org \
    --to=rms@gnu.org \
    --cc=emacs-pretest-bug@gnu.org \
    --cc=sdl.web@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.