--- Begin Message ---
Subject: |
30.0.50; [PATCH] Improve read/append behavior of eshell history command |
Date: |
Fri, 27 Oct 2023 12:15:00 +0800 |
Hi,
This patch fixes some corner cases of the eshell history command about
reading (-r) and appending (-a).
Recipe:
1. create a sample history file containing some lines, e.g.
ls
2. emacs -Q --eval "(setq eshell-history-file-name ...)" -f eshell
3. type following commands:
$ ls
$ history -a
$ cd /tmp
$ history -a
'history -a' doesn't distinguish old history from new history items of
current buffer, and always appends the whole history list whenever it
is called, resulting in a mess of the content of history file:
ls
ls
ls
history -a
ls
ls
history -a
cd /tmp/
history -a
If another eshell buffer or emacs instance is launched before we quit
this eshell buffer, they will read messed history. Thus this patch
changes behavior of 'history -a' from "append current history list to
history file" to "append new history in current buffer to history
file", which is also consistent with bash's 'history -a'.
4. continue to type:
$ (setq eshell-hist-ignoredups t)
$ history -a; history -r
$ history
'history -r', which calls eshell-read-history, doesn't remove
consecutive "ls" duplicates from the history file. Thus this patch
amends eshell-read-history to make it respect the
eshell-hist-ignoredups option (both t and 'erase).
Since 'history -r' replaces current history list, which is actually
equivalent to bash's 'history -c; history -r', I have updated the help
text. Maybe it should be split into two commands, i.e. adding 'history
-c'?
Best,
--
Liu Hui
0001-Improve-read-append-behavior-of-eshell-history-comma.patch
Description: Text Data
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#66768: 30.0.50; [PATCH] Improve read/append behavior of eshell history command |
Date: |
Fri, 10 Nov 2023 18:03:07 -0800 |
Version: 30.1
On 11/7/2023 2:14 AM, Liu Hui wrote:
Thanks for your comments! I've updated the patch to address all
concerns.
Everything in your patch looks good to me. I've now merged it as
8b3969006fe (with a small editorial change to a docstring), and added a
few extra regression tests for the history code on top as f2b162f8ee5.
Closing this now. Thanks for helping improve Eshell!
--- End Message ---