2

I tried to install verilog-mode from github to replace the version built in to Emacs.

I'm using spacemacs. I created a layer for verilog and added verilog-mode in packages.el:

(verilog-mode :location (recipe
                         :fetcher github
                         :repo "veripool/verilog-mode"))

I have enabled the verilog layer but the verilog-mode is still the built-in version.

How could I make spacemacs use the version from Github?

2

To install a package by using a layer, you need to add the pacakge to the layer's packages list, write an init function for the package, and enable the layer. It appears that you did not write an init function. The init function is necessary for Spacemacs to install the package, but it can be empty if no configuration is needed for the package.

When trying to override a built-in package with a newer version, use the :min-version keyword to specify a version that is higher than the built-in one and lower or equal to the desired version. :min-version should be a version string, similar in format to emacs-version.

Assuming your layer is called verilog, its packages.el file should look like this:

(defconst verilog-packages
  '((verilog-mode :location (recipe :fetcher github
                                    :repo "veripool/verilog-mode"
                                    :min-version "1"))))

(defun verilog/init-verilog-mode ()
  ;; ... verilog configuration goes here ...
  )

And of course don't forget to enable the layer by adding it to dotspacemacs-configuration-layers.

To make sure that :min-version is newer than the built-in version, you can use this next small snippet. It is meant to be used interactively before installing the newer version:

(package-installed-p 'verilog-mode (version-to-list "1"))

Another approach is to install verilog-mode as an additional package. In this approach, you install the package by adding it to dotspacemacs-additional-packages. The same entries that fit in a layer's packages list also fit in dotspacemacs-additional-packages. In your case, you'd add this as an entry:

(verilog-mode :location (recipe :fetcher github :repo "veripool/verilog-mode" :min-version "1"))

And any configuration for verilog-mode goes in dotspacemacs/user-config.

6
  • I do have a init function init-verilog-mode, but it still doesn't install from github. – Enze Chi Sep 1 '16 at 10:28
  • Did you name the function init-verilog-mode? The function name must be <layer>/init-<package>, so in this case verilog/init-verilog-mode (I fixed the name in the answer) – bmag Sep 1 '16 at 18:37
  • I did name the function verilog/init-verilog-mode and I can see the variables I set in that function have the expected value. Just the verilog-mode is still the builtin one. – Enze Chi Sep 4 '16 at 22:52
  • Earlier I didn't run the code myself. Now I have and realized that :min-version needs to be specified as well. Updated my answer. – bmag Sep 5 '16 at 19:32
  • I think the verilog-mode is a little bit tricky. I don't know how to find the version number. Now I have to manually copy the repo to local directory under verilog layer and install it from there. – Enze Chi Sep 5 '16 at 23:52

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.