[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/markdown-mode 4fc65528b9 1/2: Don't load language mode if
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/markdown-mode 4fc65528b9 1/2: Don't load language mode if it is not in `auto-mode-alist` |
Date: |
Fri, 19 May 2023 19:00:48 -0400 (EDT) |
branch: elpa/markdown-mode
commit 4fc65528b908429cfb3321a42e168a0977250c15
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: Shohei YOSHIDA <syohex@gmail.com>
Don't load language mode if it is not in `auto-mode-alist`
---
CHANGES.md | 2 ++
markdown-mode.el | 10 +++++++++-
tests/markdown-test.el | 9 +++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/CHANGES.md b/CHANGES.md
index e554571a49..3957e0175f 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -22,6 +22,7 @@
- Highlight autolinks if a scheme is valid and it is not registered in
markdown-uri-types
[GH-743][]
- Improve horizontal rule rendering in `markdown-view-mode` [GH-753][]
+ - Don't load major-mode if it isn't in `auto-mode-alist`[GH-761][]
* Bug fixes:
- Don't override table faces by link faces [GH-716][]
@@ -42,6 +43,7 @@
[gh-743]: https://github.com/jrblevin/markdown-mode/issues/743
[gh-747]: https://github.com/jrblevin/markdown-mode/issues/747
[gh-753]: https://github.com/jrblevin/markdown-mode/issues/753
+ [gh-761]: https://github.com/jrblevin/markdown-mode/issues/761
[gh-762]: https://github.com/jrblevin/markdown-mode/issues/762
diff --git a/markdown-mode.el b/markdown-mode.el
index 00918a23d4..9d7bb31d9c 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -8779,7 +8779,7 @@ mode to use is `tuareg-mode'."
"Return major mode that should be used for LANG.
LANG is a string, and the returned major mode is a symbol."
(cl-find-if
- 'fboundp
+ #'markdown--lang-mode-predicate
(nconc (list (cdr (assoc lang markdown-code-lang-modes))
(cdr (assoc (downcase lang) markdown-code-lang-modes)))
(and (fboundp 'treesit-language-available-p)
@@ -8791,6 +8791,14 @@ LANG is a string, and the returned major mode is a
symbol."
(intern (concat lang "-mode"))
(intern (concat (downcase lang) "-mode"))))))
+(defun markdown--lang-mode-predicate (mode)
+ (and mode
+ (fboundp mode)
+ ;; https://github.com/jrblevin/markdown-mode/issues/761
+ (cl-loop for pair in auto-mode-alist
+ for func = (cdr pair)
+ thereis (and (atom func) (eq mode func)))))
+
(defun markdown-fontify-code-blocks-generic (matcher last)
"Add text properties to next code block from point to LAST.
Use matching function MATCHER."
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index 000974653e..dea5d98075 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -4306,6 +4306,15 @@ x: x
(should (string-equal (markdown-code-block-lang
'(83 . markdown-tilde-fence-begin)) "bash"))))
+(ert-deftest test-markdown-parsing/get-lang-mode ()
+ "Test `markdown-get-lang-mode'.
+Do not load major-mode function if it isn't in auto-mode-alist.
+Details: https://github.com/jrblevin/markdown-mode/issues/761"
+ (should (eq (markdown-get-lang-mode "emacs-lisp") 'emacs-lisp-mode))
+
+ (let ((auto-mode-alist nil))
+ (should (null (markdown-get-lang-mode "emacs-lisp")))))
+
(ert-deftest test-markdown-parsing/code-block-lang-period ()
"Test `markdown-code-block-lang' when language name begins with a period."
(markdown-test-string "~~~ { .ruby }
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/markdown-mode 4fc65528b9 1/2: Don't load language mode if it is not in `auto-mode-alist`,
ELPA Syncer <=