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

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

RE: savehist-autosave should be wrapped in a condition-case


From: Drew Adams
Subject: RE: savehist-autosave should be wrapped in a condition-case
Date: Thu, 1 Dec 2005 15:30:46 -0800

    > Because it's always possible for a history list to end up containing
    > malformed entries,

    Really?  How can that happen?

It probably can't, in the normal event of things. By "it's always possible"
I meant that it's happened to me -- no doubt by messing around.

The problem with ignoring this possibility is that this is in
kill-emacs-hook, and it makes it hard for a user to exit if the (rare)
problem does happen to arise. He needs to know enough to do something like
use remove-hook (or savehist-uninstall) to disable history saving and try
again to exit.

    > in my local copy of savehist.el I have added this condition-case:
    >
    > (defun savehist-autosave ()
    >   "Save the minibuffer history if it has been modified since the last
    > save."
    >   (condition-case nil
    >       (savehist-save t)
    >     (error nil)))

    The problem with this is that it effectively disables saving the
    history until you reenter Emacs.  savehist-save could check for
    "printability" of each history list, but that check does not come
    without a cost and I wanted to avoid it if I could.

I agree. If this problem were something that could happen easily, then some
more sophisticated check might be needed, even at some performance cost.
Since, however, (I believe) this problem should normally never occur, the ~
freebie safety net should be enough. You just need something
fool(Drew)proof.

Another possibility would be to use a simple condition-case to catch the
(rare) error, then resort to cleaning up the history lists and trying again
to save. There would be no cost in that case, except when a cleanup is
really needed.

 - Drew





reply via email to

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