I have found that scad-mode.el
, a derived mode from CC Mode, which can be found here:
https://github.com/openscad/openscad/blob/master/contrib/scad-mode.el
hangs emacs if I type
#(
into the window, or indeed any line containing a #
and also one of ()[]{}
. I have to kill Emacs completely and restart it after this crash.
I'm not familiar with how one write a derived mode and have not been able to figure out why this happens. I deleted almost all of scad-mode.el
and I still get the hang. (This makes me suspect that the hang is caused by something missing rather than something in the code.) Furthermore, I can't find a coherent explanation of how one writes derived modes. The example derived mode,
http://cc-mode.sourceforge.net/derived-mode-ex.el
doesn't look much like scad-mode.el
. I wonder if perhaps things have changed since 2002, when the example was written. The documentation text for c-basic-common-init
says I need to call c-init-language-vars
first, which scad-mode
does not. But if I add a call to this
(c-init-language-vars scad-mode)
I get the message:
File mode specification error: (void-function c-init-language-vars)
Can anybody tell me what's wrong with scad-mode.el
that it causes Emacs to hang? Or how to go about debugging it?
Note: I reduced scad-mode.el to this:
(add-to-list 'auto-mode-alist '("\\.scad$" . scad-mode))
(require 'cc-mode)
(define-derived-mode scad-mode prog-mode "SCAD"
"Major mode for editing OpenSCAD code."
(c-initialize-cc-mode)
(c-basic-common-init 'scad-mode "k&r")
)
(provide 'scad-mode)
and it still hangs the same way. It's not clear to me how to truly disentangle the question of how to write a mode from the question of why this is hanging. It has been suggested to me that it's an emacs bug.
font-lock-studio
(available from Melpa) to single-step the font-lock keywords to find which is broken. – Lindydancer Jun 20 '19 at 18:51