Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 --show-themes errs with Pattern not found (press RETURN) #587

Closed
vassudanagunta opened this issue May 4, 2021 · 16 comments · Fixed by #1611
Closed

🐛 --show-themes errs with Pattern not found (press RETURN) #587

vassudanagunta opened this issue May 4, 2021 · 16 comments · Fixed by #1611

Comments

@vassudanagunta
Copy link

vassudanagunta commented May 4, 2021

I'm invoking delta as follows:

git --no-pager diff SQUASHED^^^^ SQUASHED^^^ | delta --show-themes

This results in:

Screen Shot 2021-05-04 at 2 24 56 PM

If I press RETURN or any other key, it enters an empty pager.

raw `git diff`
git --no-pager diff SQUASHED^^^^ SQUASHED^^^ 

diff --git a/textplain/blockTreeParser.ts b/textplain/blockTreeParser.ts
index 9e2f3ac..228cac3 100644
--- a/textplain/blockTreeParser.ts
+++ b/textplain/blockTreeParser.ts
@@ -111,7 +111,7 @@ export class BlockTreeParser {
         this._parseFront = new ParseFront(src, this._irRoot)
     }
 
-    get currentContainer (): ir.Block {
+    get currentIRContainer (): ir.Block {
         return this._parseFront.curPContainer.irContainer
     }
 
@@ -127,7 +127,7 @@ export class BlockTreeParser {
             // uncomment and use this line to trigger the debugger at a certain line
             //if (this._parseFront.lineRemainingContent() === '- * * *\n') debugger
 
-            this.parseContainerContinuation()
+            this.parsePContainerContinuation()
 
             if (front.curLineResolved()) {
                 // continue
@@ -223,7 +223,7 @@ export class BlockTreeParser {
      * If lazy continuation is enabled, it sets `_curLazyContainer` as
      * appropriate.
      */
-    parseContainerContinuation (): void {
+    parsePContainerContinuation (): void {
         const line = this._parseFront.curLine
 
         // match (non-lazy) continuing containers
@@ -361,7 +361,7 @@ export class BlockTreeParser {
             console.log(`new chunk: style=${chunkStyle.name}  ire=${(chunkStyle.irNode.type)}`);
             (result.irBlock.source as ptss.Block).lineStart = firstLine.num;
             (result.irBlock.source as ptss.Block).lineEnd = result.endLine.num
-            appendBlockContent(this.currentContainer, result.irBlock)
+            appendBlockContent(this.currentIRContainer, result.irBlock)
         }
         if (result.irRef) {
             console.log('new ref:', result.irRef)
@@ -392,7 +392,7 @@ export class BlockTreeParser {
         console.log(`new container: style=${containerStyle.name}  ire=${containerStyle.irNode.type}`);
         (result.irBlock.source as ptss.Block).lineStart = firstLine.num;
         (result.irBlock.source as ptss.Block).lineEnd = result.endLine.num
-        appendBlockContent(this.currentContainer, result.irBlock)
+        appendBlockContent(this.currentIRContainer, result.irBlock)
 
         if (result.irRef) {
             console.log('new ref:', result.irRef)
@@ -548,7 +548,7 @@ export class BlockTreeParser {
 
         console.log(`contentIndent:${contentIndent} offset:${line.ptr}`)
 
-        let irList = this.currentContainer.lastBodyBlock
+        let irList = this.currentIRContainer.lastBodyBlock
         if (!irList || irList.type != 'list' || !ptss.continuesList(irList, listOrdered, bulletChar, delimiter)) {
             const ptList = new ptss.Block(listStyle)
             ptList.listBulletChar = bulletChar
@@ -566,7 +566,7 @@ export class BlockTreeParser {
             irList.hints['commonmark.list.tight'] = true
 
             console.log(`starting new List: ordered:${listOrdered} bullet:${bulletChar} delim:${delimiter} start:${startNum}`)
-            appendBlockContent(this.currentContainer, irList)
+            appendBlockContent(this.currentIRContainer, irList)
         } else {
             console.log('adding to existing list')
 
@@ -574,11 +574,11 @@ export class BlockTreeParser {
             //  as a full fledged container in the ContainerStack. If
             //  it were, this logic would be taken care of in the normal
             //  this._parseFront.appendBlockContent call.
-            if ((this.currentContainer.source as ptss.Block).lastLineBlank) {
+            if ((this.currentIRContainer.source as ptss.Block).lastLineBlank) {
                 console.log('  set commonmark.list.tight to FALSE for list starting on line',
-                    (this.currentContainer.source as ptss.Block).lineStart)
+                    (this.currentIRContainer.source as ptss.Block).lineStart)
                 irList.hints['commonmark.list.tight'] = false;
-                (this.currentContainer.source as ptss.Block).lastLineBlank = false
+                (this.currentIRContainer.source as ptss.Block).lastLineBlank = false
             }
         }
 
@@ -622,7 +622,7 @@ export class BlockTreeParser {
 
         (result.irBlock.source as ptss.Block).lineStart = firstLine.num;
         (result.irBlock.source as ptss.Block).lineEnd = result.endLine.num
-        appendBlockContent(this.currentContainer, result.irBlock)
+        appendBlockContent(this.currentIRContainer, result.irBlock)
 
         // mark line resolved
         front.curLineConsume()
@vassudanagunta
Copy link
Author

vassudanagunta commented May 4, 2021

Ok, I figured out that I should be using --show-syntax-themes to see the options for --syntax-theme, and that --show-themes shows configured features to be used with --features.

Suggestion (if my above understanding is correct): --show-themes should be --show-features, OR --features should be --theme.

@docwhat
Copy link

docwhat commented Aug 25, 2021

I agree. Using consistent terms would be very helpful.

@dandavison
Copy link
Owner

Hi @docwhat, @vassudanagunta I believe that the terminology is already consistent. It's explained here: https://github.com/dandavison/delta#custom-themes

A "theme" in delta is just a collection of settings grouped together in a named feature. One of the available settings is syntax-theme: this dictates the colors and styles that are applied to foreground text by the syntax highlighter. Thus the concept of "theme" in delta encompasses not just the foreground syntax-highlighting color theme, but also background colors, decorations such as boxes and under/overlines, etc.

--show-themes should be --show-features
--features should be --theme

No, "feature" is a more fine-grained concept than "theme": A theme specifies how to display everything including colors and various features such as line numbers. In contrast a feature is a single feature, such as "line-numbers". If one were to demo line numbers, what colors would you use?

Using consistent terms would be very helpful.

It is intended to be consistent. Please point out inconsistencies and I'll fix them. The definitions are

  • "syntax-theme": the choice of foreground text colors used for syntax highlighting
  • "theme" a specification of the values of all delta settings, including color choices (foreground and background) and decorations and which individual features are active
  • "feature" an individual feature such as side-by-side mode, which can be mixed and matched with other features.

I'll close this now because I don't think any of us are proposing further development tasks stemming from the discussion, but please do feel free to continue the discussion / suggest ways to clarify this.

@docwhat
Copy link

docwhat commented Aug 31, 2021

Ah-hah. The distinction between "syntax-theme" vs. "theme" is what was confusing. I had assumed they were the same.

Thanks for the explanation!

@dandavison
Copy link
Owner

Ah-hah. The distinction between "syntax-theme" vs. "theme" is what was confusing.

Yes, that totally fair, I knew that this would be a bit confusing, but I felt that it was necessary. What delta calls a "syntax-theme" is called a "theme" in bat. But bat doesn't add background (non-syntax) colors, so I felt that delta needed a word for the syntax colors, and also for the overall concept of foreground + background colors + decorations, and I felt that "theme" was the natural choice for the latter.

@jab
Copy link

jab commented Jan 17, 2024

I just found my way to this issue after trying the exact git show | delta --show-themes command suggested in the --help output, and getting the 'pattern not found' error:

❯ delta --help | fgrep -A 1 show-themes
      --show-themes
          Show example diff for available delta themes.
--
          A delta theme is a delta named feature (see --features) that sets either `light` or `dark`. See https://github.com/dandavison/delta#custom-color-themes. If diff output is supplied on standard input then this will be used for the demo. For example: `git show | delta --show-themes`. By default shows dark or light themes only, according to whether delta is in dark or light mode (as set by the user or inferred from BAT_THEME). To control the themes shown, use --dark or --light, or both, on the command line together with this option.

❯ git show | delta --show-themes
Pattern not found  (press RETURN)

❯ git --no-pager show | head -n 15  # just to prove delta got valid diff output:
commit 9b2ad400f8af82635289bf9f5a9990588b7f1326
Author: Joshua Bronson <[email protected]>
Date:   Tue Jan 16 11:16:10 2024 -0500

    hello mypyc

diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml
index 605f909..bb06220 100644
--- a/.github/workflows/benchmark.yml
+++ b/.github/workflows/benchmark.yml
@@ -44,6 +44,9 @@ jobs:
       - name: install the version of bidict to benchmark
         run: |
           git checkout ${{ github.event.inputs.ref || github.sha }}
+          pip install mypy[mypyc]

I am aware of --show-syntax-themes, but am interested in showing themes, not syntax themes. What am I doing wrong?

@dandavison
Copy link
Owner

Hi @jab. "Pattern not found" is a less error I believe. Do you have it pre-seeded to look for a certain rgexp? Can you check your $LESS and env | grep PAGER and try things like git show | LESS= delta --show-themes?

@jab
Copy link

jab commented Jan 18, 2024

LESS and PAGER are unset:

jab@jabmbp bidict % echo $LESS

jab@jabmbp bidict % echo $PAGER

jab@jabmbp bidict % git show | LESS= delta --show-themes
Pattern not found  (press RETURN)

Both with less resolving to /usr/bin/less on latest macOS (less 581.2 (POSIX regular expressions)) as well as latest less from Nix unstable (less 643 (PCRE2 regular expressions)).

@jab
Copy link

jab commented Jan 18, 2024

Also reproduces with PAGER set to more and vimpager.

@dandavison
Copy link
Owner

Hm, it is working for me. I do suspect this is something in your environment.

@georgevreilly
Copy link

I'm seeing the same Pattern not found on macOS 14.2.1 for delta --show-themes. Reproes in iTerm2 3.4.23 and in Terminal.

❯ env | grep -iE '(less|pager|bat|delta)'
# nothing

@dandavison
Copy link
Owner

What delta versions are you using? @georgevreilly is it occuring only when you pipe content into delta --show-themes?

@georgevreilly
Copy link

I'm using version 0.16.5, installed by Homebrew. The problem occurs without any pipes. That's how I originally discovered it.

@dandavison
Copy link
Owner

Ah, right. It's occurring because you don't have any themes loaded. You need to include the themes via your gitconfig; see https://dandavison.github.io/delta/custom-themes.html

I'll re-open this to fix that output.

@georgevreilly
Copy link

My ~/.gitconfig already had a [delta] section.

[delta]
    plus-color = "#012800"
    minus-color = "#340001"
    # syntax-theme = Coldark-Dark
    syntax-theme = ansi
    line-numbers = true
    features = collared-trogon

but there was no [include] in my ~/.gitconfig. Adding one fixes the problem.

[include]
    path = /Users/georgevreilly/.config/delta/themes.gitconfig

(I already had themes.gitconfig and I updated it today.)

What are plus-color and minus-color? They've been in my [delta] section of ~/.gitconfig for a couple of years, but I can't find mention of them in the documentation. Were they present in earlier versions of Delta, or did I misread something a while back?

@dandavison
Copy link
Owner

Great. plus-color and minus-color went through a "deprecation period" for a year or so (at least in my mind, and for anyone paying attention to delta's help text!) and are no longer supported: they are now plus-style and minus-style.

Incidentally, I think there's a little flaw in the show-themes logic. I believe it's only listing themes that specify the light or dark key. Perhaps all themes should do that, but I believe this issue is causing show-themes not to show all themes. If anyone feels like a bit of Rust development, do feel free to jump in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants