Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] improve surfraw subcommands list
- X-seq: zsh-users 26579
- From: Marc Chantreux <eiro@xxxxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: [PATCH] improve surfraw subcommands list
- Date: Thu, 11 Mar 2021 19:08:57 +0100
- Archived-at: <https://zsh.org/users/26579>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2021-03/YEpcucXK1jtJJLA2%40prometheus.u-strasbg.fr>
- Dkim-filter: OpenDKIM Filter v2.10.3 aurora-borealis.phear.org E2205FF33
- In-reply-to: <20210301152344.GA18578@tarpaulin.shahaf.local2>
- List-id: <zsh-users.zsh.org>
- References: <YDpk58wVLfg8EpHF@prometheus.u-strasbg.fr> <20210301152344.GA18578@tarpaulin.shahaf.local2>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author