adding package-repositories to emacs - emacs

I need to add various packages to my emacs installation. It comes with tromey as the only repository. The variable package-archives is not defined (!). I am running GNU Emacs version 24.3.1 on Linux. I set up the following code in my .emacs file:
(when (>= emacs-major-version 24)
(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives '())
(package-initialize)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives
'("gnu" . "http://elpa.gnu.org/packages/"))
(add-to-list 'package-archives
'("marmalade" . "https://marmalade-repo.org/packages/"))
(add-to-list 'package-archives
'("org" . "http://orgmode.org/elpa/") t)
(add-to-list 'package-archives
'("tromey" . "http://tromey.com/elpa/") t)
)
By default, without this code, the variable package-archives isn't defined. After running this code, it is, and contains the right values, but doesn't seem to have any effect. I verified that this variable is not customized anywhere.
The problem is that I don't get to see any packages from the various archives I added; Only from tromey. Obviously I'm doing something wrong, but this code is supposed to work from emacs version 24 and higher.
Can someone suggest how to set up my repositories properly?

Everything worked well! What does that mean? That something in my .emacs file is conflicting with elpa?
That's exactly what it means.
Comment out half of your configuration (comment-dwim, bound to C-; by default, might be helpful here) and see if that fixes it. That will tell you which have contains the ELPA conflict. Repeat with the half that shows the problem to find which quarter is problematic, then again to find the eighth…
Pretty soon you'll find the cause, which might be a single sexp. Remove or adjust that, uncomment the rest of your config, and enjoy the plethora of packages that await.

Related

New to Emacs, issue with Melpa

I followed their guide on github and put the following in my init.el file:
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line
However when I go M-x package-list-packages I either get a Melpa not found error or a 'missing zlib library' error, and it only shows the gnu packages. I've also tried using stable Melpa, to no avail. I'm using windows 10 and set a HOME variable pointing to the directory with the 'init.el' file.

package-install can't find icicles

I'm trying to install icicles in Emacs because I've read it makes for a more clear emacs experience. The problem is, even though I'm loading the Melpa repositories, and Checked melpa for if the package was available (it was) If I try package-install on it, it returns [no match].
I've tried package-refresh-contents to na avail. Please help with this, I could do it manually, but AUGH!
Just for context, here's the contents on my .emacs:
;; packages
(require 'package)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")
("marmalade" . "https://marmalade-repo.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(add-to-list 'load-path "~/.emacs.d/elisp")
(defun require-package (package)
(setq-default highlight-tabs t)
"Install given PACKAGE."
(unless (package-installed-p package)
(unless (assoc package package-archive-contents)
(package-refresh-contents))
(package-install package)))
(package-initialize)
(load-theme 'zenburn t)
(require 'php-mode)
(eval-after-load 'php-mode
'(require 'php-ext))
(add-to-list 'auto-mode-alist '("\\.json$" . js-mode))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes (quote ("f5eb916f6bd4e743206913e6f28051249de8ccfd070eae47b5bde31ee813d55f" default))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;;
Thanks in advance, all help is very much appreciated
Icicles is no longer distributed on ELPA or MELPA:
NOTE:
Icicles, as well as my other libraries that are on EmacsWiki, used to be obtainable also from MELPA. You may still find some of them there, but they are likely not up-to-date.
As of 2017-10, MELPA has decided to no longer accept Lisp libraries from EmacsWiki. This includes my libraries, even though these libraries are read-only (administrator lock on the wiki pages). Too bad. This means that you must download Icicles and my other libraries only from Emacs Wiki. Sorry about that. I upload Icicles files only to the wiki.
https://www.emacswiki.org/emacs/Icicles_-_Libraries
Solved the problem by doing M-x eval-buffer on my .emacs.

Missing packages from GNU Emacs

I’m been wanting to install a number of new packages for Emacs. mmm-mode, multi-web-mode, and smart-tab-mode are a few examples. But I don’t seem to be able to find them when I run
M-x package-list-packages
I have this in my .emacs file:
(require 'package)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/"))
(package-initialize)
And when I run package-list-packages I can see that it contacts all those different hosts. I use C-s to search for them, they aren’t there. What am I doing wrong?
My Emacs version is displayed as: Version 24.2 (9.0)
URL for Melpa was too short: it should be http://melpa.milkbox.net/packages/
You've mixed up the order. It goes like this:
(package-initialize)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
The ELPA/package system is a relatively new addition to Emacs. It is far from the case that all libraries are available as packages, but similarly it is not necessary for a library to be packaged in order to use it with Emacs.
If a library you wish to use is unavailable through any of the package repositories, simply follow the installation/usage instructions which (generally) can be found in the accompanying documentation for the library (either in the .el file's commentary, or as a separate file).
(You will at minimum need to ensure that the files are located in a directory which is in Emacs' load-path, but the exact details thereafter will vary depending upon the purpose of the library in question.)

Slime mode error

I was following the guide and information from A gentle tutorial to Emacs/Swank/Paredit for Clojure
However after opening elpa and installing clojure-mode, slime and paredit. I restarted emacs and then attempted to use M-x slime however it continually says no match . What am I doing wrong?
I then tried to install clojure-mode from marmalade http://marmalade-repo.org/packages I byte-compiled package el and then added
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) to my.emacs. However marmalade errors with
Symbol's value as variable is void: package-archives .
Unsure exactly what I am doing wrong I am on windows7 using emacs 23.3. I have clojure installed to c:/clojure.
Any help appreciated.
My init.el has both (require 'package) and (package-initialize). It's not very big, it looks like this:
(require 'package)
;; Add the original Emacs Lisp Package Archive
(add-to-list 'package-archives
'("elpa" . "http://tromey.com/elpa/"))
;; Add the user-contributed repository
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
I'm on emacs 24 (a development build) on Windows 7. I had trouble getting emacs 23 to work with packages too, it was easier for me to just upgrade.
By the way, I noticed that if I set a HOME environment variable, emacs looks there for the .emacs.d directory (instead of in %USER_PROFILE%\AppData\Roaming).
Download package.el (don't follow the instructions on the ELPA site, just download the package.el provided on marmalade's site).
Put package.el in your .emacs.d directory (~/.emacs.d/).
Add the following to your .emacs file (~/.emacs):
;;Load path to my packages
(add-to-list 'load-path "~/.emacs.d/")
;;Load ELPA (the package.el you downloaded from marmalade)
(require 'package)
;;Load Marmalade (the code found on marmalade's welcome page)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
That's it! I really hope this helps.
EDIT: Sorry, I forgot to mention that you need to add (package-initialize) at the end of the code I provided. If you don't add this line, the packages will install, but won't load.
I think, that you need to put
(require 'package)
before 'add-to-list'
P.S. and add following call after 'add-to-list'
(package-initialize)
this command will load installed packages and activate them
P.P.S. '(require 'package)' maybe not needed, but I'm personally not using 'package.el'
It seems to me you're missing either (require 'package) or (package-initialize). You can check out my setup here - I'm using both marmalade and clojure-mode on Windows 7 and it works like a charm.
Do not know it is same problem, I faced when I were trying to use quicklisp's swank/slime
Finally I found that few /contrib/*.el packages were dependent on each other
if A's dependency package is B, if B is not byte-compiled than A will not compile
when you do
(require 'A)
it will throw
Symbol's variable value is void: A
So ensure you compile each package than try require.

What's the magic behind the ELPA?

I use Aquamacs, and I use ELPA that installs files in ~/.emacs.d/elpa?
What's the magic behind this ELPA? I mean, without ELPA, I should download and install the packages in a specific directory, and add those two lines in .emacs.
(add-to-list 'load-path "PACKAGE_DIRECTORY")
(require 'PACKAGE)
But, with ELPA, I don't see anything added to .emacs or /Users/smcho/Library/Preferences/Aquamacs Emacs/{Preferences.el, customizations.el}. How is this possible?
Added
This is what I found with Aquamacs.
Aquamacs reads ~/Preference/Aquamacs Emacs/Preference, and it has "(add-to-list 'load-path kitfiles-dir)(require 'init)", which reads start kit.
The init.el of start kit has the "(require 'package)(package-initialize)"
~/Library/Preferences/Aquamacs Emacs/aquamacs-emacs-starter-kit/vendor has the package.el
I guess the initialization files are not changed, but the package manager reads the ~/.emacs.d/elpd/* to initialize automatically, as I see ***-autoloads.el in each of it.
Added2
With emacs 24, it seems that package is pre-built. I need only to have these lines in .emacs or .emacs.d/init.el to get ELPA working. Hints from this site.
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar my-packages '(clojure-mode
nrepl))
(dolist (p my-packages)
(when (not (package-installed-p p))
(package-install p)))
(package-initialize) will go through all the installed packages (in ~/.emacs.d/elpa/ or similar, depending on configuration), and add them to the load path. One you have run it, take a look at load-path (C-hvload-path), it will have all those subdirectories added. So at this point, file loading will use the normal mechanisms.
You have a (require 'package) (package-initialize) pair somewhere in your initialization files. Package.el does the magic :)