Is there a way to install ELPA packages from command line? - emacs

I'm interested in standardizing the emacs configurations that a few of us use (~5 people).
Is there a way to install ELPA packages from lisp functions that can be included in a script if we know the set of packages we want? All I can find is how to call up list-packages and install individual packages graphically.

What you need is to use package-install function, like:
(mapc 'package-install install-list)
the install-list variable should contain a list of names of packages that you want to install.

Another thing you can do it make your own package that depends on the other packages that you want installed. Then install that package.
Packages can be installed from file with:
M-x package-install-from-file
or you can make your own package archive with the package in, you can use elpakit to do that.
You can also do this from the command line:
emacs -e "(progn (package-initialize)(package-install 'packagename))"
to install from the operating system command line if you wish.

You may also want to take a look at cask. It allows you to declare the packages you want to install in file named Cask using a DSL described here. Then from the command line go to the directory and run cask. It will install all the packages declared in the Cask file.
In you init file you will need to add the following lines to use the packages installed by cask.
(require 'cask "~/.cask/cask.el")
(cask-initialize)

In addition you can get the list of already installed ELPA packages by
(defun eab/print-0 (body)
"Insert value of body in current-buffer."
(let ((print-length nil)
(eval-expression-print-length nil))
(prin1 `,body (current-buffer))))
(defun eab/package-installed ()
"Get the list of ELPA installed packages."
(mapcar (lambda (x) (car x)) package-alist))
(eab/print-0 (eab/package-installed))
and the same for el-get packages
(defun eab/el-get-installed ()
"Get the list of el-get installed packages."
(mapcar 'intern
(el-get-list-package-names-with-status "installed")))
(eab/print-0 (eab/el-get-installed))

Related

Unable to install cider to emacs - package not found

Fresh install of Ubuntu 20.04
Added openjdk-11 and lein 2.9.3
$ sudo apt-add-repository ppa:kelleyk/emacs
Installed
GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14)
of 2020-03-26, modified by Debian
Tried the instructions on the cider Getting Started page
M-x package-refresh-contents
M-x package install <RET>
cider <RET>
The cider package isn't found. Tried to package-list-packages - list doesn't contain cider.
What am I missing?
Finally did the steps from the following link to get it to work
Brave Clojure book companion repo
Not sure why the cider instructions don't mention this.
You need to create a ~/.emacs.d/init.el file with the following contents
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
Save and restart emacs.
M-x package-list-packages check the archive column shows packages from gnu as well as melpa archives.
Sometimes you would see an error Failed to download ‘gnu’ archive. - this one is a flaky one. A restart and/or M-x package-refresh-contents fixed it for me.
Now we have the sources configured correctly.
Install:
M-x package-install <RET> cider <RET>
M-x package-list-packages - Move to the end of the listing to see Status=installed packages.
Test: M-x cider-jack-in. Answer no to the prompt indicating you are not in a clojure project. Soon you should be dropped to a user> prompt - ready to REPL and roll.
You may also consider trying out popular existing "bundle setups' like Spacemacs and Prelude Both of which have all the tooling necessary for Clojure development built-in.
Instead of modifying .emacs or init file manually, you can just change the package-archives variable by typing the following:
M-x customize-variable package-archives
By default, you should only have a GNU source set. Go ahead and add Melpa's name and URL (https://melpa.org/packages/) too by clicking INS. Then apply the changes. Next, type the following commands into the terminal:
M-x package-refresh-contents [RET]
M-x package-install [RET] cider [RET]
You should be all set.
CIDER is available on the two major package.el community maintained repos - MELPA Stable and MELPA.
After adding the following in my ./emacs, i could install CIDER.
(setq package-archives
'(("Elpa" . "https://elpa.gnu.org/packages/")
("Melpa Stable" . "https://stable.melpa.org/packages/")
("Melpa" . "https://melpa.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/"))
package-archive-priorities
'(("MELPA Stable" . 10)
("GNU ELPA" . 5)
("MELPA" . 0)))

Emacs : install a package with melpa on windows

I am trying to install a package with emacs melpa package manager.
The github page says that the package multiple-cursors is available with melpa.
But when I try to install or list this package using M-x package-install multiple-cursors, the package is not found.
I am using emacs version 24.5.1 on windows. I have tried to add the following lines to my init.el file :
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
What's wrong ? How shall I proceed to install this package ?

Matlab-emacs integration - Symbol's value as variable is void: letion

I am new to emacs and I was trying to install the Matlab mode for emacs following the instruction on this page:
matlab script editing
Everything compiled fine, but I ran into this error:
Symbol's value as variable is void: letion
When I did "emacs --init-debug" it gave me the following:
Debugger entered--Lisp error: (void-variable letion)
eval-buffer(#<buffer *load*> nil "/home/wjlee/.emacs" nil t) ; Reading at buffer position 404
load-with-code-conversion("/home/wjlee/.emacs" "/home/wjlee/.emacs" t t)
load("~/.emacs" t t)
#[0 "\205\262
I googled around a bit and some people said it's related to using older versions of emacs (emacs23 or older), however, I have emacs24.3.1, so I am not sure why this is still the case. Does anyone know how to fix this, please?
I decided to go a clean install of emacs24.3.1 again, without recompiling cedet and the matlab-emacs components, and somehow it works now... It seems like (from what I found on the web) although the newest version of CEDET is not bundled with emacs24, those that are already in there is enough for me to do the matlab-emacs integration.
Since I am very new to using all these, I'll just post what I found here:
To do a clean install of emacs24:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:cassou/emacs
sudo apt-get update
sudo apt-get purge emacs-snapshot-common emacs-snapshot-bin-common emacs-snapshot emacs-snapshot-el emacs-snapshot-gtk emacs23 emacs23-bin-common emacs23-common emacs23-el emacs23-nox emacs23-lucid auctex emacs24 emacs24-bin-common emacs24-common emacs24-common-non-dfsg
sudo apt-get install emacs24 emacs24-el emacs24-common-non-dfsg
sudo rm /etc/apt/sources.list.d/cassou-emacs-precise.list
Download matlab.el:
cvs -d:pserver:anonymous#matlab-emacs.cvs.sourceforge.net:/cvsroot/matlab-emacs login
cvs -z3 -d:pserver:anonymous#matlab-emacs.cvs.sourceforge.net:/cvsroot/matlab-emacs co -P matlab-emacs
And modify ~/.emacs:
(add-to-list 'load-path "~/.emacs.d/matlab-emacs")
(load-library "matlab-load")
I also found the following useful:
(custom-set-variables
'(matlab-shell-command-switches '("-nodesktop -nosplash")))
And some short-cuts:
Some useful short cuts to begin with:
C-c C-r : run region in matlab
C-c C-s : save and run the file in matlab
C-c C-c E : insert a matching END statment
M-TAB : symbol/variable completion based on the script
M-s : brings up matlab-shell (in a different buffer if available)
M-p, M-n : in matlab-shell (or any emacs shell) cycle through past commands

Emacs Autocomplete: the function `define-package` is not known

I am trying to install autocomplete mode on OS X 10.8.4 using emacs 24 installed through brew.
I have cloned autocomplete through git git mirror here and I'm following the build instructions build instructions here. I am getting an error during make install telling me that define-package (presumably some elisp) is undefined.
➜ auto-complete git:(master) make install
emacs -Q -L . -batch -l etc/install
Install to: ~/.emacs.d/
Installing to ~/.emacs.d/ from /Users/f/src/auto-complete/
In toplevel form:
auto-complete-config.el:31:1:Error: Cannot open load file: popup
In end of data:
auto-complete-pkg.el:5:1:Warning: the function `define-package' is not known
to be defined.
Wrote /Users/f/src/auto-complete/auto-complete-pkg.elc
In toplevel form:
auto-complete.el:51:1:Error: Cannot open load file: popup
83117999910111511510211710810812132105110115116971081081011003310106510010032116104101321021111081081111191051101033299111100101321161113212111111711432461011099799115581010409710010045116111451081051151163239108111971004511297116104323412647461011099799115461004734411040114101113117105114101323997117116111459911110911210810111610145991111101021051034110409799459911111010210510345100101102971171081164110
Anybody encounter this before / have a fix?
Install using Melpa or Marmalade via package.el. Auto-complete expects to be installed this way, and you'll also get updates installed very easily.
If you don't have package.el configured already, add the following to .emacs or .emacs.d/init.el
(setq package-archives
'(
("marmalade" . "http://marmalade-repo.org/packages/")
("elpa" . "http://tromey.com/elpa/")
("melpa" . "http://melpa.milkbox.net/packages/")
("gnu" . "http://elpa.gnu.org/packages/")
))
(package-initialize) ;; init elpa packages
Just run M-x package-list-packages (or M-x p-l-p TAB) and install auto-complete from the package list, mark packages with i use x to run the installation of marked packages.
Periodically, opening M-x package-list-packages and pressing U will mark installed packages for updating, press x to run the updates.
This is assuming Emacs 24.

Emacs Yasnippet install

trying to install yasnippet for emacs 23 from https://github.com/joaotavora/yasnippet
Firstly I attempted the quick install but the yasnippet-bundle.el for the 'quick' install doesn't seem to be in the repository?
Secondly I attempted the full install.
When trying to do the full install I get the following error:
[yas] Check your `yas/snippet-dirs': ~/.emacs.d/snippets is not a directory
I have downloaded the latest bundle joaotavora-yasnippet-e53c41d/ and unpacked in into .emacs.d/plugins/
the addition to my `.emacs' is:
(add-to-list 'load-path
"~/.emacs.d/plugins/joaotavora-yasnippet-e53c41d")
(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
(yas/load-directory "~/.emacs.d/plugins/joaotavora-yasnippet-e53c41d/snippets")
Basically, the install instructions seem to have become out of sync with the latest src. Does anyone know how to install it?
You need to initialize yas/root-directory. Here is how I setup yasnippet
(require 'yasnippet "~/emacs/addons/yasnippet.el")
(yas/initialize)
(setq yas/root-directory "~/emacs/snippets")
(yas/load-directory yas/root-directory)