zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Oliver Kiddle <okiddle@yahoo.co.uk>
Cc: zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH: _ps1234, _date_formats: Complete strftime formats for %D{}
Date: Mon, 6 Jul 2015 16:56:55 +0200	[thread overview]
Message-ID: <CAHYJk3TYDK5JNna_E2+EqdzJTkcoLwYgk1ZhW1D_qkZhLgDodw@mail.gmail.com> (raw)
In-Reply-To: <CAHYJk3S1Snh7gTwVrj9BeJ3T5T0u9gF=gxaDd8v1naeg5D7Yvw@mail.gmail.com>

On Mon, Jul 6, 2015 at 4:17 PM, Mikael Magnusson <mikachu@gmail.com> wrote:
> On Mon, Jul 6, 2015 at 1:11 PM, Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
>> Mikael Magnusson wrote:
>>>
>>> PS, my strftime(3) says it handles %E and %O, and it does work with date +%Ey,
>>> but zsh just prints the literal %Ey. Is it handled wrong by us or not
>>> by the libc like the manpage claims?
>>
>> Looking at the source, it seems only - is treated as a modifier.
>> It'd be nice for it to be updated if it can remain portable.
>>
>>> +  compset -P "*"
>>> +  _describe -t date-format-specifier 'date format specifier' '(%)' -S ''
>>
>> Using _describe to complete just % seems rather overkill. An _wanted
>> would do. However, it'd be better to use a prefix for the % and use
>> compset -P to cut off complete format specifiers or unrelated
>> characters. The patch below does that and adds a case statement to
>> select some OS specific additions.
>>
>> It'd perhaps be nice to complete format specifiers and modifiers with a
>> different tag and description.
>
> I don't know how most of the things you did work, but as far as I can
> tell it only breaks one thing; pressing tab after %5 now completes all
> modifiers instead of just putting in a . since %. is the only one that
> takes a numeric argument. %- is also handled internally by zsh for
> some modifiers, so it'll work on any OSTYPE as long as $1 is zsh.

Oh, I see I didn't read far enough in strftime(3), and only checked
behaviour in zsh, not date. This is fun too btw:

% print -P %D\{%10A\}
%10A
% print -P %D\{%9A\}
       %9A

I guess this code could use some overall touchups.

It looks like the order of modifiers matter, so for example %-Ey works
in date, but %E-y does not.

Ah, date has a similar bug:
% date +%5Ey
   15
% date +%-Ey
15
% date +%-5Ey
   15
% date +%5-Ey
  %5-Ey
(the string was already five characters, but it still added extra
padding, and didn't expand the number, and if it was expanded, there
should be one more space).

-- 
Mikael Magnusson


  reply	other threads:[~2015-07-06 14:57 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 [this message]
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
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=CAHYJk3TYDK5JNna_E2+EqdzJTkcoLwYgk1ZhW1D_qkZhLgDodw@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=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).