From: Ihor Radchenko <yantar92@posteo.net>
To: Derek Chen-Becker <derek@chen-becker.org>
Cc: Matt <matt@excalamus.com>, 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: Tue, 04 Apr 2023 12:32:27 +0000 [thread overview]
Message-ID: <87sfdfakv8.fsf@localhost> (raw)
In-Reply-To: <CAMbmz5ntkOHMiZG4EbNAks9ob-0ahnciCfHQ9LQmJoci0+i7fg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 469 bytes --]
Derek Chen-Becker <derek@chen-becker.org> writes:
> 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))))
See the attached tentative patch.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-src-Use-sh-mode-for-all-the-shells-it-can-handle.patch --]
[-- Type: text/x-patch, Size: 2180 bytes --]
From 85e268de9435d94eb6766e3f92f4f56a9dc1aebe Mon Sep 17 00:00:00 2001
Message-Id: <85e268de9435d94eb6766e3f92f4f56a9dc1aebe.1680611510.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Tue, 4 Apr 2023 14:30:34 +0200
Subject: [PATCH] org-src: Use `sh-mode' for all the shells it can handle
* lisp/org-src.el (org-src--get-known-shells): New helper function
extracting known shells from `sh-ancestor-alist'.
(org-src-lang-modes): Update the value.
Link: https://orgmode.org/list/CAMbmz5ntkOHMiZG4EbNAks9ob-0ahnciCfHQ9LQmJoci0+i7fg@mail.gmail.com
---
lisp/org-src.el | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/lisp/org-src.el b/lisp/org-src.el
index ec2716885..2669b1b77 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -194,11 +194,17 @@ (defvar org-src-mode-hook nil
or similar things which you want to have when editing a source code file,
but which mess up the display of a snippet in Org exported files.")
+(defun org-src--get-known-shells ()
+ "List all the shells in `sh-ancestor-alist' for `org-src-lang-modes'.
+The shells are associated with `sh-mode'."
+ (mapcar
+ (lambda (shell) (cons (symbol-name shell) 'sh))
+ (delete-dups (flatten-tree sh-ancestor-alist))))
+
(defcustom org-src-lang-modes
- '(("C" . c)
+ `(("C" . c)
("C++" . c++)
("asymptote" . asy)
- ("bash" . sh)
("beamer" . latex)
("calc" . fundamental)
("cpp" . c++)
@@ -208,9 +214,10 @@ (defcustom org-src-lang-modes
("elisp" . emacs-lisp)
("ocaml" . tuareg)
("screen" . shell-script)
- ("shell" . sh)
("sqlite" . sql)
- ("toml" . conf-toml))
+ ("toml" . conf-toml)
+ ("shell" . sh)
+ ,@(org-src--get-known-shells))
"Alist mapping languages to their major mode.
The key is the language name. The value is the mode name, as
@@ -221,7 +228,7 @@ (defcustom org-src-lang-modes
the user side. For example, there is no `ocaml-mode' in Emacs,
but the mode to use is `tuareg-mode'."
:group 'org-edit-structure
- :package-version '(Org . "9.6")
+ :package-version '(Org . "9.7")
:type '(repeat
(cons
(string "Language name")
--
2.40.0
[-- Attachment #3: Type: text/plain, Size: 224 bytes --]
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
next prev parent reply other threads:[~2023-04-04 12:30 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
2023-04-04 12:32 ` Ihor Radchenko [this message]
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=87sfdfakv8.fsf@localhost \
--to=yantar92@posteo.net \
--cc=Emacs-orgmode@gnu.org \
--cc=derek@chen-becker.org \
--cc=matt@excalamus.com \
/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.