Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
gen-hg-bookmark-string hook in vcs_info is not very helpful
- X-seq: zsh-users 22899
- From: yegle <cnyegle@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: gen-hg-bookmark-string hook in vcs_info is not very helpful
- Date: Fri, 22 Sep 2017 11:33:18 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=sOl7DM1qE7TeJhfAkadtiQFxu5F2MByTC6Ep/YhUG8k=; b=S6TiRSgeFDwfyXXnWv8Zr3A7Jp5UVzhKzbVVD+LtTRXDR/4sRCm0dZTp5H9Q5J2+K1 U7e2ZujysMqoB4QmjI88Md/ZLh01ugn7lE0OuoVDINO36CVYB0TBQUx2Zg0Xi0g/tNAZ S68eBwu6PvoqaRxyABCxv8drLwqSt8nr+kAZMIA5zGI7XOBYdolzqe+C22/DehE/BjO0 ifxIu0sJ3H2a2HDTMKvMfwdjW3hgI7n3tL+I1MylLwGBRZfLAH+ovIPLIl+T75/kDZ0v YjNM2zWnvzGgpP0GeXMbN/sCMo2NmNAIjqQWCxg38a1Sm/FlloqQqmumpi0mHysCd9Ds RYvw==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
Hi list,
I'm trying to highlight the current bookmark in a hg repo with some color.
It looks like gen-hg-bookmark-string is the way to go, but I find it
impossible to do what I plan to do.
Specifically, the issue with these lines:
https://github.com/zsh-users/zsh/blob/master/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg#L140-L142
if VCS_INFO_hook 'gen-hg-bookmark-string' "${hgbmarks[@]}"; then
# If there is an active bookmark, annotate it and put it first.
if [[ -n $curbm ]] ; then
hgbmarks[(i)$curbm]=()
hgbmarks[1,0]="${curbm}*"
fi
hgbmstring=${(j:, :)hgbmarks}
# Deannotate the array, in case later code expects it to be valid.
# (The order is not restored.)
[[ -n $curbm ]] && hgbmarks[1]=${${hgbmarks[1]}[1,-2]}
else
hgbmstring=${hook_com[hg-bookmark-string]}
fi
Because the existing code append $curbm with *, it seems like I can just
modify curbm in my hook to add color escape string. But note the line
`hgbmarks[(i)$curbm]=()`: if you modify $curbm in any way, the result
string will have duplicate bookmarks: one that I modified with color escape
string, one that was failed to remove from the array.
Another option, of course, is to make the change and then unset $curbm at
the end, but this is really a hack:
function +vi-hg-highlight-curbm {
if [[ -n $curbm ]] ; then
hgbmarks[(i)$curbm]=()
hgbmarks[1,0]="%{$fg_bold[red]%}${curbm}%{$reset_color%}*"
curbm=""
fi
}
I think a very simple fix for this issue is to modify the line to:
hgbmarks[1,0]="${hook_com[hg-active-bookmark]}*"
Can anyone propose a patch to fix this issue and make
gen-hg-bookmark-string more useful? I would be happy to send a PR if the
repo is hosted on Github or something more user friendly :-(
--
Yuchen Ying
https://about.me/yegle
Messages sorted by:
Reverse Date,
Date,
Thread,
Author