git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Karthik Nayak <karthik.188@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jacob Keller <jacob.keller@gmail.com>,
	Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
	Eric Sunshine <sunshine@sunshineco.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>,
	"christian.couder@gmail.com" <christian.couder@gmail.com>
Subject: Re: [RFC/PATCH 02/11] ref-filter: add 'colornext' atom
Date: Sat, 1 Aug 2015 18:36:08 +0530	[thread overview]
Message-ID: <CAOLa=ZQbH274PnydmvDQv77QCOQEPfVKViKkh0iEOMcpQ-PcMQ@mail.gmail.com> (raw)
In-Reply-To: <xmqqsi857h8d.fsf@gitster.dls.corp.google.com>

On Thu, Jul 30, 2015 at 9:47 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Jacob Keller <jacob.keller@gmail.com> writes:
>
>> On Wed, Jul 29, 2015 at 2:30 PM, Matthieu Moy
>> <Matthieu.Moy@grenoble-inp.fr> wrote:
>>> Eric Sunshine <sunshine@sunshineco.com> writes:
>>>
>>>> Also, please explain here and in the commit message why this highly
>>>> specialized colorizer ('colornext'), is needed even though a more
>>>> general purpose one ('color') is already available.
>>>
>>> It is needed in the current form to allow
>>> %(colornext:blue)%(ifexists:[%s]) to color only the replacement of %s
>>> and not the [].
>>>
>>> But I now think that this would be more elegantly solved by Junio's
>>> %(if) %(endif) idea:
>>>
>>>   %(if:atom) [ %(color:blue)%(atom)%(color:reset) ] %(endif)
>>>
>>> (I added spaces for clarity)
>>
>> I agree, this style seems a lot more elegant and expressive while much
>> easier to understand. Same for doing this to the alignment atoms and
>> such as it solves the same problem(s) there.
>
> Do you mean something like these?
>
>     %(align:left,20) branch %(refname:short) %(end)
>     %(align:middle,20) branch %(refname:short) %(end)
>     %(align:right,20) branch %(refname:short) %(end)
>
> to replace and enhance %(padright:20)?
>
>> I can't speak to how easy it is to implement tho.
>
> Perhaps it would go like this:
>
>  * Instead of always emitting to the standard output, emit() and
>    print_value() will gain an option to append into a strbuf that is
>    passed as argument.  Alternatively, appending to strbuf could be
>    made the only output channel for them; show_ref_array_item() can
>    prepare an empty strbuf, call them repeatedly to fill it, and
>    then print the resulting strbuf itself.
>
>  * Things like %(if) and %(align) would do the following:
>
>    (1) Push the currently active strbuf it got from the calling
>        show_ref_array_item() to the formatting state;
>
>    (2) Create a new strbuf and arrange so that further output would
>        be diverted to this new one; and
>
>    (3) Push the fact that the diverted output will be processed by
>        them (i.e. %(if), %(align), etc.) when the diversion finishes
>        to the formatting state.
>
>  * When %(end) is seen, the currently active strbuf (i.e. the new
>    one created in (2) above for diversion) holds the output made
>    since the previously seen %(if), %(align), etc.  The formatting
>    state knows what processing needs to be performed on that from
>    (3) above.
>
>    - Pop the strbuf where the output of the entire %(if)...%(end)
>      construct needs to go from the formatting state;
>
>    - Have the processing popped from (3) above, e.g. %(if:atom) or
>      %(align:left,20), do whatever they need to do on the diverted
>      output, and emit their result.
>
> Both %(if) and the hypotherical %(align) can use this same
> "diversion" mechanism.  And the above would properly nest,
> e.g.
>
>     %(align:middle,40)%(if:taggerdate)tag %(end)%(refname:short)%(end)
>

This actually looks neat and good, I'll try implementing this :)

-- 
Regards,
Karthik Nayak

  reply	other threads:[~2015-08-01 13:06 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-28  6:55 [RFC/PATCH] Port branch.c to use ref-filter APIs Karthik Nayak
2015-07-28  6:56 ` [RFC/PATCH 01/11] ref-filter: add "%(objectname:size=X)" option Karthik Nayak
2015-07-28  6:56   ` [RFC/PATCH 02/11] ref-filter: add 'colornext' atom Karthik Nayak
2015-07-28  8:45     ` Matthieu Moy
2015-07-28 16:03       ` Karthik Nayak
2015-07-28  9:13     ` Christian Couder
2015-07-28 16:04       ` Karthik Nayak
2015-07-29 20:10     ` Eric Sunshine
2015-07-29 21:30       ` Matthieu Moy
2015-07-30  4:27         ` Jacob Keller
2015-07-30 16:17           ` Junio C Hamano
2015-08-01 13:06             ` Karthik Nayak [this message]
2015-07-28  6:56   ` [RFC/PATCH 03/11] ref-filter: add option to filter only branches Karthik Nayak
2015-07-28 13:38     ` Matthieu Moy
2015-07-28 16:42       ` Karthik Nayak
2015-07-28  6:56   ` [RFC/PATCH 04/11] ref-filter: add 'ifexists' atom Karthik Nayak
2015-07-28  7:54     ` Jacob Keller
2015-07-28 16:47       ` Karthik Nayak
2015-07-28  8:50     ` Matthieu Moy
2015-07-28 17:39       ` Karthik Nayak
2015-07-28 17:57     ` Junio C Hamano
2015-07-29 17:48       ` Karthik Nayak
2015-07-29 18:00         ` Junio C Hamano
2015-07-29 18:56           ` Junio C Hamano
2015-07-29 21:21             ` Matthieu Moy
2015-07-29 22:05               ` Junio C Hamano
2015-08-01  6:46               ` Karthik Nayak
2015-08-01  7:05                 ` Jacob Keller
2015-08-01  6:44           ` Karthik Nayak
2015-07-28  6:56   ` [RFC/PATCH 05/11] branch: fix width computation Karthik Nayak
2015-07-28  9:47     ` Matthieu Moy
2015-07-28 18:16       ` Karthik Nayak
2015-07-28  6:56   ` [RFC/PATCH 06/11] branch: roll show_detached HEAD into regular ref_list Karthik Nayak
2015-07-28 13:01     ` Matthieu Moy
2015-07-28 19:19       ` Karthik Nayak
2015-07-29  9:56         ` Matthieu Moy
2015-07-29 17:54           ` Karthik Nayak
2015-07-28  6:56   ` [RFC/PATCH 07/11] branch: move 'current' check down to the presentation layer Karthik Nayak
2015-07-28 13:09     ` Matthieu Moy
2015-07-28 20:12       ` Karthik Nayak
2015-07-29  0:46         ` Jacob Keller
2015-07-29 18:44           ` Karthik Nayak
2015-07-29 10:01         ` Matthieu Moy
2015-07-29 18:52           ` Karthik Nayak
2015-07-29 21:27             ` Matthieu Moy
2015-08-01  6:48               ` Karthik Nayak
2015-08-01  7:06                 ` Jacob Keller
2015-08-01  9:03                 ` Eric Sunshine
2015-08-02 12:59                   ` Karthik Nayak
2015-08-02 17:58                     ` Junio C Hamano
2015-07-28  6:56   ` [RFC/PATCH 08/11] branch: drop non-commit error reporting Karthik Nayak
2015-07-28  6:56   ` [RFC/PATCH 09/11] branch.c: use 'ref-filter' data structures Karthik Nayak
2015-07-28  8:17     ` Christian Couder
2015-07-28 13:48       ` Matthieu Moy
2015-07-28 20:41         ` Karthik Nayak
2015-07-29 10:08           ` Matthieu Moy
2015-07-29 19:38             ` Karthik Nayak
2015-07-28 20:38       ` Karthik Nayak
2015-07-28  8:22     ` Christian Couder
2015-07-28 20:31       ` Karthik Nayak
2015-07-28  8:42   ` [RFC/PATCH 01/11] ref-filter: add "%(objectname:size=X)" option Matthieu Moy
2015-07-28 15:54     ` Karthik Nayak
2015-07-28 15:43   ` Junio C Hamano
2015-07-28 15:55     ` Karthik Nayak
2015-07-28 16:19   ` Junio C Hamano
2015-07-29 16:02     ` Karthik Nayak
2015-07-28  7:11 ` [RFC/PATCH 10/11] branch.c: use 'ref-filter' APIs Karthik Nayak
2015-07-28  7:57   ` Jacob Keller
2015-07-29  3:46     ` Karthik Nayak
2015-07-28  8:09   ` Christian Couder
2015-07-29  3:48     ` Karthik Nayak
2015-07-28 14:17   ` Matthieu Moy
2015-07-29 15:32     ` Karthik Nayak
2015-07-29 15:46       ` Matthieu Moy
2015-07-29 15:37     ` Karthik Nayak
2015-07-29 15:56       ` Matthieu Moy
2015-07-30  6:37         ` Karthik Nayak
2015-07-30  7:29           ` Matthieu Moy
2015-08-03 10:20             ` Karthik Nayak
2015-08-19 15:49               ` Matthieu Moy
2015-08-19 15:52                 ` Karthik Nayak
2015-07-28  7:11 ` [RFC/PATCH 11/11] branch: add '--points-at' option Karthik Nayak
2015-07-28  7:46   ` Jacob Keller
2015-07-29 15:44     ` Karthik Nayak
2015-07-28 13:35 ` [RFC/PATCH] Port branch.c to use ref-filter APIs Matthieu Moy
2015-07-28 15:48   ` Karthik Nayak
2015-07-28 17:53     ` Matthieu Moy
2015-07-29 15:54       ` Karthik Nayak

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to='CAOLa=ZQbH274PnydmvDQv77QCOQEPfVKViKkh0iEOMcpQ-PcMQ@mail.gmail.com' \
    --to=karthik.188@gmail.com \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jacob.keller@gmail.com \
    --cc=sunshine@sunshineco.com \
    /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://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).