Question

I have the following code in .emacs:

;yasnippet
;;{{{

(load (concat *my-emacs-lib-dir* "plugins/yasnippet/yasnippet"))
(setq yas/snippet-dirs nil)
(yas/initialize)

;; Develop and keep personal snippets under ~/emacs.d/yasnippets
(setq yas/root-directory (concat *my-emacs-lib-dir* "yasnippets"))
(yas/load-directory yas/root-directory)

;;}}}
(add-hook 'javascript-mode-hook (lambda () (yas/minor-mode-on)))

I have snippet files in *my-emacs-lib-dir* "yasnippets/javascript-mode" and in *my-emacs-lib-dir* "yasnippets/php-mode".

It works well for php-mode and doesn't work for javascript-mode. The settings are identical, the files are ok. What can be the reason?

Was it helpful?

Solution

Are you sure that javascript files are opened in javascript-mode? Look to the value of major-mode variable (with C-h v), and if it's different from javascript-mode, then create new directory with name of this mode, and add the file .yas-parents inside this directory. Put javascript-mode inside this file, and save...

OTHER TIPS

The mode name is js-mode, and the hook is js-mode-hook.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top