jdtsmith / indent-bars

Fast, configurable indentation guide-bars for Emacs
GNU General Public License v3.0
340 stars 13 forks source link

Screenshot showing configuration matching `prism-whitespace-mode` #64

Closed alphapapa closed 3 days ago

alphapapa commented 4 days ago

Hi JD,

indent-bars has been very helpful to me recently while working on some big YAML files. I thought I'd share a screenshot showing how I configured it to use the faces matching prism-whitespace-mode. This is using Prot's ef-eagle theme.

indent-bars--prism-whitespace-mode--ef-eagle

Some people may decry the "fruit salad," and most of the time I only use a cycle of 3-4 colors, but with this many levels of indentation, sometimes more colors actually helps.

Thanks for your work!

jdtsmith commented 4 days ago

Thanks for sharing, Adam, looks very nice, and cool how text and bar colors coordinate. BTW, since all your faces are named similarly, you could have gotten away with the simpler :regexp "prism-level-\\([0-9]+\\)".

The next level of the game would be to try yaml-ts-mode, and configure some tree-sitter scope node types, so that (here) only the one containing "block" would be emphasized, the rest could be more subtle (or monochrome, or anything really). That said, for repetitive files like this, I kind of like the bars everywhere.

Random question: is yours a Cairo build?

jdtsmith commented 3 days ago

Added this to the examples page.

alphapapa commented 3 days ago

Thanks for sharing, Adam, looks very nice, and cool how text and bar colors coordinate. BTW, since all your faces are named similarly, you could have gotten away with the simpler :regexp "prism-level-\\([0-9]+\\)".

Ah, that's great, thanks.

The next level of the game would be to try yaml-ts-mode, and configure some tree-sitter scope node types, so that (here) only the one containing "block" would be emphasized, the rest could be more subtle (or monochrome, or anything really). That said, for repetitive files like this, I kind of like the bars everywhere.

Hm, ok, I haven't really gotten into tree-sitter yet. I feel like I want to wait until it settles down a bit. :)

Random question: is yours a Cairo build?

Yes, as far as I know. I use Guix for Emacs, and cairo-version-string is "1.18.0".

Added this to the examples page.

Cool. Would you prefer me to update the screenshot to show the regexp-based face selection?

jdtsmith commented 3 days ago

Thanks for sharing, Adam, looks very nice, and cool how text and bar colors coordinate. BTW, since all your faces are named similarly, you could have gotten away with the simpler :regexp "prism-level-\\([0-9]+\\)".

Ah, that's great, thanks.

With the usual proviso that customize handles escaping and quoting for you (which honestly is confusing to newcomers who mix Customize and traditional elisp config).

The next level of the game would be to try yaml-ts-mode, and configure some tree-sitter scope node types, so that (here) only the one containing "block" would be emphasized, the rest could be more subtle (or monochrome, or anything really). That said, for repetitive files like this, I kind of like the bars everywhere.

Hm, ok, I haven't really gotten into tree-sitter yet. I feel like I want to wait until it settles down a bit. :)

It definitely adds an extra layer, but certain TS-enabled things are indispensable to me now, including precision indenting (with combobulate) and structure navigation.

Random question: is yours a Cairo build?

Yes, as far as I know. I use Guix for Emacs, and cairo-version-string is "1.18.0".

OK, marking you down as someone for whom Cairo supports stipples (assuming emacs-version mentions it). It seems to be random whether a Cairo build supports it or not (even identical builds). Some anecdotal evidence suggests that building --with-cairo inhibits stipple (vs. using the defaults, which includes Cairo).

Added this to the examples page.

Cool. Would you prefer me to update the screenshot to show the regexp-based face selection?

Either way, happy to update if so.

alphapapa commented 3 days ago

Thanks for sharing, Adam, looks very nice, and cool how text and bar colors coordinate. BTW, since all your faces are named similarly, you could have gotten away with the simpler :regexp "prism-level-\\([0-9]+\\)".

Ah, that's great, thanks.

With the usual proviso that customize handles escaping and quoting for you (which honestly is confusing to newcomers who mix Customize and traditional elisp config).

Indeed.

The next level of the game would be to try yaml-ts-mode, and configure some tree-sitter scope node types, so that (here) only the one containing "block" would be emphasized, the rest could be more subtle (or monochrome, or anything really). That said, for repetitive files like this, I kind of like the bars everywhere.

Hm, ok, I haven't really gotten into tree-sitter yet. I feel like I want to wait until it settles down a bit. :)

It definitely adds an extra layer, but certain TS-enabled things are indispensable to me now, including precision indenting (with combobulate) and structure navigation.

I still need to try Combobulate...

Random question: is yours a Cairo build?

Yes, as far as I know. I use Guix for Emacs, and cairo-version-string is "1.18.0".

OK, marking you down as someone for whom Cairo supports stipples (assuming emacs-version mentions it). It seems to be random whether a Cairo build supports it or not (even identical builds). Some anecdotal evidence suggests that building --with-cairo inhibits stipple (vs. using the defaults, which includes Cairo).

My emacs-version shows: GNU Emacs 29.4 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0)

Added this to the examples page.

Cool. Would you prefer me to update the screenshot to show the regexp-based face selection?

Either way, happy to update if so.

I just tried to use the regexp, but I got this backtrace, because prism isn't configured on my system to have as many faces as indent-bars is looking for:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-to-number(nil)
  #f(compiled-function (x) #<bytecode 0x11388bfeb4760bd7>)(prism-level-15)
  mapcar(#f(compiled-function (x) #<bytecode 0x11388bfeb4760bd7>) (indent-bars-9 indent-bars-8 indent-bars-current-face indent-bars-face indent-bars-7 indent-bars-6 indent-bars-5 indent-bars-4 indent-bars-3 indent-bars-2 indent-bars-1 yaml-tab-face sh-escaped-newline sh-quoted-exec sh-heredoc treesit-explorer-field-name treesit-explorer-anonymous-node scrollkeeper-guideline-underline scrollkeeper-guideline-thinline ffap log-view-commit-body log-view-message log-view-file shortdoc-section shortdoc-heading emoji-with-derivations emoji emoji-list-header textsec-suspicious ement-room-list-very-recent ement-room-list-recent ement-room-list-unread ement-room-list-space ement-room-list-name ement-room-list-low-priority ement-room-list-left ement-room-list-invited ement-room-list-favourite ement-room-list-direct ement--font-lock-constant-face ement-tabulated-room-list-very-recent ement-tabulated-room-list-recent ement-tabulated-room-list-low-priority ement-tabulated-room-list-favourite ement-tabulated-room-list-unread ement-tabulated-room-list-left ement-tabulated-room-list-invited ement-tabulated-room-list-direct ement-tabulated-room-list-name flyspell-duplicate ...))
  #f(compiled-function #'sequence #<bytecode 0x18577d7a4f75ceb4>)(#f(compiled-function (x) #<bytecode 0x11388bfeb4760bd7>) (indent-bars-9 indent-bars-8 indent-bars-current-face indent-bars-face indent-bars-7 indent-bars-6 indent-bars-5 indent-bars-4 indent-bars-3 indent-bars-2 indent-bars-1 yaml-tab-face sh-escaped-newline sh-quoted-exec sh-heredoc treesit-explorer-field-name treesit-explorer-anonymous-node scrollkeeper-guideline-underline scrollkeeper-guideline-thinline ffap log-view-commit-body log-view-message log-view-file shortdoc-section shortdoc-heading emoji-with-derivations emoji emoji-list-header textsec-suspicious ement-room-list-very-recent ement-room-list-recent ement-room-list-unread ement-room-list-space ement-room-list-name ement-room-list-low-priority ement-room-list-left ement-room-list-invited ement-room-list-favourite ement-room-list-direct ement--font-lock-constant-face ement-tabulated-room-list-very-recent ement-tabulated-room-list-recent ement-tabulated-room-list-low-priority ement-tabulated-room-list-favourite ement-tabulated-room-list-unread ement-tabulated-room-list-left ement-tabulated-room-list-invited ement-tabulated-room-list-direct ement-tabulated-room-list-name flyspell-duplicate ...))
  apply(#f(compiled-function #'sequence #<bytecode 0x18577d7a4f75ceb4>) #f(compiled-function (x) #<bytecode 0x11388bfeb4760bd7>) (indent-bars-9 indent-bars-8 indent-bars-current-face indent-bars-face indent-bars-7 indent-bars-6 indent-bars-5 indent-bars-4 indent-bars-3 indent-bars-2 indent-bars-1 yaml-tab-face sh-escaped-newline sh-quoted-exec sh-heredoc treesit-explorer-field-name treesit-explorer-anonymous-node scrollkeeper-guideline-underline scrollkeeper-guideline-thinline ffap log-view-commit-body log-view-message log-view-file shortdoc-section shortdoc-heading emoji-with-derivations emoji emoji-list-header textsec-suspicious ement-room-list-very-recent ement-room-list-recent ement-room-list-unread ement-room-list-space ement-room-list-name ement-room-list-low-priority ement-room-list-left ement-room-list-invited ement-room-list-favourite ement-room-list-direct ement--font-lock-constant-face ement-tabulated-room-list-very-recent ement-tabulated-room-list-recent ement-tabulated-room-list-low-priority ement-tabulated-room-list-favourite ement-tabulated-room-list-unread ement-tabulated-room-list-left ement-tabulated-room-list-invited ement-tabulated-room-list-direct ement-tabulated-room-list-name flyspell-duplicate ...) nil)
  seq-map(#f(compiled-function (x) #<bytecode 0x11388bfeb4760bd7>) (indent-bars-9 indent-bars-8 indent-bars-current-face indent-bars-face indent-bars-7 indent-bars-6 indent-bars-5 indent-bars-4 indent-bars-3 indent-bars-2 indent-bars-1 yaml-tab-face sh-escaped-newline sh-quoted-exec sh-heredoc treesit-explorer-field-name treesit-explorer-anonymous-node scrollkeeper-guideline-underline scrollkeeper-guideline-thinline ffap log-view-commit-body log-view-message log-view-file shortdoc-section shortdoc-heading emoji-with-derivations emoji emoji-list-header textsec-suspicious ement-room-list-very-recent ement-room-list-recent ement-room-list-unread ement-room-list-space ement-room-list-name ement-room-list-low-priority ement-room-list-left ement-room-list-invited ement-room-list-favourite ement-room-list-direct ement--font-lock-constant-face ement-tabulated-room-list-very-recent ement-tabulated-room-list-recent ement-tabulated-room-list-low-priority ement-tabulated-room-list-favourite ement-tabulated-room-list-unread ement-tabulated-room-list-left ement-tabulated-room-list-invited ement-tabulated-room-list-direct ement-tabulated-room-list-name flyspell-duplicate ...))
  indent-bars--colors-from-regexp("\\`prism-level-[[:digit:]]+\\'" nil)
  indent-bars--depth-palette(#s(indent-bars-style :tag nil :main-color "#deaaf055e8e8" :depth-palette ["#be23acc0b13f" "#c04eb625cbfe" "#b404b39eaf14" "#a533b90ab4dc"] :faces [indent-bars-1 indent-bars-2 indent-bars-3 indent-bars-4 indent-bars-5 indent-bars-6 indent-bars-7 indent-bars-8 indent-bars-9] :stipple-face indent-bars-face :no-stipple-chars [#("│" 0 1 (face indent-bars-1)) #("│" 0 1 (face indent-bars-2)) #("│" 0 1 (face indent-bars-3)) #("│" 0 1 (face indent-bars-4)) #("│" 0 1 (face indent-bars-5)) #("│" 0 1 (face indent-bars-6)) #("│" 0 1 (face indent-bars-7))] :current-stipple-face indent-bars-current-face :current-bg-color nil :current-depth-palette nil))
  indent-bars--initialize-style(#s(indent-bars-style :tag nil :main-color "#deaaf055e8e8" :depth-palette ["#be23acc0b13f" "#c04eb625cbfe" "#b404b39eaf14" "#a533b90ab4dc"] :faces [indent-bars-1 indent-bars-2 indent-bars-3 indent-bars-4 indent-bars-5 indent-bars-6 indent-bars-7 indent-bars-8 indent-bars-9] :stipple-face indent-bars-face :no-stipple-chars [#("│" 0 1 (face indent-bars-1)) #("│" 0 1 (face indent-bars-2)) #("│" 0 1 (face indent-bars-3)) #("│" 0 1 (face indent-bars-4)) #("│" 0 1 (face indent-bars-5)) #("│" 0 1 (face indent-bars-6)) #("│" 0 1 (face indent-bars-7))] :current-stipple-face indent-bars-current-face :current-bg-color nil :current-depth-palette nil))
  indent-bars-reset-styles()
  funcall-interactively(indent-bars-reset-styles)
  command-execute(indent-bars-reset-styles record)
  execute-extended-command(nil "indent-bars-reset-styles" nil)
  funcall-interactively(execute-extended-command nil "indent-bars-reset-styles" nil)
  command-execute(execute-extended-command)
jdtsmith commented 3 days ago

It should handle arbitrary length palettes, wrapping around as needed if depth>palette length.

I think the problem here is you didn't specify a capturing group, like \\([[:digit]]+\\):

the first match group in the regex (if any) will be interpreted as a number, and used to sort the resulting list of faces

I should probably throw a warning in the case of no match.

alphapapa commented 2 days ago

Ah, thanks.