From 0fd68767f291626ca4a313d7d269f279c8c0c713 Mon Sep 17 00:00:00 2001 From: Tom May Date: Thu, 26 Feb 2015 17:41:27 -0800 Subject: [PATCH] Respect font-lock-mode nil. font-lock-refresh-defaults can set font-lock-mode to t even if global-font-lock-mode and font-lock-global-modes are nil. So save the original value of font-lock-mode and set it back to nil if it was nil to begin with. --- markdown-mode.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/markdown-mode.el b/markdown-mode.el index 053b8cd9..74dc1cfe 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -4556,7 +4556,15 @@ This is an exact copy of `line-number-at-pos' for use in emacs21." markdown-mode-font-lock-keywords-basic markdown-mode-font-lock-keywords-core)) (setq font-lock-defaults '(markdown-mode-font-lock-keywords)) - (when (fboundp 'font-lock-refresh-defaults) (font-lock-refresh-defaults)))) + (when (fboundp 'font-lock-refresh-defaults) + ;; font-lock-refresh-defaults can set font-lock-mode to t even + ;; if global-font-lock-mode and font-lock-global-modes are nil. + ;; So save the original value of font-lock-mode and set it back + ;; to nil if it was nil to begin with. + (let ((save-font-lock-mode font-lock-mode)) + (font-lock-refresh-defaults) + (when (not save-font-lock-mode) + (font-lock-mode -1)))))) (defun markdown-enable-math (&optional arg) "Toggle support for inline and display LaTeX math expressions.