* [PATCH] Fix 'unset ZLE_RPROMPT_INDENT' not restoring the default behaviour.
@ 2017-03-05 22:25 Daniel Shahaf
2017-03-05 23:34 ` Daniel Shahaf
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Shahaf @ 2017-03-05 22:25 UTC (permalink / raw)
To: zsh-workers
To reproduce:
RPS1=foo
ZLE_RPROMPT_INDENT=42
unset ZLE_RPROMPT_INDENT
---
Src/init.c | 2 +-
Src/params.c | 19 ++++++++++++++++++-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/Src/init.c b/Src/init.c
index 43d274c..98f836f 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -790,7 +790,7 @@ init_term(void)
tcstr[TCCLEARSCREEN] = ztrdup("\14");
tclen[TCCLEARSCREEN] = 1;
}
- rprompt_indent = 1;
+ rprompt_indent = 1; /* If you change this, update rprompt_indent_unsetfn() */
/* The following is an attempt at a heuristic,
* but it fails in some cases */
/* rprompt_indent = ((hasam && !hasbw) || hasye || !tccan(TCLEFT)); */
diff --git a/Src/params.c b/Src/params.c
index d09ff21..f01bbfa 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -128,6 +128,11 @@ struct timeval shtimer;
/**/
mod_export int termflags;
+/* Forward declaration */
+
+static void
+rprompt_indent_unsetfn(Param pm, UNUSED(int exp));
+
/* Standard methods for get/set/unset pointers in parameters */
/**/
@@ -241,6 +246,9 @@ static const struct gsu_integer argc_gsu =
static const struct gsu_array pipestatus_gsu =
{ pipestatgetfn, pipestatsetfn, stdunsetfn };
+static const struct gsu_integer rprompt_indent_gsu =
+{ intvargetfn, zlevarsetfn, rprompt_indent_unsetfn };
+
/* Nodes for special parameters for parameter hash table */
#ifdef HAVE_UNION_INIT
@@ -327,7 +335,7 @@ IPDEF4("ZSH_SUBSHELL", &zsh_subshell),
#define IPDEF5U(A,B,F) {{NULL,A,PM_INTEGER|PM_SPECIAL|PM_UNSET},BR((void *)B),GSU(F),10,0,NULL,NULL,NULL,0}
IPDEF5("COLUMNS", &zterm_columns, zlevar_gsu),
IPDEF5("LINES", &zterm_lines, zlevar_gsu),
-IPDEF5U("ZLE_RPROMPT_INDENT", &rprompt_indent, zlevar_gsu),
+IPDEF5U("ZLE_RPROMPT_INDENT", &rprompt_indent, rprompt_indent_gsu),
IPDEF5("SHLVL", &shlvl, varinteger_gsu),
/* Don't import internal integer status variables. */
@@ -3733,6 +3741,15 @@ zlevarsetfn(Param pm, zlong x)
adjustwinsize(2 + (p == &zterm_columns));
}
+
+/* Implements gsu_integer.unsetfn for ZLE_RPROMPT_INDENT; see stdunsetfn() */
+
+static void
+rprompt_indent_unsetfn(Param pm, UNUSED(int exp))
+{
+ rprompt_indent = 1; /* Keep this in sync with init_term() */
+}
+
/* Function to set value of generic special scalar *
* parameter. data is pointer to a character pointer *
* representing the scalar (string). */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix 'unset ZLE_RPROMPT_INDENT' not restoring the default behaviour.
2017-03-05 22:25 [PATCH] Fix 'unset ZLE_RPROMPT_INDENT' not restoring the default behaviour Daniel Shahaf
@ 2017-03-05 23:34 ` Daniel Shahaf
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Shahaf @ 2017-03-05 23:34 UTC (permalink / raw)
To: zsh-workers
Daniel Shahaf wrote on Sun, Mar 05, 2017 at 22:25:33 +0000:
> +/* Implements gsu_integer.unsetfn for ZLE_RPROMPT_INDENT; see stdunsetfn() */
> +
> +static void
> +rprompt_indent_unsetfn(Param pm, UNUSED(int exp))
> +{
> + rprompt_indent = 1; /* Keep this in sync with init_term() */
> +}
That's wrong: unlike stdunsetfn(), it doesn't add the PM_UNSET bitflag,
so ${+ZLE_RPROMPT_INDENT} remains 1 after unsetting.
Fix:
diff --git a/Src/params.c b/Src/params.c
index f01bbfa..798e92c 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -131,7 +131,7 @@ mod_export int termflags;
/* Forward declaration */
static void
-rprompt_indent_unsetfn(Param pm, UNUSED(int exp));
+rprompt_indent_unsetfn(Param pm, int exp);
/* Standard methods for get/set/unset pointers in parameters */
@@ -3745,8 +3745,9 @@ zlevarsetfn(Param pm, zlong x)
/* Implements gsu_integer.unsetfn for ZLE_RPROMPT_INDENT; see stdunsetfn() */
static void
-rprompt_indent_unsetfn(Param pm, UNUSED(int exp))
+rprompt_indent_unsetfn(Param pm, int exp)
{
+ stdunsetfn(pm, exp);
rprompt_indent = 1; /* Keep this in sync with init_term() */
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-05 23:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-05 22:25 [PATCH] Fix 'unset ZLE_RPROMPT_INDENT' not restoring the default behaviour Daniel Shahaf
2017-03-05 23:34 ` Daniel Shahaf
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).