Avoiding version numbers from elpa in my init.el file

146 views Asked by At

How do I avoid hardcoding version numbers in my load paths when writing my init.el file?

Every time I go through and update my packages, I have to do the same in my init.el file.

It'd be great if I could do something like this:

(setq yas-snippet-dirs
      '("~/.emacs.d/snippets/"
       (regexp-quote "~/.emacs.d/elpa/yasnippet-[.*]/snippets/"))

This wasn't working for me, but then again I tried kludging it together from this example real fast, so honestly I'm not surprised. Can someone let me know if this is the preferred way of handling this, and if so, how you'd go about doing it?

2

There are 2 answers

1
juanleon On BEST ANSWER

I think you are looking for something like this:

(setq yas-snippet-dirs
    '("~/.emacs.d/snippets/"
     (file-expand-wildcards "~/.emacs.d/elpa/yasnippet-*/snippets"))

But I think you don't need it...

For load-path variable... package-initialize should update it automatically, so this would not be needed.

For yas-snippet-dirs installed with elpa... just doing M-x yas-global-mode sets the value of that variable just to what you want.

0
lawlist On

One option would be to change the folder names inside the elpa directory, and take a look at the . . . autoload.el to make sure there is no special reference to a folder with a version number. NOTE:  You may need to add the autoload.el file specifically so that it gets loaded on startup -- the file should be called after the load-path is defined within your init.el file.

Alternatively, set-up a subdirs system similar to what is used in the Emacs source so that all specified sub-folders are in the load-path, but you would still need to add new folder names and specifically call the autoload.el file after the load path is defined.

FYI: There is no requirement that your snippets be placed in that directory. You could put them somewhere else where the change in versions will not affect their location.