[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Turning on savehist-mode by default
From: |
Po Lu |
Subject: |
Re: Turning on savehist-mode by default |
Date: |
Sun, 19 Nov 2023 14:59:47 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
sbaugh@catern.com writes:
> savehist-mode is a useful mode which is turned on by many Emacs
> users. [1] It matches the default behavior of programs like bash and
> vim, which save command history by default. I suggest that we should
> find some way to enable savehist by default.
>
> By default savehist creates a timer which saves the history every 5
> minutes. I suggest that by default we should just have behavior like:
> (add-hook 'kill-emacs-hook #'savehist-autosave)
> If the user explicitly runs (savehist-mode 1) then that would enable the
> timer-based saving.
>
> I'm not sure what other issues have prevented savehist from being turned
> on by default, but I'm happy to do the work to get it into good shape.
>
> This proposal is somewhat motivated by bug#66993, because project.el
> already has some custom code which runs by default which is kind of like
> savehist-mode, but which only save project--list. It may be possible to
> get rid of that code in favor of the generic savehist logic, but to do
> that we'd need to turn savehist on by default in some form.
There is a grave disadvantage to introducing kill-emacs-hooks or saving
files periodically from a timer. In the case of the former, Emacs will
behave inconsistently, subject to whether it's been killed such that the
hook cannot run. And the latter runs the risk of files being corrupted
if the file is being saved, by chance, the instant Emacs is killed.
You might object that people are always meant to shut Emacs down in a
way that prompts it to execute these hooks, but I've always considered
it a virtue of Emacs's that it can be so terminated without consequence.
Departing from this in our default configuration would be a step
backwards, inasmuch as we constantly hear of users suffering from long
startup times, implying that Emacs is frequently started for momentary
editing sessions. And in such scenarios users are apt to kill Emacs by
whatever means are then at hand: xkill, pkill, and the like, this being
behavior that I have myself engaged in on occasion.
As regards enabling savehist-mode by default, I have no strong
objections. Provided that you can pull it off without either timers or
entries in kill-emacs-hook.
- Re: [External] : Turning on savehist-mode by default, (continued)
- RE: [External] : Turning on savehist-mode by default, Drew Adams, 2023/11/20
- Re: [External] : Turning on savehist-mode by default, Eli Zaretskii, 2023/11/20
- RE: [External] : Turning on savehist-mode by default, Drew Adams, 2023/11/20
- Re: [External] : Turning on savehist-mode by default, Eli Zaretskii, 2023/11/20
- RE: [External] : Turning on savehist-mode by default, Drew Adams, 2023/11/19
- RE: [External] : Turning on savehist-mode by default, Drew Adams, 2023/11/19
- Re: [External] : Turning on savehist-mode by default, Visuwesh, 2023/11/19
- Re: Turning on savehist-mode by default, sbaugh, 2023/11/19
Re: Turning on savehist-mode by default,
Po Lu <=
Re: Turning on savehist-mode by default, Dmitry Gutov, 2023/11/19
Re: Turning on savehist-mode by default, Spencer Baugh, 2023/11/19
Re: Turning on savehist-mode by default, Po Lu, 2023/11/19
Re: Turning on savehist-mode by default, sbaugh, 2023/11/19