joaotavora / yasnippet

A template system for Emacs
http://joaotavora.github.io/yasnippet/
2.78k stars 313 forks source link

Can not test snippet for unkown major mode when test-yas/snippet #1129

Open zw963 opened 2 years ago

zw963 commented 2 years ago

Following is context.

  1. I create a folder, named flutter.
  2. Add .yas-parents.el, content: "dart-mode" (i have another folder, named: dart-mode)
  3. Then i add new snippet in flutter folder.
  4. after done, i run test-yas/snippet
  5. it give me two candidates(use completion), one flutter, one dart-mode
  6. i select dart-mode
  7. get this error.

In fact, the reason i am not place all snippets in dart-mode folder. is category. if i add sub folder, e.g. like this: 'snippets/dart-mode/flutter/some_snippet', when i want to try this snippet use test-yas/snippet, it never work, because it treat flutter as the only candidate, however, the mode i expected to run is dart-mode.

Thank you.

nfedyashev commented 2 years ago

I'm not familiar with Dart/Flutter projects but

This is probably doable using yasnippet's condition mechanism which runs any elisp code.

For example,

# condition: (cl-search "some/category/in/your/project/" buffer-file-name)
zw963 commented 2 years ago

I consider the real issue is, i create two folder, dart-mode, flutter, but no a emacs mode named flutter, that cause this issue, though, i point out, it parent mode should be exists dart-mode.