From: Derek Chen-Becker <derek@chen-becker.org>
To: Matt <matt@excalamus.com>
Cc: Ihor Radchenko <yantar92@posteo.net>,
Emacs-orgmode <Emacs-orgmode@gnu.org>
Subject: Re: [BUG] No font lock in src blocks for shells in org-babel-shell-names (was Re: Font lock for org-babel shell scripts?)
Date: Mon, 3 Apr 2023 11:42:54 -0600 [thread overview]
Message-ID: <CAMbmz5ntkOHMiZG4EbNAks9ob-0ahnciCfHQ9LQmJoci0+i7fg@mail.gmail.com> (raw)
In-Reply-To: <1873f20a792.fcfc6bcd54095.5358297633673942037@excalamus.com>
[-- Attachment #1: Type: text/plain, Size: 1719 bytes --]
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 <matt@excalamus.com> wrote:
>
> ---- On Thu, 30 Mar 2023 04:55:32 -0400 Ihor Radchenko wrote ---
> > Matt matt@excalamus.com> 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 |
+---------------------------------------------------------------+
[-- Attachment #2: Type: text/html, Size: 3793 bytes --]
next prev parent reply other threads:[~2023-04-03 17:44 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 17:24 Font lock for org-babel shell scripts? Derek Chen-Becker
2023-03-28 21:07 ` Matt
2023-03-28 21:53 ` [BUG] No font lock in src blocks for shells in org-babel-shell-names (was Re: Font lock for org-babel shell scripts?) Matt
2023-03-29 9:35 ` Ihor Radchenko
2023-03-29 17:04 ` Derek Chen-Becker
2023-03-29 20:17 ` Matt
2023-03-30 8:56 ` Ihor Radchenko
2023-03-30 23:10 ` Derek Chen-Becker
2023-03-31 13:08 ` Ihor Radchenko
2023-03-31 17:04 ` Derek Chen-Becker
2023-03-31 17:46 ` Ihor Radchenko
2023-04-01 23:21 ` Matt
2023-04-03 17:42 ` Derek Chen-Becker [this message]
2023-04-04 12:32 ` Ihor Radchenko
2023-04-04 14:49 ` Derek Chen-Becker
2023-04-07 15:29 ` Matt
2023-04-07 15:32 ` Derek Chen-Becker
2023-04-17 15:12 ` Matt
2023-04-17 15:21 ` Ihor Radchenko
2023-04-20 14:42 ` Max Nikulin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAMbmz5ntkOHMiZG4EbNAks9ob-0ahnciCfHQ9LQmJoci0+i7fg@mail.gmail.com \
--to=derek@chen-becker.org \
--cc=Emacs-orgmode@gnu.org \
--cc=matt@excalamus.com \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.