zsh-workers
 help / color / mirror / code / Atom feed
From: Marc Chantreux <eiro@phear.org>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: 2 new patches for _surfraw
Date: Fri, 9 Apr 2021 21:49:52 +0200	[thread overview]
Message-ID: <YHCv4PKK/2ah9s32@prometheus.u-strasbg.fr> (raw)

[-- Attachment #1: Type: text/plain, Size: 115 bytes --]

hello people,

here are

* one comply to good practices
* one bugfix

any review is warmly welcome.

regards,
marc

[-- Attachment #2: 0001-pluralize-tags-in-_surfraw.patch --]
[-- Type: text/x-diff, Size: 3499 bytes --]

From d6acd1c9bb02d77d5102f7319c327e9aec702e2f Mon Sep 17 00:00:00 2001
From: Marc Chantreux <eiro@phear.org>
Date: Fri, 9 Apr 2021 21:44:54 +0200
Subject: [PATCH 1/2] pluralize tags in _surfraw

---
 Completion/Unix/Command/_surfraw | 44 +++++++++++++++++---------------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/Completion/Unix/Command/_surfraw b/Completion/Unix/Command/_surfraw
index 343d275cc..09852475e 100644
--- a/Completion/Unix/Command/_surfraw
+++ b/Completion/Unix/Command/_surfraw
@@ -20,11 +20,11 @@ case $state in
   subcmd)
     args=(
       '-help[display help information]'
-      '*:string:_guard "^-*" "search string"'
+      '*:strings:_guard "^-*" "search string"'
     )
     case "$words[1]" in
       ask|cia|cnn|deblogs|excite|filesearching|foldoc|happypenguin|slashdot|slinuxdoc|sundocs|sunsolve|xxx)
-        _message -e string 'search string'
+        _message -e strings 'search string'
       ;;
       alioth)
         _arguments $args \
@@ -164,7 +164,7 @@ case $state in
           '-doc[view PTS documentation]' && ret=0
       ;;
       debsec)
-        _message -e string 'package name, bug number or CVE ID'
+        _message -e strings 'package name, bug number or CVE ID'
       ;; 
       deja)
         _arguments $args \
@@ -261,9 +261,9 @@ case $state in
           '-head=:display headlines:(on off)' \
           '-grid=:show results in grid:(on off)' \
           '-spell=:spelling tolerance:(off standard force)' \
-          '*:dictionary word:->dictword' && ret=0
+          '*:dictionary word:->words' && ret=0
 
-        [[ "$state" = dictword ]] && _wanted words expl 'dictionary word' \
+        [[ "$state" = words ]] && _wanted words expl 'dictionary word' \
             compadd $(look "${PREFIX}") && ret=0
       ;;
       netbsd|openbsd)
@@ -422,27 +422,31 @@ case $state in
           '-results=-[specify number of results to return]:number' && ret=0
       ;;
       yubnub)
-        _message -e command 'Yubnub Command'
+        _message -e commands 'Yubnub Command'
       ;;
       *)
-        _message -e string 'search string'
+        _message -e strings '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)"$(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
+    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
 
-- 
2.30.2


[-- Attachment #3: 0002-fix-ebay-completion-bug-due-to-tailing-space.patch --]
[-- Type: text/x-diff, Size: 1385 bytes --]

From 210a35e9512d3add59774c3012c4ebc241411e55 Mon Sep 17 00:00:00 2001
From: Marc Chantreux <eiro@phear.org>
Date: Fri, 9 Apr 2021 21:45:40 +0200
Subject: [PATCH 2/2] fix ebay completion bug due to tailing space

also removing all the other extra spaces
---
 Completion/Unix/Command/_surfraw | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Completion/Unix/Command/_surfraw b/Completion/Unix/Command/_surfraw
index 09852475e..81f8d635f 100644
--- a/Completion/Unix/Command/_surfraw
+++ b/Completion/Unix/Command/_surfraw
@@ -165,7 +165,7 @@ case $state in
       ;;
       debsec)
         _message -e strings 'package name, bug number or CVE ID'
-      ;; 
+      ;;
       deja)
         _arguments $args \
           '-results=-:[number of results to return]' \
@@ -183,7 +183,7 @@ case $state in
       ;;
       ebay)
         _arguments $args \
-          '-country=-:country:(com de uk fr)' \ 
+          '-country=-:country:(com de uk fr)' \
           '-results=-:[number of results to return]:number' && ret=0
       ;;
       etym)
@@ -233,7 +233,7 @@ case $state in
 	  '-title[search titles (default)]'
 	  '-author[search authors]'
 	  '-num[search etext numbers]'
-      ;;       
+      ;;
       imdb)
         _arguments $args \
           '-category=-:category:(All Titles MyMovies People Characters Quotes Bios Plots)' && ret=0
-- 
2.30.2


             reply	other threads:[~2021-04-09 19:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09 19:49 Marc Chantreux [this message]
2021-04-09 21:53 ` Oliver Kiddle
2021-04-09 23:10   ` Daniel Shahaf
2021-04-10  0:05     ` Oliver Kiddle
2021-04-10  8:38   ` Marc Chantreux
2021-04-11 20:23     ` Oliver Kiddle
2021-04-12  8:23       ` Marc Chantreux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YHCv4PKK/2ah9s32@prometheus.u-strasbg.fr \
    --to=eiro@phear.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).