7

I am new to emacs. I'm trying to use cask to manage emacs packages.

This is my ~/.emacs.d/init.el:

(require 'cask "~/etsi/cask/cask.el")
(cask-initialize "~/etsi")

(require 'evil)
(evil-mode 1)

~/etsi/Cask file:

(source "melpa" "http://melpa.milkbox.net/packages/")
(source "gnu" "http://elpa.gnu.org/packages/")

(depends-on "evil")

However, it does not seem to work. For example, whenever I open a file, there seems to be no evil mode. (Yes I add cask binary to $PATH and ran cask install.)

Looking at other people's publicly available dotfiles, I see they use Cask too and do the same or similar things, so I'm not sure what I did wrong.

I also tried the following for ~/.emacs.d/init.el:

(require 'package)
(require 'cask "~/etsi/cask/cask.el")
(package-initialize)
(cask-initialize "~/etsi")

(require 'evil)
(evil-mode 1)

which also does not work.


Why?

Because I am new to emacs, perhaps I'm doing it wrong, and explaining what exactly I'm trying to achieve might bring forward a more straightforward solution.

Instead of manually M-x package-install RET <package-name> RET for each and every package, I want to simply put a list of them somewhere (in a text file), and have something automatically install them all (and take care of initalization). This is because I want to replicate my emacs setup across multiple machines, and obviously doing M-x package-install RET <package-name> RET for each package on each machine is not desirable.

I thought cask was the correct tool for this, since you can have a Cask file to list your packages. And just use the cask install command to install them. When I ran cask install, it did download and "install" (to .cask directory) evil and its dependencies. But emacs does not seem to load it?

I also tried (add-to-list 'load-path (cask-load-path ((cask-initialize "~/etsi")))) instead of (cask-initialize "~/etsi"), but that did not work either.

Is el-get the right tool for the job instead? Reading the introductory documentation, it wasn't clear that it was, hence why I chose clask, because their documentation specifically said "If you are using Cask for your Emacs configuration [...]".

Edit: Maybe I'm checking for evil mode wrong? Is there a reliable way to check for the existence of a package, i.e. whether or not it has been loaded? I'm checking for evil by just pressing j, or searching for evil mode help with C-h evil.

vyp
  • 243
  • 2
  • 10
  • 1
    Why do you think you need cask? The default package manager is shorter and simpler. I use only the cask shell script for testing. – abo-abo Jun 24 '15 at 14:18
  • 1
    Because of what I said under the why section? Can I do it with the default package manager? If so, how? – vyp Jun 24 '15 at 14:25
  • 2
    I believe that most people have their Cask file within their .emacs.d folder vs. an external folder. Did you give it a shot? If that doesn't work, I believe that it's worth creating a Github issue for your problem? I've never used cask-initialize with arguments. – rimero Jun 24 '15 at 18:07
  • 1
    Do you see an error message when starting Emacs? –  Jun 24 '15 at 19:15
  • @rimero Thanks, I tried but it didn't work. The documentation says that cask-initialize can take an optional "project path" argument. `~/etsi` is just my git cloned dotfiles repository, and so I put that argument because cask created `.cask` folder there (but it also created `.cask` folder in `~/.emacs.d`). But evil does not also seem to load without the argument (I tried that too of course). – vyp Jun 25 '15 at 01:58
  • @lunaryorn No, both when starting `emacsclient` and just `emacs`. Btw, I was looking into using el-get instead for this, and I found [this](http://emacs.stackexchange.com/questions/13048/what-are-the-use-cases-of-alternative-package-managers-vis-%c3%a0-vis-package-el). In short, so how do I do what I want to do with quelpa? I.e. is there more documentation somewhere, or do you know any more example repositories/dotfiles I could look at? I saw [this](https://github.com/steckerhalter/steckemacs.el/blob/master/steckemacs.el) which they linked, but what these "recipes", and where can I read more.. – vyp Jun 25 '15 at 02:15
  • ..about them and the syntax? As in, how exactly would a "recipe" that installs a specific *git hash* version look like? (Or is that not possible? In that other thread, you say ELPA will never be able to install a specific commit hash, but so I'm assuming with el-get/quelpa you can?) Does quelpa have the equivalent of el-get's `el-get-list-package-names-with-status` function as described [here](https://github.com/dimitri/el-get#replicating-a-package-set-on-another-emacs-installation)? Or does quelpa not need that? As in, will quelpa automatically try to install the recipes it sees in the file? – vyp Jun 25 '15 at 02:21
  • Should "file" be `init.el` or `.emacs`, or does it not matter? Lastly, what's the difference between ELPA and MELPA? Do I need ELPA if I use the MELPA repository? Does that even matter with quelpa and using git/vcs versions directly? And what's marmalade, is that generally needed/useful too? Sorry. – vyp Jun 25 '15 at 02:24
  • 2
    Okay figured it out, `~/.emacs` and `~/.emacs.d/init.el` (or I guess any other startup file) are mutually exclusive. I had one line .emacs file. I thought there was a load order or something. i.e. init.el loads before .emacs. For anyone reading in the future, solved by removing `~/.emacs` file (or transferring the contents of that too init.el and then deleting). – vyp Jun 25 '15 at 08:07

1 Answers1

3

Here's how I do it: packages.el.

Cite some code, it's nothing too complex:

;; install required
(dolist (package ora-packages)
  (unless (package-installed-p package)
    (package-install package)))
;; upgrade installed
(save-window-excursion
  (package-list-packages t)
  (package-menu-mark-upgrades)
  (condition-case nil
      (package-menu-execute t)
    (error
     (package-menu-execute))))

And how to use it:

emacs -batch -l packages.el

That's it, after this single shell command all packages from the ora-packages variable will be installed/upgraded.

I have this tied into my Emacs startup, if I want to start Emacs with an upgrade, I type make up. To start without an upgrade, I type make run.

abo-abo
  • 13,943
  • 1
  • 29
  • 43
  • I've seen something like this [here](http://stackoverflow.com/questions/10092322/how-to-automatically-install-emacs-packages-by-specifying-a-list-of-package-name) and [here](http://oli.me.uk/2015/03/03/making-el-get-sync-like-vim-plug/), but can this be used to install specific versions/hashes? Does ELPA even support installing specific revisions? – vyp Jun 24 '15 at 15:04
  • 1
    Specific revisions aren't supported. I don't miss them too much. If you look at my config, I'm using git submodules for that sort of stuff. – abo-abo Jun 24 '15 at 15:24
  • I see, I will have to "fallback" anyway to using package.el, but would you know why cask does not seem to work here still? (Say I want to use it for package *development* or something later.) – vyp Jun 24 '15 at 15:35
  • 1
    For package development, I only use the cask python script. I never actually install cask into Emacs. – abo-abo Jun 24 '15 at 15:59
  • Okay cool. :) I will wait to see if anyone else answers, or if I can figure out it myself, or figure out something else. Otherwise I'll accept your answer. – vyp Jun 24 '15 at 16:01