zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH: _ps1234, _date_formats: Complete strftime formats for %D{}
Date: Thu, 09 Jul 2015 17:20:11 +0200	[thread overview]
Message-ID: <24602.1436455211@thecus.kiddle.eu> (raw)
In-Reply-To: <CAHYJk3QtTSZTQKerhj2HWofSPsVvR1dxBc7L8npDVz+EgxD-ww@mail.gmail.com>

Mikael Magnusson wrote:
> PS1='%(<tab> no longer tells me "--- number", how is this an
> improvement? It now completes delimiters after PS1='%(3<tab> which I
> would also not consider an improvement :).

I never realised the numbers were also allowed after the (. I've always
had them before.

> There doesn't seem to be a way to get back to completing anything
> after print -P %D\\\{ (pressing tab at this point just deletes two
> backslashes for me, and typing more things does nothing). It's
> probably not a common thing to do though, so if it's complicated then
> don't worry about it on my account.

That wasn't too complicated.

> Let's hope nobody ever tries to use print -rP.

Completing for PS1 is just the same. If you really want to fix this,
check $service, set a variable to (\\|)  and use it with the ~ flag.

Oliver

diff --git a/Completion/Zsh/Type/_ps1234 b/Completion/Zsh/Type/_ps1234
index 8d3c5d8..f182a16 100644
--- a/Completion/Zsh/Type/_ps1234
+++ b/Completion/Zsh/Type/_ps1234
@@ -3,9 +3,7 @@
 local -a specs
 local expl bs suf pre changed=1 ret=1
 
-if [[ -z $compstate[quote] ]]; then
-  bs='\' # in patterns we use (\\|) widely as print -P handles backslashes first
-fi
+[[ -z $compstate[quote] ]] && bs='\'
 
 # first strip off any complete prompt specifications leaving only the
 # current, incomplete, one
@@ -14,10 +12,10 @@ while (( changed )); do
   compset -P '%[DFK](\\|){[^}]#}' && changed=1 # formats with arg: %x{...}
   compset -P '%[0-9-\\]#[^DFK(0-9-<>\\\[]' && changed=1 # normal formats
   compset -P '%[0-9-\\]#(<[^<]#<|>[^>]#>|\[[^\]]#\])' && changed=1 # truncations
-  compset -P '%[0-9-\\]#(\\|)\(??|[^%]' && changed=1 # start of ternary
+  compset -P '%[0-9-\\]#(\\|)\([0-9-]#[^0-9-]?|[^%]' && changed=1 # start of ternary
   compset -P '[^%]##' && changed=1 # sundry other characters
   # %D/%F/%K without a following { ... }
-  [[ $PREFIX = %(-|)<->#[DFK](\\|)[^{\\]* ]] &&
+  [[ $PREFIX = %(-|)<->#[DFK](\\[^{]|[^{\\])* ]] &&
       compset -P '%[0-9\\-]#[DFK]' && changed=1
 done
 [[ $PREFIX = %(-|)<->[FK](#e) ]] && compset -P '*' # F/K with number
@@ -45,12 +43,12 @@ if compset -P '%[FK]'; then
   fi
 fi
 
-if compset -P '%[0-9-\\]#\(?'; then
+if compset -P '%[0-9-\\]#(\\|)\([0-9-]#[^0-9-]'; then
   compset -S '*'
   _delimiters && ret=0
 elif compset -P '%[0-9-\\]#[<>\]]'; then
   _message -e replacements 'replacement string'
-elif compset -P '%[0-9-\\]#(\\|)\('; then
+elif compset -P '%[0-9-\\]#(\\|)\([0-9-]#'; then
   compset -S '[.:+/-%]*' || suf=( -S . )
   compset -S '*'
   specs=(
@@ -76,7 +74,9 @@ elif compset -P '%[0-9-\\]#(\\|)\('; then
     'V:element n of psvar is set and non-empty'
     'w:day of week (Sunday = 0)'
   )
-  _describe -t ternary-prompt-expressions 'ternary prompt format test character' specs $suf && ret=0
+  [[ $IPREFIX != *- ]] && _describe -t ternary-prompt-expressions \
+      'ternary prompt format test character' specs $suf && ret=0
+  _message -e numbers number
 elif compset -P '%D(\\|){'; then
   compset -S '(\\|)}*'
   _date_formats zsh && ret=0
@@ -150,8 +150,7 @@ then
   fi
   _describe -t prompt-format-specifiers 'prompt format specifier' \
       specs -S '' $pre && ret=0
-  (( ! $#pre )) && [[ -prefix '(-|)<->' ]] &&
-      _message -e prompt-format-specifiers number
+  (( ! $#pre )) && _message -e prompt-format-specifiers number
 fi
 
 return ret


  reply	other threads:[~2015-07-09 15:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06  0:36 Mikael Magnusson
2015-07-06 11:11 ` Oliver Kiddle
2015-07-06 14:17   ` Mikael Magnusson
2015-07-06 14:56     ` Mikael Magnusson
2015-07-08 14:02   ` Jun T.
2015-07-08 14:42     ` Mikael Magnusson
2015-07-09 12:17       ` Oliver Kiddle
2015-07-09 13:25         ` Mikael Magnusson
2015-07-09 13:53         ` Mikael Magnusson
2015-07-09 15:20           ` Oliver Kiddle [this message]
2015-07-09 23:02             ` Oliver Kiddle
2015-07-09 12:22     ` Oliver Kiddle

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=24602.1436455211@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --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).