1

I'm writing a syntax highlighting mode for emacs, and wondering if there is a way to improve my workflow.

Currently I do this:

  1. make edits to mymode.el
  2. restart emacs
  3. open mymode.el
  4. eval buffer
  5. open a file with the language to see the changes

Is there a way to quickly display the results of syntax mode changes, preferably without having to reload emacs?

[EDIT]

My font faces are defined using (defface... like so:

(defface my-lang-comment-face '((t (:inherit font-lock-comment-face)))
                              "comments" :group 'my-lang)

Should I be using defconstant or setq instead during development, then change it to defface when it's "done"?

3
  • 1
    Add a step 6. delete buffer containing file with the language using C-x k. Then delete steps 2 and 3. Your new loop should be steps 1, 4, 5 and 6.
    – g-gundam
    Nov 12, 2022 at 16:54
  • I tried this first - the result was no change to the syntax highlighting, even if I change things in mymode.el. The old syntax table is not replaced when I eval the mode. However I can do M-x describe-variable RET my--syntax-table and select Forget, confirm, then reload the mode and revisit the language file. But this is not better than restarting emacs. Really I just want to "reload" the entire mode, overwriting previous definitions with the new ones, but I can't figure out how to do that without restarting emacs. Nov 12, 2022 at 17:38
  • 2
    I discovered that if I use (defconst my-syntax-table ...) rather than (defvar my-syntax-table ...) then I can actually eval-buffer and then reload the language buffer to see changes! I learned to use defconst if I want to be able to change the thing, versus defvar when it should never change. Great naming scheme there, thanks Emacs. Nov 12, 2022 at 18:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.