@@ -72,8 +72,9 @@ The following functions are defined.
7272 append the ` ellipsis ` to the result.
7373* ` hash(content: Stringify) -> String ` :
7474 Hash the input and return a hexadecimal string representation of the digest.
75- * ` label(label: Stringify, content: Template) -> Template ` : Apply label to
76- the content. The ` label ` is evaluated as a space-separated string.
75+ * ` label(label: Stringify, content: Template) -> Template ` : Apply a custom
76+ [ color label] ( #color-labels ) to the content. The ` label ` is evaluated as a
77+ space-separated string.
7778* ` raw_escape_sequence(content: Template) -> Template ` : Preserves any escape
7879 sequences in ` content ` (i.e., bypasses sanitization) and strips labels.
7980 Note: This function is intended for escape sequences and as such, its output
@@ -621,20 +622,39 @@ The following methods are defined.
621622
622623## Color labels
623624
624- Template fragments are usually labeled with the command name, the context (or
625- the top-level object), and the method names. You can [ customize the output
626- colors] [ config-colors ] by using these labels.
625+ You can [ customize the output colors] [ config-colors ] by using color labels. ` jj `
626+ adds some labels automatically; they can also be added manually.
627627
628- For example, the following template is labeled as ` op_log operation id short ` :
628+ Template fragments are usually ** automatically** labeled with the command name,
629+ the context (or the top-level object), and the method names. For example, the
630+ following template is labeled as ` op_log operation id short ` automatically:
629631
630632``` sh
631633jj op log -T ' self.id().short()'
632634```
633635
634- In addition to that, you can insert arbitrary labels by ` label(label, content) `
635- function.
636+ The exact names of such labels are often straightforward, but are not currently
637+ documented. You can discover the actual label names used with the
638+ ` --color=debug ` option, e.g.
636639
637- To inspect how output fragments are labeled, use ` --color=debug ` option.
640+ ``` sh
641+ jj op log -T ' self.id().short()' --color=debug
642+ ```
643+
644+ Additionally, you can ** manually** insert arbitrary labels using the
645+ ` label(label, content) ` function. For example,
646+
647+ ``` sh
648+ jj op log -T ' "ID: " ++ self.id().short().substr(0, 1) ++ label("id short", "<redacted>")'
649+ ```
650+
651+ will print "ID:" in the default style, and the string ` <redacted> ` in the same
652+ style as the first character of the id. It would also be fine to use an
653+ arbitrary template instead of the string ` "<redacted>" ` , possibly including
654+ nested invocations of ` label() ` .
655+
656+ You are free to use custom label names as well. This will only have a visible
657+ effect if you also [ customize their colors] [ config-colors ] explicitly.
638658
639659[ config-colors ] : config.md#custom-colors-and-styles
640660
0 commit comments