* [PATCH] improve surfraw subcommands list
@ 2021-02-27 15:27 Marc Chantreux
2021-03-01 15:23 ` Daniel Shahaf
0 siblings, 1 reply; 6+ messages in thread
From: Marc Chantreux @ 2021-02-27 15:27 UTC (permalink / raw)
To: Zsh Users
[-- Attachment #1: Type: text/plain, Size: 410 bytes --]
hello people,
i wrote this patch for the _surfraw completion, it
* add bookmarks support
* remove the header from the final list
i don't know if it's good enough to be merged but
bookmark support is very useful so this is my proposal.
any review will be warmly welcome.
regards,
marc
---
Completion/Unix/Command/_surfraw | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
[-- Attachment #2: 0001-improve-surfraw-subcommands-list.patch --]
[-- Type: text/x-patch, Size: 1158 bytes --]
diff --git a/Completion/Unix/Command/_surfraw b/Completion/Unix/Command/_surfraw
index f945f1ca9..343d275cc 100644
--- a/Completion/Unix/Command/_surfraw
+++ b/Completion/Unix/Command/_surfraw
@@ -424,12 +424,26 @@ case $state in
yubnub)
_message -e command 'Yubnub Command'
;;
+ *)
+ _message -e string 'search string'
+ ;;
esac
;;
elvi)
+ local -UT XDG_CONFIG_DIRS xcd
+ # as it starts with a space, the header becomes an empty
+ # string removed by the list expansion
_wanted elvi expl elvi compadd \
- ${${${(f)"$(_call_program elvi surfraw -elvi)"}%%[[:space:]]##--*}%:*} && ret=0
+ ${${(f)"$(surfraw -elvi)"}%%[[:space:]]*} $(
+ # extract the keys of all bookmarks (should be in surfraw itself)
+ awk '{keys[$1]=1} END {for (k in keys) print k}' \
+ $^xcd/surfraw/bookmarks(Nr) \
+ /etc/xdg/surfraw/bookmarks(Nr) \
+ /etc/surfraw.bookmarks(Nr) \
+ ${XDG_CONFIG_HOME-${HOME?homeless}/.config}/surfraw/bookmarks(Nr) \
+ ${HOME?homeless}/.surfraw.bookmarks(Nr)
+ ) && ret=0
;;
-esac
+esac
return ret
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] improve surfraw subcommands list
2021-02-27 15:27 [PATCH] improve surfraw subcommands list Marc Chantreux
@ 2021-03-01 15:23 ` Daniel Shahaf
2021-03-11 18:08 ` Marc Chantreux
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Shahaf @ 2021-03-01 15:23 UTC (permalink / raw)
To: Marc Chantreux; +Cc: Zsh Users
Marc Chantreux wrote on Sat, Feb 27, 2021 at 16:27:35 +0100:
> diff --git a/Completion/Unix/Command/_surfraw b/Completion/Unix/Command/_surfraw
> index f945f1ca9..343d275cc 100644
> --- a/Completion/Unix/Command/_surfraw
> +++ b/Completion/Unix/Command/_surfraw
> @@ -424,12 +424,26 @@ case $state in
> yubnub)
> _message -e command 'Yubnub Command'
> ;;
> + *)
> + _message -e string 'search string'
> + ;;
> esac
> ;;
> elvi)
> + local -UT XDG_CONFIG_DIRS xcd
Don't play golf. Name it «xdg_config_dirs».
> + # as it starts with a space, the header becomes an empty
> + # string removed by the list expansion
What? Does "the header" mean the first line of the output?
> _wanted elvi expl elvi compadd \
> - ${${${(f)"$(_call_program elvi surfraw -elvi)"}%%[[:space:]]##--*}%:*} && ret=0
> + ${${(f)"$(surfraw -elvi)"}%%[[:space:]]*} $(
Restore _call_program.
> + # extract the keys of all bookmarks (should be in surfraw itself)
> + awk '{keys[$1]=1} END {for (k in keys) print k}' \
Use a parameter expansion rather than an external dependency and a fork,
if possible. If there's a reason to make an exception, it's not clear
to me.
> + $^xcd/surfraw/bookmarks(Nr) \
> + /etc/xdg/surfraw/bookmarks(Nr) \
> + /etc/surfraw.bookmarks(Nr) \
> + ${XDG_CONFIG_HOME-${HOME?homeless}/.config}/surfraw/bookmarks(Nr) \
> + ${HOME?homeless}/.surfraw.bookmarks(Nr)
There shouldn't be an error message here at all, certainly not such
a brief one.
>
Please use proper capitalization in your written English.
> + ) && ret=0
> ;;
> -esac
> +esac
>
> return ret
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] improve surfraw subcommands list
2021-03-01 15:23 ` Daniel Shahaf
@ 2021-03-11 18:08 ` Marc Chantreux
2021-03-20 1:35 ` Lawrence Velázquez
0 siblings, 1 reply; 6+ messages in thread
From: Marc Chantreux @ 2021-03-11 18:08 UTC (permalink / raw)
To: Daniel Shahaf; +Cc: Zsh Users
hello,
Daniel: thanks for the review. this is the new patch proposal.
> > + local -UT XDG_CONFIG_DIRS xcd
> Don't play golf. Name it «xdg_config_dirs».
done
> > + # as it starts with a space, the header becomes an empty
> > + # string removed by the list expansion
> What? Does "the header" mean the first line of the output?
the comment is now more clear about it.
> > - ${${${(f)"$(_call_program elvi surfraw -elvi)"}%%[[:space:]]##--*}%:*} && ret=0
> > + ${${(f)"$(surfraw -elvi)"}%%[[:space:]]*} $(
> Restore _call_program.
done
> > + awk '{keys[$1]=1} END {for (k in keys) print k}' \
> Use a parameter expansion rather than an external dependency and a fork,
> if possible. If there's a reason to make an exception, it's not clear
> to me.
done.
> > + ${XDG_CONFIG_HOME-${HOME?homeless}/.config}/surfraw/bookmarks(Nr) \
> > + ${HOME?homeless}/.surfraw.bookmarks(Nr)
> There shouldn't be an error message here at all, certainly not such
> a brief one.
I removed it.
So the new patch is below. thanks again.
regards
marc
diff --git a/Completion/Unix/Command/_surfraw b/Completion/Unix/Command/_surfraw
index f945f1ca9..4838f1e58 100644
--- a/Completion/Unix/Command/_surfraw
+++ b/Completion/Unix/Command/_surfraw
@@ -424,12 +424,30 @@ case $state in
yubnub)
_message -e command 'Yubnub Command'
;;
+ *)
+ _message -e string 'search string'
+ ;;
esac
;;
elvi)
- _wanted elvi expl elvi compadd \
- ${${${(f)"$(_call_program elvi surfraw -elvi)"}%%[[:space:]]##--*}%:*} && ret=0
+ local -UT XDG_CONFIG_DIRS xdg_config_dirs
+ local it
+ # list the applets
+ set -- ${${(f)"$(_call_program elvi surfraw -elvi)"}%%[[:space:]]##-- *}
+ shift # the first line is an header: remove it
+ # then list the bookmarks
+ for it in \
+ $^xdg_config_dirs/surfraw/bookmarks(Nr) \
+ /etc/xdg/surfraw/bookmarks(Nr) \
+ /etc/surfraw.bookmarks(Nr) \
+ ${XDG_CONFIG_HOME-$HOME/.config}/surfraw/bookmarks(Nr) \
+ $HOME/.surfraw.bookmarks(Nr)
+ do
+ read -d'\0' it < $it
+ set -- "$@" ${${(f)it}%%[[:space:]]*}
+ done
+ _wanted elvi expl elvi compadd "$@" && ret=0
;;
-esac
+esac
return ret
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] improve surfraw subcommands list
2021-03-11 18:08 ` Marc Chantreux
@ 2021-03-20 1:35 ` Lawrence Velázquez
2021-03-27 16:17 ` Lawrence Velázquez
0 siblings, 1 reply; 6+ messages in thread
From: Lawrence Velázquez @ 2021-03-20 1:35 UTC (permalink / raw)
To: zsh-users; +Cc: Marc Chantreux
On Thu, Mar 11, 2021, at 1:08 PM, Marc Chantreux wrote:
> So the new patch is below. thanks again.
ping
vq
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] improve surfraw subcommands list
2021-03-20 1:35 ` Lawrence Velázquez
@ 2021-03-27 16:17 ` Lawrence Velázquez
2021-04-03 15:59 ` Lawrence Velázquez
0 siblings, 1 reply; 6+ messages in thread
From: Lawrence Velázquez @ 2021-03-27 16:17 UTC (permalink / raw)
To: zsh-users; +Cc: Marc Chantreux
On Fri, Mar 19, 2021, at 9:35 PM, Lawrence Velázquez wrote:
> On Thu, Mar 11, 2021, at 1:08 PM, Marc Chantreux wrote:
>
> > So the new patch is below. thanks again.
>
> ping
Ping for Review 2: Electric Boogaloo
vq
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] improve surfraw subcommands list
2021-03-27 16:17 ` Lawrence Velázquez
@ 2021-04-03 15:59 ` Lawrence Velázquez
0 siblings, 0 replies; 6+ messages in thread
From: Lawrence Velázquez @ 2021-04-03 15:59 UTC (permalink / raw)
To: Oliver Kiddle; +Cc: zsh-users
On Sat, Mar 27, 2021, at 12:17 PM, Lawrence Velázquez wrote:
> On Fri, Mar 19, 2021, at 9:35 PM, Lawrence Velázquez wrote:
> > On Thu, Mar 11, 2021, at 1:08 PM, Marc Chantreux wrote:
> >
> > > So the new patch is below. thanks again.
> >
> > ping
>
> Ping for Review 2: Electric Boogaloo
Oliver, you applied the original patch from users/26557 instead of
the revised patch from users/26579, which accounted for Daniel's
feedback. Was that intentional?
vq
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-04-03 16:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-27 15:27 [PATCH] improve surfraw subcommands list Marc Chantreux
2021-03-01 15:23 ` Daniel Shahaf
2021-03-11 18:08 ` Marc Chantreux
2021-03-20 1:35 ` Lawrence Velázquez
2021-03-27 16:17 ` Lawrence Velázquez
2021-04-03 15:59 ` Lawrence Velázquez
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).