I have Emacs installed on multiple machines, and every time I install yasnippet through elpa. As it's version changes, it is being installed into different directories. For example:

#first machine
#second machine

In ~/.emacs I have the following code:

(defvar *my-emacs-lib-dir* "d:/bin/cygwin/home/user/.emacs.d/")
(defvar *yasnippet-dir* "~/.emacs.d/elpa/yasnippet-20170518.1753")
(load-file (concat *my-emacs-lib-dir* "bootstrap-init.el"))

in bootstrap-init.el I load yasnippet library:

(load (concat *yasnippet-dir* "/yasnippet"))
(yas/global-mode 1)

Is it possible to get path to installed yasnippet library from elpa database? So I won't need to modify *yasnippet-dir* on every machine?

  • 1
    (file-name-directory (locate-library "yasnippet"))
    – bertfred
    Sep 20, 2017 at 15:31
  • @bertfred How to accept if it works?
    – user4035
    Sep 20, 2017 at 16:15
  • 1
    You should be able to do (load "yasnippet"), or (require 'yasnippet) as long as you call package-initialize first. Actually even just (yas-global-mode 1) without loading should work since it's autoloaded.
    – npostavs
    Sep 20, 2017 at 16:41


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.