From 3b926189fee01aa90680740f363dd0e6c9c80779 Mon Sep 17 00:00:00 2001 From: Jason Blevins Date: Wed, 8 Nov 2017 14:51:22 -0500 Subject: [PATCH] Add markdown-edit-code-block-default-mode Based on a suggestion in GH-251. --- CHANGES.md | 3 +++ markdown-mode.el | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index a02116e6..237966c5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -29,6 +29,8 @@ - Support double-backslash math delimiters. ([GH-270][]) - New user option `markdown-export-kill-buffer` to kill or preserve HTML export output buffer. ([GH-224][]) + - Add `markdown-edit-code-block-default-mode` to specify default + mode for indirect editing of code blocks. ([GH-251][]) * Bug fixes: @@ -60,6 +62,7 @@ [gh-238]: https://github.com/jrblevin/markdown-mode/issues/238 [gh-246]: https://github.com/jrblevin/markdown-mode/issues/246 [gh-248]: https://github.com/jrblevin/markdown-mode/issues/248 + [gh-251]: https://github.com/jrblevin/markdown-mode/issues/251 [gh-252]: https://github.com/jrblevin/markdown-mode/pull/252 [gh-254]: https://github.com/jrblevin/markdown-mode/issues/254 [gh-255]: https://github.com/jrblevin/markdown-mode/issues/255 diff --git a/markdown-mode.el b/markdown-mode.el index 0deb75f1..a92c7624 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -1490,6 +1490,14 @@ This applies to insertions done with :group 'markdown :type 'boolean) +(defcustom markdown-edit-code-block-default-mode 'normal-mode + "Default mode to use for editing code blocks. +This mode is used when automatic detection fails, such as for GFM +code blocks with no language specified." + :group 'markdown + :type 'symbol + :package-version '(markdown-mode . "2.4")) + (defcustom markdown-gfm-uppercase-checkbox nil "If non-nil, use [X] for completed checkboxes, [x] otherwise." :group 'markdown @@ -9059,7 +9067,9 @@ position." (end (and bounds (goto-char (nth 1 bounds)) (point-at-bol 1)))) (if (and begin end) (let* ((lang (markdown-code-block-lang)) - (mode (and lang (markdown-get-lang-mode lang))) + (mode (if lang + (markdown-get-lang-mode lang) + markdown-edit-code-block-default-mode)) (edit-indirect-guess-mode-function (lambda (_parent-buffer _beg _end) (funcall mode))))