Skip to content

Commit

Permalink
Ensure font-lock-defaults is always populated on load
Browse files Browse the repository at this point in the history
Attempt to fix an issue introduced in commit 8300a05.

The behavior now is to always run `markdown-reload-extensions` when
initially loading `markdown-mode'.  Later, when `hack-local-variables`
runs the new `markdown-handle-local-variables' hook function, we only
reload again if there are actually `markdown-mode`-related local
variables that might require different `font-lock-defaults`.
  • Loading branch information
jrblevin committed Jul 27, 2015
1 parent cd0db54 commit 86fb0ea
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -4821,6 +4821,14 @@ if ARG is omitted or nil."
(message "markdown-mode math support disabled"))
(markdown-reload-extensions))

(defun markdown-handle-local-variables ()
"Runs as a `hack-local-variables-hook' to update font lock rules.
Checks to see if there is actually a markdown-mode file local variable
before regenerating font-lock rules for extensions."
(when (and (boundp 'file-local-variables-alist)
(assoc 'markdown-enable-math file-local-variables-alist))
(markdown-reload-extensions)))


;;; Mode Definition ==========================================================

Expand Down Expand Up @@ -4853,11 +4861,9 @@ if ARG is omitted or nil."
;; Extensions
(make-local-variable 'markdown-enable-math)
;; Reload extensions
(if (and enable-local-variables buffer-file-name)
;; Add a buffer-local hook to reload after file-local variables are read
(add-hook 'hack-local-variables-hook 'markdown-reload-extensions nil t)
;; File local variables disabled or not visiting a file, reload now
(markdown-reload-extensions))
(markdown-reload-extensions)
;; Add a buffer-local hook to reload after file-local variables are read
(add-hook 'hack-local-variables-hook 'markdown-handle-local-variables nil t)
;; For imenu support
(setq imenu-create-index-function 'markdown-imenu-create-index)
;; For menu support in XEmacs
Expand Down

0 comments on commit 86fb0ea

Please sign in to comment.