mbj4668 / yang-mode

Emacs mode for YANG (RFC 7950)
10 stars 4 forks source link

(wrong-type-argument stringp nil) when using Emacs 26 #7

Open ghost opened 6 years ago

ghost commented 6 years ago

It does't take much to reproduce this, just type module foo { in a new .yang file and you'll get a backtrace like this.

Using yang-mode packaage 20180306.407 on Emacs 26.1

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  looking-at(nil)
  c-just-after-func-arglist-p(1)
  c-guess-basic-syntax()
  c-electric-brace(nil)
  funcall-interactively(c-electric-brace nil)
  call-interactively(c-electric-brace nil nil)
  command-execute(c-electric-brace)
ghost commented 6 years ago

Adding this near the other c-lang-defconst calls seems to fix the problem. cc-mode seems to be defaulting some stuff to nil and then passing that to looking-at (which apparently doesn't like nil).

(c-lang-defconst c-cpp-expr-functions-key
  yang "")

(c-lang-defconst c-opt-op-identifier-prefix
  yang "")

I'm not really sure if "" is the right thing for YANG though

event commented 7 months ago

Since the time of the original issue, more variables cause problems. Another solution is to derive yang-mode from js-mode, rather then java-mode:

@@ -157,12 +157,13 @@
   (require 'cc-langs)
   (require 'cc-fonts))

+(require 'js)
 (eval-and-compile
   ;; Make our mode known to the language constant system.  Use Java
   ;; mode as the fallback for the constants we don't change here.
   ;; This needs to be done also at compile time since the language
   ;; constants are evaluated then.
-  (c-add-language 'yang-mode 'java-mode)
+  (c-add-language 'yang-mode 'js-mode)

   ;; compatibility with emacs < 24
   (defalias 'yang-mode-prog-mode