mbj4668 / yang-mode

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

imenu not supported for yang-mode? #9

Open pierre-rouleau opened 3 years ago

pierre-rouleau commented 3 years ago

When opening a .yang file that has yang-mode associated with it and using the latest version (20190507.724) of this code Emacs complains that imenu support is not available: I get the following traceback.

Debugger entered--Lisp error: (imenu-unavailable "The mode ‘YANG//l’ does not support Imenu")
  signal(imenu-unavailable ("The mode ‘YANG//l’ does not support Imenu"))
  imenu-unavailable-error("The mode `%s' does not support Imenu" "YANG//l")
  imenu-add-to-menubar("Defs")
  imenup-add-defs-to-menubar()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook yang-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook yang-mode-hook))
  run-mode-hooks(yang-mode-hook)
  yang-mode()
  set-auto-mode-0(yang-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer iana-if-type@2020-01-10.yang> "~/devpub/yang/yang/standard/ieee/published/1906.1/iana-if-type@2020-01-10.yang" nil nil "~/devpub/ya$
  find-file-noselect("/Users/roup/devpub/yang/yang/standard/ieee/published/1906.1/iana-if-type@2020-01-10.yang" nil nil nil)
  find-file("/Users/roup/devpub/yang/yang/standard/ieee/published/1906.1/iana-if-type@2020-01-10.yang")
  dired-find-file()
  funcall-interactively(dired-find-file)
  #<subr call-interactively>(dired-find-file nil nil)
  apply(#<subr call-interactively> dired-find-file (nil nil))
  call-interactively@ido-cr+-record-current-command(#<subr call-interactively> dired-find-file nil nil)
  apply(call-interactively@ido-cr+-record-current-command #<subr call-interactively> (dired-find-file nil nil))
  call-interactively(dired-find-file nil nil)
  command-execute(dired-find-file)
pierre-rouleau commented 3 years ago

I did not notice the 'p' in the imenup-add-defs-to-menubar(). This is a imenu+ function. If I disable the use of imenu+ from my setup, the problem goes away. If I set imenu-generic-expression to something valid inside yang-mode the problem also goes away (with the added benefit of supporting imenu).

The imenu+ issue has to do with it expecting the imenu-generic-expression to be set. This has nothing to do about the yang code. The yang-mode code can stay as is and it's possible to add imenu (and imenu+) support via hooks. But Iit might also be a good idea to have built-in imenu support.

I could provide it if there's an interest.