1

I have a function to highlight custom Scheme syntax:

(defun scheme-defmacro (syntax &optional args)
  (let ((args (or args 1)))
    (put syntax 'scheme-indent-function args))
  (let ((regexp (concat "(\\<\\(" (symbol-name syntax) "\\)\\>")))
    (font-lock-add-keywords 'scheme-mode
                            `((,regexp 1 font-lock-keyword-face)))))

The function works but affects only newly created Scheme buffers. How to update the highlighting of the current buffer, if the major mode is scheme-mode?

I tried this (because of a SO answer), but it does not work:

(if (eq major-mode 'scheme-mode)
    (font-lock-fontify-buffer))
4
  • 1
    I don't have a solution to whatever the overall issue may be, but wanted to mention that I manually use jit-lock-refontify occasionally -- the argument BEG could either be (point-min) or (window-start WIN) and the argument END could be either (point-max) or (window-end WIN t).
    – lawlist
    Jan 10 at 14:31
  • Typically, you add keywords either before you open any buffers, or in the major mode hook. That way you don't have the problem with updating existing buffers. Jan 12 at 21:16
  • You could simply restart the major mode, then it will pick up the new keywords Jan 12 at 21:17
  • @Lindydancer In Scheme the keywords depend on the syntax you define. Because of that, I like to have scheme-defmacro in a comment next to define-syntax in the same Scheme source file.
    – ceving
    Jan 13 at 8:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.