* Mapping language to mode
@ 2024-11-17 15:55 Stefan Monnier
2024-11-23 17:08 ` Ihor Radchenko
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2024-11-17 15:55 UTC (permalink / raw)
To: emacs-orgmode
Would the 100% untested patch below make sense?
Stefan
diff --git a/lisp/org/org-src.el b/lisp/org/org-src.el
index 229bf62e1c0..1f0306a1f98 100644
--- a/lisp/org/org-src.el
+++ b/lisp/org/org-src.el
@@ -970,11 +970,14 @@ org-src-do-key-sequence-at-code-block
(defun org-src-get-lang-mode (lang)
"Return major mode that should be used for LANG.
LANG is a string, and the returned major mode is a symbol."
- (intern
- (concat
- (let ((l (or (cdr (assoc lang org-src-lang-modes)) lang)))
- (if (symbolp l) (symbol-name l) l))
- "-mode")))
+ (let ((mode (intern
+ (concat
+ (let ((l (or (cdr (assoc lang org-src-lang-modes)) lang)))
+ (if (symbolp l) (symbol-name l) l))
+ "-mode"))))
+ (if (fboundp 'major-mode-remap)
+ (major-mode-remap mode)
+ mode)))
(defun org-src-edit-buffer-p (&optional buffer)
"Non-nil when current buffer is a source editing buffer.
diff --git a/lisp/org/ox-html.el b/lisp/org/ox-html.el
index 4eb3a511b00..002978e65c3 100644
--- a/lisp/org/ox-html.el
+++ b/lisp/org/ox-html.el
@@ -2355,8 +2355,7 @@ org-html-fontify-code
(org-html-encode-plain-text code))
(t
;; Map language
- (setq lang (or (assoc-default lang org-src-lang-modes) lang))
- (let* ((lang-mode (and lang (intern (format "%s-mode" lang)))))
+ (let* ((lang-mode (and lang (org-src-get-lang-mode lang))))
(cond
;; Case 1: Language is not associated with any Emacs mode
((not (functionp lang-mode))
diff --git a/lisp/org/ox-odt.el b/lisp/org/ox-odt.el
index c6a70fe9cd8..1b2728d1a5d 100644
--- a/lisp/org/ox-odt.el
+++ b/lisp/org/ox-odt.el
@@ -3116,8 +3116,7 @@ org-odt-htmlfontify-string
(defun org-odt-do-format-code
(code info &optional lang refs retain-labels num-start)
- (let* ((lang (or (assoc-default lang org-src-lang-modes) lang))
- (lang-mode (if lang (intern (format "%s-mode" lang)) #'ignore))
+ (let* ((lang-mode (if lang (org-src-get-lang-mode lang) #'ignore))
(code-lines (org-split-string code "\n"))
(code-length (length code-lines))
(use-htmlfontify-p (and (functionp lang-mode)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: Mapping language to mode
2024-11-17 15:55 Mapping language to mode Stefan Monnier
@ 2024-11-23 17:08 ` Ihor Radchenko
2024-11-23 17:12 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2024-11-23 17:08 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-orgmode
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> Would the 100% untested patch below make sense?
> ...
> + (if (fboundp 'major-mode-remap)
> + (major-mode-remap mode)
> + mode)))
Thanks!
Applied, onto main, after adding proper commit message.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=984c0c58bb
--
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Mapping language to mode
2024-11-23 17:08 ` Ihor Radchenko
@ 2024-11-23 17:12 ` Stefan Monnier
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2024-11-23 17:12 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
>> Would the 100% untested patch below make sense?
>> ...
>> + (if (fboundp 'major-mode-remap)
>> + (major-mode-remap mode)
>> + mode)))
>
> Thanks!
> Applied, onto main, after adding proper commit message.
Oh! Wonderful, thanks Ihor!
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-23 17:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-17 15:55 Mapping language to mode Stefan Monnier
2024-11-23 17:08 ` Ihor Radchenko
2024-11-23 17:12 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).