package-install can't find icicles - emacs

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.

Related

Setting up emacs on new machine with init.el and package installation

Like presumably many emacs users I have my own emacs config file ~/.emacs.d/init.el for configuring emacs the way I like. So when I start using a new machine I copy my emacs config file to it. Now, the problem is that my emacs config file depends on a few packages that I have installed via the emacs package manager, but due to the missing packages I'm unable to successfully install packages.
I can of course start emacs without my config file (emacs -q), but then the problem is that only the default repo is available, so I cannot actually install the package I need to install in order to successfully start emacs with my config file.
So what I have usually done is to temporarily comment out stuff in my emacs config file, so that I'm able to successfully install the packages, and then I can uncomment it and restart emacs with my full config. But this is cumbersome, and usually takes a few tries before I comment out all the needed stuff. Surely there must be a better way that I'm missing?
What you can do is to declare packages you use. Then add some code that runs every time you open Emacs. It checks each package from that list if it has been installed or not. When it's not, it installs it.
A quick example from my config file:
;; first, declare repositories
(setq package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.org/packages/")))
;; Init the package facility
(require 'package)
(package-initialize)
;; (package-refresh-contents) ;; this line is commented
;; since refreshing packages is time-consuming and should be done on demand
;; Declare packages
(setq my-packages
'(cider
projectile
clojure-mode
expand-region
helm
jinja2-mode
magit
markdown-mode
paredit
wrap-region
yaml-mode
json-mode))
;; Iterate on packages and install missing ones
(dolist (pkg my-packages)
(unless (package-installed-p pkg)
(package-install pkg)))
And you're good.
You can place the initialization elisp that installs the packages you need in a separate file, then start emacs -q, then load and evaluate the packages elisp file.
I'm using the following code, in a file of its own, to handle packages. This code also defines the packages I'm using and allows for dynamically adding and loading packages.
If you load this file first thing from your init.el, then you would probably be able to just start Emacs as usual, and missing required packages will be installed automatically.
Update
I was somewhat bothered with the way I used defvar to define the package list variable. I've done some reading and fixed the code below—now it defvar a variable my-packages-package-list and then setq it to the list of packages to install. As far as I understand, this is a more idiomatic way of defining and using variables. As a result, this code now byte-compiled without any warnings.
For those who are interested, some information of using defvar and setq may be found here and in the Emacs` manual.
(require 'package)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
;; ("marmalade" . "https://marmalade-repo.org/packages/")
("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")))
(setq package-archive-priorities '(("melpa" . 10)
("gnu" . 5)
("org" . 2)
;; ("marmalade" . 0)
))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
;; the following code will install packages listed in myPackages if
;; they are not already installed
;; https://realpython.com/emacs-the-best-python-editor/
(defvar my-packages-package-list "List of custom packages to install.")
;;; this allows for dynamically update and install packages while
;;; Emacs is running, by modifying this list, and then evaluating it
;;; and tha mapc expression below it
(setq my-packages-package-list
'(;; add the ein package (Emacs ipython notebook)
ein
;; python development environment
elpy
;; beutify python code
py-autopep8
;; git emacs interface
magit
;; debuggers front end
realgud
;; multiple major mode for web editing
;; multi-web-mode
;; major mode for editing web templates
web-mode
;; docker modes
docker-compose-mode
dockerfile-mode
;; list library for emacs
dash
;; collection of useful combinators for emacs lisp
dash-functional
;; major modes for yaml
yaml-mode
;; major modes for markdown
markdown-mode
;; major modes for lua
lua-mode
;; major modes for fvwm config files
fvwm-mode
;; treat undo history as a tree
undo-tree
;; flychek
;; flychek-clojure
;; flychek-pycheckers
;; Clojure for the brave and true - below; amit - some packages
;; commented out by me until I'll be sure they are needed
;; makes handling lisp expressions much, much easier
;; Cheatsheet: http://www.emacswiki.org/emacs/PareditCheatsheet
paredit
;; key bindings and code colorization for Clojure
;; https://github.com/clojure-emacs/clojure-mode
clojure-mode
;; extra syntax highlighting for clojure
clojure-mode-extra-font-locking
;; integration with a Clojure REPL
;; https://github.com/clojure-emacs/cider
cider
;; allow ido usage in as many contexts as possible. see
;; customizations/navigation.el line 23 for a description
;; of ido
;; ido-ubiquitous
;; Enhances M-x to allow easier execution of commands. Provides
;; a filterable list of possible commands in the minibuffer
;; http://www.emacswiki.org/emacs/Smex
;; smex
;; project navigation
;; projectile
;; colorful parenthesis matching
rainbow-delimiters
;; solarized theme
solarized-theme
;; edit html tags like sexps
;; tagedit
;; help finding keys
which-key
;; xkcd
xkcd
;; Clojure exercises
4clojure
))
(mapc #'(lambda (package)
(unless (package-installed-p package)
(package-install package)))
my-packages-package-list)

How do you "import" the github MELPA fetcher?

I get Symbol's value as variable is void: github when I have the following in my .emacs file (the error comes from the last expression):
(require 'package)
(add-to-list 'package-archives
'("MELPA Stable" . "http://stable.melpa.org/packages/") t)
(add-to-list 'package-archives
'("gnu" . "http://elpa.gnu.org/packages/") t )
(package-initialize)
(package-refresh-contents)
(package-install 'flycheck)
(global-flycheck-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.
'(package-selected-packages (quote (haskell-mode idris-mode flycheck))))
(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.
;; If there is more than one, they won't work right.
)
(add-hook 'after-init-hook #'global-flycheck-mode)
(idris-mode
:repo "idris-hackers/idris-mode"
:fetcher github
:files (:defaults "logo-small.png"))
It looks like the last expression in your .emacs file comes from the MELPA recipe for idris-mode. You don't need that in your init file - just type M-x list-packages, find idris-mode in the list, and install it by typing i x. After that, idris-mode will be available every time you start Emacs.

adding package-repositories to 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.

Emacs: list-packages [no match]

I'm new to Emacs. I'd like to install a package, but doing M-x package-install says there is no such command.
Trying to look which packages are installed with M-x list-packages does not work either. GNU Emacs manual does not say much about it (or I looked in a wrong place), and I can't quite come up with meaningful keywords for search due to my limited Emacs knowledge.
Thanks phils and shyamupa for setting me on track. Indeed, I am using emacs 23 ("M-x version" to check).
I used instruction from here to install packaging system. I had to copy the following in scratch:
(let ((buffer (url-retrieve-synchronously
"http://tromey.com/elpa/package-install.el")))
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
(re-search-forward "^$" nil 'move)
(eval-region (point) (point-max))
(kill-buffer (current-buffer))))
and then M-x eval-buffer
Then, M-x package-list-packages works.
UPDATE:
It turns out I was looking for a package in MELPA, and the above procedure sets you up for ELPA only. The content of my .emacs file after installation was following:
(when
(load
(expand-file-name "~/.emacs.d/elpa/package.el"))
(package-initialize))
To enable MELPA load I had to replace the contents of package.el with this and change .emacs as follows (inspired by this SO question):
(load (expand-file-name "~/.emacs.d/elpa/package.el"))
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(package-initialize)
This did the trick and I got a huge list of packages from MELPA. Hope this will save someone time in future.

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 :)