branch: elpa/markdown-mode
commit 080098ee73fc299aef9c9213c8c2681856386c93
Merge: 1d22840d58 63321854d5
Author: Shohei YOSHIDA <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #959 from darkfeline/fix/export-auto-insert
Do not trigger auto-insert-mode in markdown-export
---
markdown-mode.el | 2 ++
tests/markdown-test.el | 16 ++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/markdown-mode.el b/markdown-mode.el
index dc97f8de7d..87f84b198c 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -49,6 +49,7 @@
(defvar flyspell-generic-check-word-predicate)
(defvar electric-pair-pairs)
(defvar sh-ancestor-alist)
+(defvar auto-insert)
(declare-function project-roots "project")
(declare-function sh-set-shell "sh-script")
@@ -7962,6 +7963,7 @@ current filename, but with the extension removed and
replaced with .html."
(let* ((init-buf (current-buffer))
(init-point (point))
(init-buf-string (buffer-string))
+ (auto-insert nil)
(output-buffer (find-file-noselect output-file))
(output-buffer-name (buffer-name output-buffer)))
(run-hooks 'markdown-before-export-hook)
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index d4059574c3..f0228ab5c2 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -6461,6 +6461,22 @@ bar baz"
;;; Export tests:
+(require 'autoinsert)
+
+(ert-deftest test-markdown-export/auto-insert ()
+ "Test that `markdown-export' does not trigger `auto-insert-mode'."
+ (skip-unless (executable-find markdown-command))
+ (markdown-test-temp-file "inline.text"
+ (let* ((auto-insert-triggered nil)
+ (auto-insert t)
+ (auto-insert-query nil)
+ (auto-insert-alist `((html-mode . ,(lambda () (setq
auto-insert-triggered t)))))
+ (find-file-hook (cons #'auto-insert find-file-hook))
+ (markdown-command #'markdown-command-identity)
+ (ofile (markdown-export)))
+ (delete-file ofile)
+ (should-not auto-insert-triggered))))
+
(ert-deftest test-markdown-hook/xhtml-standalone ()
"Test `markdown-xhtml-standalone-regexp' and `markdown-output-standalone-p'."
(should (string-match markdown-xhtml-standalone-regexp