Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Some modes require a second mode activation #26
Yeah me too. It's quite annoying but I never got around to investigate enough to actually fix it because I suspect doing so would involve gaining a deep understanding of how font-locking works and implementing functionality which ought to already exist.
Back in the days package authors used
(defun font-lock-fontify-buffer (&optional interactively) "Fontify the current buffer the way the function `font-lock-mode' would." (declare ;; When called from Lisp, this function is a big mess. The caller usually ;; expects one of the following behaviors: ;; - refresh the highlighting (because the font-lock-keywords have been ;; changed). ;; - apply font-lock highlighting even if font-lock-mode is not enabled. ;; - reset the highlighting rules because font-lock-defaults ;; has been changed (and then rehighlight everything). ;; Of course, this function doesn't do all of the above in all situations ;; (e.g. depending on whether jit-lock is in use) and it can't guess what ;; the caller wants. (interactive-only "use `font-lock-ensure' or `font-lock-flush' instead.")) (interactive "p") (font-lock-set-defaults) (let ((font-lock-verbose (or font-lock-verbose interactively))) (funcall font-lock-fontify-buffer-function)))
The commit that added the above comment, emacs-mirror/emacs@6711a21, also added
I tried using the former instead for a while because its doc-string says that (when called without any arguments) it makes sure that the whole buffer is fontified, but apparently that only means that ensures that the buffer has been fontified at some point and not that it ensures that all currently defined keywords actually are in effect.
So I started to also call
(define-minor-mode hl-todo-mode "Highlight TODO and similar keywords in comments and strings." :lighter "" :keymap hl-todo-mode-map :group 'hl-todo (if hl-todo-mode (hl-todo--setup) (font-lock-remove-keywords nil hl-todo--keywords)) (when font-lock-mode (if (and (fboundp 'font-lock-flush) (fboundp 'font-lock-ensure)) (save-restriction (widen) (font-lock-flush) (font-lock-ensure)) (with-no-warnings (font-lock-fontify-buffer)))))
But those are the functions added to do this sort of thing and I don't know what else I could do to make the new keywords take effect without implementing it myself. Even if these functions reliably did what I think they were designed to do, they would still be problematic because they refontify the whole buffer (when they actually do, which, as we have learned, doesn't appear to be always the case), then that would be wasteful (leading to issues such as #22).
What I would really like to be able to use is
referenced this issue
Oct 3, 2018
I am unable to locate an
The version of
Oh! If you say "tested with sql-mode" you probably mean a buffer whose major-mode is
@dschrempf I assume you were talking about
Yes, I was talking about buffers using
As far as I can see the problem has not been fixed. I am using
The value of
I don't know why this is not working, it is working fine with