branch: elpa/markdown-mode
commit 3207f366ba0367966b1886943172a032be59a953
Author: Shohei YOSHIDA <[email protected]>
Commit: Shohei YOSHIDA <[email protected]>
Improve selecting mode when editting code blocks
---
CHANGES.md | 2 ++
markdown-mode.el | 4 ++++
tests/markdown-test.el | 13 +++++++++----
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 854ddaae36..8f28a89607 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -23,6 +23,7 @@
- Don't hide backslashes in code blocks when using `markdown-hide-markup`
and `markdown-fontify-code-blocks-natively` together [GH-766][]
- Fix `markdown-fontify-whole-heading-line` regression [GH-848][]
+ - Fix using fundamental-mode issue when editting code block [GH-868][]
* Improvements:
- Apply url-unescape against URL in an inline link [GH-805][]
@@ -45,6 +46,7 @@
[gh-845]: https://github.com/jrblevin/markdown-mode/issues/845
[gh-848]: https://github.com/jrblevin/markdown-mode/issues/848
[gh-855]: https://github.com/jrblevin/markdown-mode/issues/855
+ [gh-868]: https://github.com/jrblevin/markdown-mode/issues/868
[gh-870]: https://github.com/jrblevin/markdown-mode/issues/870
# Markdown Mode 2.6
diff --git a/markdown-mode.el b/markdown-mode.el
index 2470e2ff63..fc01170aab 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -9099,6 +9099,10 @@ LANG is a string, and the returned major mode is a
symbol."
(and mode
(fboundp mode)
(or
+ (not (string-match-p "ts-mode\\'" (symbol-name mode)))
+ ;; Don't load tree-sitter mode if the mode is in neither
auto-mode-alist nor major-mode-remap-alist
+ ;; Because some ts-mode overwrites auto-mode-alist and it might break
user configurations
+
;; https://github.com/jrblevin/markdown-mode/issues/787
;; major-mode-remap-alist was introduced at Emacs 29.1
(cl-loop for pair in (bound-and-true-p major-mode-remap-alist)
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index 081826fd0c..66ecf298b9 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -4379,12 +4379,17 @@ x: x
(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"
+Do not load tree-sitter-mode function if it is in neither auto-mode-alist nor
major-mode-remap-alist.
+Details:
+- https://github.com/jrblevin/markdown-mode/issues/761
+- https://github.com/jrblevin/markdown-mode/issues/868"
(should (eq (markdown-get-lang-mode "emacs-lisp") 'emacs-lisp-mode))
- (let ((auto-mode-alist nil))
- (should (null (markdown-get-lang-mode "emacs-lisp")))))
+ (when (and (fboundp 'treesit-language-available-p)
+ (funcall 'treesit-language-available-p 'python))
+ (let ((auto-mode-alist nil)
+ (major-mode-remap-alist nil))
+ (should (null (markdown--lang-mode-predicate 'python-ts-mode))))))
(ert-deftest test-markdown-parsing/get-lang-mode-from-remap-alist ()
"Test `markdown-get-lang-mode' from major-mode-remap-alist.