summaryrefslogtreecommitdiff
path: root/Src/Zle/zle_params.c
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2012-05-02 13:30:33 +0000
committerMikael Magnusson <mikachu@gmail.com>2012-05-02 13:30:33 +0000
commitf7ce5878b8b8976ba81ae6090e12aeab1f8c6f27 (patch)
tree7295f330812bc16aae7d53b16de181d802bb14c8 /Src/Zle/zle_params.c
parent150dc9021bcf8a03671424142a9ffbfecd516915 (diff)
downloadzsh-f7ce5878b8b8976ba81ae6090e12aeab1f8c6f27.tar.gz
zsh-f7ce5878b8b8976ba81ae6090e12aeab1f8c6f27.zip
30425 (fixed): Add localhistory/globalhistory to $ZLE_STATE as set by the set-local-history zle widget
Diffstat (limited to 'Src/Zle/zle_params.c')
-rw-r--r--Src/Zle/zle_params.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index 1a39df862..03c6261f5 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -709,21 +709,17 @@ get_context(UNUSED(Param pm))
static char *
get_zle_state(UNUSED(Param pm))
{
- char *zle_state = NULL, *ptr = NULL;
+ char *zle_state = NULL, *ptr = NULL, **arr = NULL;
int itp, istate, len = 0;
/*
- * When additional substrings are added, they should be kept in
- * alphabetical order, so the user can easily match against this
- * parameter: if [[ $ZLE_STATE == *bar*foo*zonk* ]]; then ...; fi
+ * Substrings are sorted at the end, so the user can
+ * easily match against this parameter:
+ * if [[ $ZLE_STATE == *bar*foo*zonk* ]]; then ...; fi
*/
for (itp = 0; itp < 2; itp++) {
char *str;
- /*
- * Currently there is only one state: insert or overwrite.
- * This loop is to make it easy to add others.
- */
- for (istate = 0; istate < 1; istate++) {
+ for (istate = 0; istate < 2; istate++) {
int slen;
switch (istate) {
case 0:
@@ -733,6 +729,13 @@ get_zle_state(UNUSED(Param pm))
str = "overwrite";
}
break;
+ case 1:
+ if (hist_skip_flags & HIST_FOREIGN) {
+ str = "localhistory";
+ } else {
+ str = "globalhistory";
+ }
+ break;
default:
str = "";
@@ -746,7 +749,7 @@ get_zle_state(UNUSED(Param pm))
} else {
/* Accumulating string */
if (istate)
- *ptr++ = ' ';
+ *ptr++ = ':';
memcpy(ptr, str, slen);
ptr += slen;
}
@@ -758,6 +761,11 @@ get_zle_state(UNUSED(Param pm))
*ptr = '\0';
}
}
+
+ arr = colonsplit(zle_state, 0);
+ strmetasort(arr, SORTIT_ANYOLDHOW, NULL);
+ zle_state = zjoin(arr, ' ', 1);
+ freearray(arr);
return zle_state;
}