0

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
~/.emacs.d/elpa/yasnippet-20170518.1753
#second machine
~/.emacs.d/elpa/yasnippet-20170828.1908

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 '17 at 15:31
  • @bertfred How to accept if it works? – user4035 Sep 20 '17 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 '17 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.