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

shell/bash highlighting? #25

Closed
epruesse opened this issue Feb 12, 2018 · 6 comments
Closed

shell/bash highlighting? #25

epruesse opened this issue Feb 12, 2018 · 6 comments

Comments

@epruesse
Copy link

Since it's already supported for embedded R, any chance to do this for embedded bash?

It may make sense for not just the shell: field, but for all strings as they are likely to be passed through the shell at some point. Although that might be too slow, considering the number of small pieces.

Alternatively, highlighting the {wildcard} parts of the strings would be neat.

@kyleam
Copy link
Owner

kyleam commented Feb 12, 2018

Since it's already supported for embedded R, any chance to do this for embedded bash?

Thanks for the suggestion. The thought hadn't occurred to me. (Well,
the embedded R fontification didn't occur to me either. @endrebak
added that feature.)

The R highlighting depends on finding triple quote markers like
R(""". I'm not sure if doing that for a shell: ".* with mmm-mode
would be more complicated to handle or more expensive to process.
Worth looking into.

Alternatively, highlighting the {wildcard} parts of the strings would be neat.

Yeah, I think that'd be nice to add.

@endrebak
Copy link

This sounds like a good idea, but I do not use the R syntax highlighting anymore since using scripts or wrappers is recommended.

There were some hiccups mixing modes with mmm for me. R indentation in Snakemake buffers became weird for example. If you’ve had no problems using it you should attempt to implement this :)

@endrebak
Copy link

“It may make sense for not just the shell: field, but for all strings as they are likely to be passed through the shell at some point.”

This I do not understand? Shell highlighting for all strings?

@epruesse
Copy link
Author

This I do not understand? Shell highlighting for all strings?

Yep :)

I tried implementing this with polymode a while back -- it sort of worked but was slow enough to be annoying, although that's perhaps my lack of skill with lisp. I eventually got stuck when I realized that the "bash parts" are actually "bash + python format mini language": the curly braces kept messing things up. Deriving a python-string-shell-mode from shell-mode was beyond me.

Perhaps the low hanging fruit - just applying font locks to the python format mini language parts - would suffice. Although that one should probably just be implemented in python-mode? Curious that python-mode doesn't do that already...

@kyleam
Copy link
Owner

kyleam commented Feb 13, 2018 via email

@kyleam
Copy link
Owner

kyleam commented Feb 17, 2018

OK, so I've played around with adding the different fontification for the minilanguage parts, and ... I really don't like it! :) I think the thing is, my brain is so used to a break in the string fontfication signaling the end of a string, so all my strings just look broken. Dunno, perhaps it's something I'd get used to.

To try this out yourself, you could do something like (changing font-lock-variable-name-face to whatever face you'd like):

(add-to-list 'snakemake-font-lock-keywords
             '("{[^}]+}" 0 font-lock-variable-name-face t))

What do others think?

@kyleam kyleam closed this as completed Apr 13, 2020
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

No branches or pull requests

3 participants