Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing YASnippet

I have installed YASnippet and configured it with this:

(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet-0.6.1c")
(require 'yasnippet) ;; not yasnippet-bundle

(yas--initialize)
(yas/load-directory "~/.emacs.d/packages/yasnippet-0.6.1c/snippets")

However, when I launch Emacs it gives me an error:

Warning (initialization): An error occurred while loading `/home/alexander/.emacs':

Symbol's function definition is void: yas--initialize

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet-0.6.1c")
(require 'yasnippet) ;; not yasnippet-bundle

(yas--initialize)
(yas/load-directory "~/.emacs.d/packages/yasnippet-0.6.1c/snippets")

What am I doing wrong? I have tried to find the answer but with no success. (I have also tried with another version of yasnippet yasnippet-0.6.1b but it was the same.)

like image 899
AlexanderNajafi Avatar asked Oct 31 '12 19:10

AlexanderNajafi


2 Answers

Just at a glance, that

(yas--initialise)

should be

(yas/initialize)

I'm running 0.6.1 and there's no such function as yas--initialize in the package.

My init code looks like

(require 'yasnippet)
(yas/initialize)
(yas/load-directory
 (dot-emacs "elpa/yasnippet-0.6.1/snippets"))

I think you just got some garbled init code somewhere.

EDIT

I should have omitted the load-directory call in my sample since it's beside the point. But for what it's worth, dot-emacs is just a config-agnostic function I use to reference files relative to my init:

(defun dot-emacs (relative-path)
  "Return the full path of a file in the user's emacs directory."
  (expand-file-name (concat user-emacs-directory relative-path)))
like image 149
harpo Avatar answered Nov 20 '22 12:11

harpo


FYI in case you ever upgrade: the information you got is correct for version 0.8, but for 0.7 and below yas/initialize is correct. See this commit

like image 4
bcasiello Avatar answered Nov 20 '22 12:11

bcasiello