From 85e268de9435d94eb6766e3f92f4f56a9dc1aebe Mon Sep 17 00:00:00 2001 Message-Id: <85e268de9435d94eb6766e3f92f4f56a9dc1aebe.1680611510.git.yantar92@posteo.net> From: Ihor Radchenko 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