* [PATCH] Introduce ZCALC_HISTFILE
@ 2022-09-09 23:27 Julian Prein
2022-09-10 0:49 ` Lawrence Velázquez
0 siblings, 1 reply; 4+ messages in thread
From: Julian Prein @ 2022-09-09 23:27 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1.1: Type: text/plain, Size: 2262 bytes --]
Hi!
This is my first time submitting a patch, so please tell me if something about
the email or patch format should be changed.
Julian
From 31f9646d8125aa5495106af539cca7322123dcfe Mon Sep 17 00:00:00 2001
From: Julian Prein <druckdev@protonmail.com>
Date: Sat, 10 Sep 2022 01:10:16 +0200
Subject: [PATCH] Introduce ZCALC_HISTFILE
Make the location of the history file to which zcalc writes customizable
through the introduced variable `$ZCALC_HISTFILE`.
Update the documentation to mention this variable. The updated part used
to differ from the implementation as it did not mention `$ZDOTDIR`.
Signed-off-by: Julian Prein <druckdev@protonmail.com>
---
Doc/Zsh/contrib.yo | 6 ++++--
Functions/Misc/zcalc | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 0ef59dbc9ca5..0bc7859b1683 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -3972,8 +3972,10 @@ calculation is stored. For example, the result of the calculation on the
line preceded by `tt(4> )' is available as tt($4). The last value
calculated is available as tt(ans). Full command line editing, including
the history of previous calculations, is available; the history is saved in
-the file tt(~/.zcalc_history). To exit, enter a blank line or type `tt(:q)'
-on its own (`tt(q)' is allowed for historical compatibility).
+the file tt($ZCALC_HISTFILE). If tt($ZCALC_HISTFILE) is unset,
+tt($ZDOTDIR/.zcalc_history) is used instead. To exit, enter a blank line
+or type `tt(:q)' on its own (`tt(q)' is allowed for historical
+compatibility).
A line ending with a single backslash is treated in the same fashion
as it is in command line editing: the backslash is removed, the
diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc
index 480373345124..397aa3cc1d4e 100644
--- a/Functions/Misc/zcalc
+++ b/Functions/Misc/zcalc
@@ -125,7 +125,7 @@ integer _max_stack _push
local -a _expressions stack
# We use our own history file with an automatic pop on exit.
-history -ap "${ZDOTDIR:-$HOME}/.zcalc_history"
+history -ap "${ZCALC_HISTFILE:-${ZDOTDIR:-$HOME}/.zcalc_history}"
_forms=( '%2$g' '%.*g' '%.*f' '%.*E' '')
--
2.25.1
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Introduce ZCALC_HISTFILE
2022-09-09 23:27 [PATCH] Introduce ZCALC_HISTFILE Julian Prein
@ 2022-09-10 0:49 ` Lawrence Velázquez
2022-09-19 2:02 ` Julian Prein
0 siblings, 1 reply; 4+ messages in thread
From: Lawrence Velázquez @ 2022-09-10 0:49 UTC (permalink / raw)
To: Julian Prein; +Cc: zsh-workers
Hi Julian,
Thanks for the submission! I don't have a particular opinion on
this proposal, but...
On Fri, Sep 9, 2022, at 7:27 PM, Julian Prein wrote:
> +the file tt($ZCALC_HISTFILE). If tt($ZCALC_HISTFILE) is unset,
> +tt($ZDOTDIR/.zcalc_history) is used instead.
This doesn't align with the actual code.
> # We use our own history file with an automatic pop on exit.
> -history -ap "${ZDOTDIR:-$HOME}/.zcalc_history"
> +history -ap "${ZCALC_HISTFILE:-${ZDOTDIR:-$HOME}/.zcalc_history}"
Consider something along the lines of:
Full command line editing, including the history of previous
calculations, is available; the history is saved in the
file specified by $ZCALC_HISTFILE, $ZDOTDIR/.zcalc_history
(if $ZCALC_HISTFILE is unset or empty), or $HOME/.zcalc_history
(if both $ZCALC_HISTFILE and $ZDOTDIR are unset or empty).
--
vq
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Introduce ZCALC_HISTFILE
2022-09-10 0:49 ` Lawrence Velázquez
@ 2022-09-19 2:02 ` Julian Prein
2022-09-25 17:07 ` Peter Stephenson
0 siblings, 1 reply; 4+ messages in thread
From: Julian Prein @ 2022-09-19 2:02 UTC (permalink / raw)
To: Lawrence Velázquez; +Cc: zsh-workers
[-- Attachment #1.1: Type: text/plain, Size: 2521 bytes --]
Hi Lawrence,
Thank you for your response!
I originally thought about that too, but in the end decided not to specify it as
I found other sections where `$ZDOTDIR` is mentioned without fallback. It seemed
like more noise that needed.
Anyways, here is the updated patch. Let me know what you think!
Julian
From d3b75e7e2af95b89194f3d4f039df5b1ad1ba9a5 Mon Sep 17 00:00:00 2001
From: Julian Prein <druckdev@protonmail.com>
Date: Sat, 10 Sep 2022 01:10:16 +0200
Subject: [PATCH] Introduce ZCALC_HISTFILE
Make the location of the history file to which zcalc writes customizable
through the introduced variable `$ZCALC_HISTFILE`.
Update the documentation to mention this variable. The updated part used
to differ from the implementation as it did not mention `$ZDOTDIR`.
Signed-off-by: Julian Prein <druckdev@protonmail.com>
---
Doc/Zsh/contrib.yo | 7 +++++--
Functions/Misc/zcalc | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 0ef59dbc9ca5..96de5aa9bf8f 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -3972,8 +3972,11 @@ calculation is stored. For example, the result of the calculation on the
line preceded by `tt(4> )' is available as tt($4). The last value
calculated is available as tt(ans). Full command line editing, including
the history of previous calculations, is available; the history is saved in
-the file tt(~/.zcalc_history). To exit, enter a blank line or type `tt(:q)'
-on its own (`tt(q)' is allowed for historical compatibility).
+the file tt($ZCALC_HISTFILE). If tt($ZCALC_HISTFILE) is unset,
+tt($ZDOTDIR/.zcalc_history) is used instead, which in turn falls backs to
+tt($HOME/.zcalc_history) if tt($ZDOTDIR) is unset. To exit, enter a blank
+line or type `tt(:q)' on its own (`tt(q)' is allowed for historical
+compatibility).
A line ending with a single backslash is treated in the same fashion
as it is in command line editing: the backslash is removed, the
diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc
index 480373345124..397aa3cc1d4e 100644
--- a/Functions/Misc/zcalc
+++ b/Functions/Misc/zcalc
@@ -125,7 +125,7 @@ integer _max_stack _push
local -a _expressions stack
# We use our own history file with an automatic pop on exit.
-history -ap "${ZDOTDIR:-$HOME}/.zcalc_history"
+history -ap "${ZCALC_HISTFILE:-${ZDOTDIR:-$HOME}/.zcalc_history}"
_forms=( '%2$g' '%.*g' '%.*f' '%.*E' '')
--
2.25.1
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Introduce ZCALC_HISTFILE
2022-09-19 2:02 ` Julian Prein
@ 2022-09-25 17:07 ` Peter Stephenson
0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2022-09-25 17:07 UTC (permalink / raw)
To: zsh-workers
On Mon, 2022-09-19 at 02:02 +0000, Julian Prein wrote:
> Anyways, here is the updated patch. Let me know what you think!
>...
> Make the location of the history file to which zcalc writes customizable
> through the introduced variable `$ZCALC_HISTFILE`.
>
> Update the documentation to mention this variable. The updated part used
> to differ from the implementation as it did not mention `$ZDOTDIR`.
Thanks, this looks fine and as the original author of zcalc I've
committed this.
pws
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-25 17:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09 23:27 [PATCH] Introduce ZCALC_HISTFILE Julian Prein
2022-09-10 0:49 ` Lawrence Velázquez
2022-09-19 2:02 ` Julian Prein
2022-09-25 17:07 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).