I fiddled around a little bit this weekend and confirmed that this (sloppy)
code makes highlighting work for all shell types that sh-script supports:
;;A quick hack to try and support more shells syntax highlight in org babel
(require 'sh-script)
(require 'ob-shell)
(let ((shells (seq-filter (lambda (shell) (not (eq shell 'sh)))
(flatten-tree sh-ancestor-alist))))
(let ((toAppend (mapcar (lambda (shell) `(,(symbol-name shell) . sh))
shells)))
(setq org-src-lang-modes (-distinct (append toAppend
org-src-lang-modes)))))
I'm a relative newcomer to elisp, so comments and suggestions are welcome.
This is basically what I meant by "dynamically amend org-src-lang-modes
based on the contents of sh-ancestor-alist".
Thanks,
Derek
On Sat, Apr 1, 2023 at 5:22 PM Matt <[email protected]> wrote:
>
> ---- On Thu, 30 Mar 2023 04:55:32 -0400 Ihor Radchenko wrote ---
> > Matt [email protected]> writes:
> >
> > > I think this approach will work fine. I tried examples for each
> shell type and keywords like if/then/else and function names are
> highlighted.
> >
> > Even for posh (powershell)?
>
> Yes. It's not great since sh-mode looks for Korn-based keywords. It does
> string highlighting and common keywords like 'if', 'exit', and 'param'.
>
>
--
+---------------------------------------------------------------+
| Derek Chen-Becker |
| GPG Key available at https://keybase.io/dchenbecker and |
| https://pgp.mit.edu/pks/lookup?search=derek%40chen-becker.org |
| Fngrprnt: EB8A 6480 F0A3 C8EB C1E7 7F42 AFC5 AFEE 96E4 6ACC |
+---------------------------------------------------------------+