Skip to content

Commit

Permalink
Improve selecting mode when editting code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
syohex committed Jan 15, 2025
1 parent 3c28f0c commit 3207f36
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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][]
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 9 additions & 4 deletions tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3207f36

Please sign in to comment.