0

I an new to emacs...so i was trying to install ya-snippets for this first i downloaded the ya-snippet tar file and then uzipped it and then kept it .emacs.d/packages/ and then added the following code to my .emacs file

;; yasnippet                                                                    
(add-to-list 'load-path                                                         
          "~/.emacs.d/packages/yasnippet")                                  
(require 'yasnippet)
(yas-global-mode 1)

but my obtaining the following error ...

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

Symbol's function definition is void: yas-global-mode

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.

please tell me the error and as i am new to emacs and please tell what each line is doing my .emacs file written to configure yasnippet ? and please tell me what to add to .emacs file for ya -snippet to use all c/c++ snippets that comes default with it?

user3091069
  • 111
  • 1
  • 3
  • When Emacs throws an error such as `Symbol's function definition is void`, that usually means the package (containing the function) has not been loaded correctly. So you will need to first verify you have a file called `yasnippet.el` at the location of `~/.emacs.d/packages/yasnippet/yasnippet.el` and also verify that file contains a line of code (usually at the bottom): `(provide 'yasnippet)` Perhaps your `yasnippet.el` file is in a different folder (e.g., one folder deeper)? – lawlist Mar 31 '14 at 23:41
  • yes both of these things are present.. i have yasnippet.el in ~/.emacs.d/packages/yasnippet and its last line is (provide 'yasnippet) and then some comments after that line(for ending)! – user3091069 Mar 31 '14 at 23:47
  • How about trying `M-x load-library RET yasnippet RET`? If it loads (with a message *Loading yasnippet...done*), then try `M-x yas-minor-mode`. If both of those steps work, then my next guess is that you have an error in your `.emacs` file (or another library called by your `.emacs` file) and your `.emacs` file is not loading entirely when you start Emacs. In that case, you should see if there are any other error messages in your `*Messages*` buffer when starting Emacs. – lawlist Mar 31 '14 at 23:51
  • when i do M-x load-library RET yasnippet RET it says ...Cannot open load file: cl-lib – user3091069 Mar 31 '14 at 23:56
  • Ahhh . . . . well, then that is a problem, because `Yasnippet` needs the `cl` library which calls other related libraries -- e.g., `cl-lib`. Time to back-up everything to somewhere safe, and then upgrade your Emacs version to a brand spanking new *complete* version. It sounds like the `Yasnippet` installation itself and your load-path are correct. – lawlist Mar 31 '14 at 23:58
  • haha..yup! its better to upgrade to complete new version rather scratching heads to install packages manually! thanks – user3091069 Apr 01 '14 at 00:01

1 Answers1

0

Step One:  Place the following two lines near the top of your .emacs file and restart Emacs:

(require 'package)
(package-initialize)

Step Two:  M-x list-packages

Step Three:  Select Yasnippet with the left mouse click and then click Install, and click Yes.

Step Four:   Open up your .emacs file and place this underneath package-initialize

(require 'yasnippet)

(yas-global-mode 1)

Step Five:  Restart Emacs and have fun coding. The mode-line will display yas when that minor mode is active.

lawlist
  • 13,099
  • 3
  • 49
  • 158
  • i don't have package.el file in ~/.emacs.d folder that is i dont have any package manager..right? thats why i have to install it manually! – user3091069 Mar 31 '14 at 23:26
  • That comes built into the standard version of Emacs -- somewhere on your computer there should be a folder `.../lisp/...` where all the stock files are stored. – lawlist Mar 31 '14 at 23:27
  • i have emacs version 23.3.1..it does not have any default package manager! please guide me through installation of package manager also? – user3091069 Mar 31 '14 at 23:28
  • I'm sorry then, I only have the latest version of Emacs. Perhaps someone else around these forums still uses an older version and can guide you further. Alternatively, consider upgrading your Emacs version. Here is a link to the Github source code for Yasnippet, which provides some basic installation instructions: https://github.com/capitaomorte/yasnippet – lawlist Mar 31 '14 at 23:30
  • i have followed the same instructions while installing it! – user3091069 Mar 31 '14 at 23:39