git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] pretty: support placeholders %C+ and %C-

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Sep 21, 2012, 08:36 UTC
Message-ID
<CACsJy8Azsg_EQvnm0L4AyZbnaDPcjtrr_+8u5eOAGjKFg9BBRQ@mail.gmail.com>
In-Reply-To
<7vehlwbn76.fsf@alter.siamese.dyndns.org>
On Fri, Sep 21, 2012 at 12:47 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
>>> +- '%C+': enable coloring on the following placeholders if supported
>>> +- '%C-': disable coloring on the following placeholders
>>
>> OK, so typically you replace some format placeholder "%?" in your
>> format string with "%C+%?%C-", because you cannot get away with
>> replacing it with "%C+%? and other things in the format you do not
>> know if they support coloring%C-".
>>
>> If that is the case, does it really make sense to have %C-?

"%C+%?" should work. if %? does not support coloring, the %C+ effect is simply ignored. In my use case, I don' really use %C- because I always want color wherever possible. Though I suspect a user might want to turn off coloring for certain part of the format string.

Replacing every %? with %C+%?%C- is really annoying in my "always color" case..
>> It smells as if it makes more sense to make _all_ %? placeholder
>> reset the effect of %C+ after they are done (even the ones that they
>> themselves do not color their own output elements), so that you can
>> mechanically replace "%?" with "%C+%?".

.. or even "%C+%?". My format string would become "%C+%h %C+%s%C+%d", much harder to read.

Show 6 quoted lines
> Thinking about this a bit more, perhaps we would want a generic
> mechanism to give parameters to various %? placeholders. This is not
> limited to "I can do color but there is no mechanism for the user to
> tell me that I should do color" %H, %h and %d may want to say.  An
> obvious and immediate example is that %h might want to be told how
> many hexdigits it should use.
Yeah that'd be nice. We already use %?(..) for %C. Maybe we can generalize that.

Still I'd like a way to define attributes for a group of placeholders instead of just individuals. Continuing with the %?(...) syntax above for specifying attributes for a specific placeholder, %(...) may be used to specify global attributes that affect all following placeholders until another %(...) stops the effect, or %?(...) overrides it.

-- 
Duy
Previous: Junio C Hamano
Message 21 of 21 in “log --oneline: put decoration at the end of the line”
  1. log --oneline: put decoration at the end of the lineNguyễn Thái Ngọc Duy, Sep 19, 2012
  2. Jeff KingSep 19, 2012
  3. Junio C HamanoSep 19, 2012
  4. Jeff KingSep 19, 2012
  5. Junio C HamanoSep 19, 2012
  6. Jeff KingSep 19, 2012
  7. Junio C HamanoSep 20, 2012
  8. Nguyen Thai Ngoc DuySep 20, 2012
  9. 0/2 New pretty format color specifiers %C+ and %C-Nguyễn Thái Ngọc Duy, Sep 20, 2012
  10. 1/2 pretty: share code between format_decoration and show_decorationsNguyễn Thái Ngọc Duy, Sep 20, 2012
  11. 2/2 pretty: support placeholders %C+ and %C-Nguyễn Thái Ngọc Duy, Sep 20, 2012
  12. Nguyen Thai Ngoc DuySep 20, 2012
  13. Junio C HamanoSep 20, 2012
  14. Nguyen Thai Ngoc DuySep 21, 2012
  15. Junio C HamanoSep 21, 2012
  16. Junio C HamanoSep 23, 2012
  17. Jeff KingSep 25, 2012
  18. Nguyen Thai Ngoc DuySep 21, 2012
  19. Junio C HamanoSep 20, 2012
  20. Junio C HamanoSep 20, 2012
  21. Nguyen Thai Ngoc DuySep 21, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.