I am setting up my archlinux-desktop in mainland China. While configuring ELPA for emacs, it turned out that (at least) the following archives are not available:
(setq package-archives '(
("gnu" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
Reason: Connections cannot be established and are aborted
On https://www.emacswiki.org/emacs/ELPA I found a remark:
Emacs users in China mainland can use popkit.org
(http://elpa.popkit.org/) archive:
(add-to-list 'package-archives '("popkit" . "http://elpa.popkit.org/packages/"))
In addition I found basically all relevant (and more) repositories on http://elpa.emacs-china.org/
ELPA | 镜像地址
-----------------------+---------------------------------------------------
GNU ELPA | http://elpa.emacs-china.org/gnu/
MELPA | http://elpa.emacs-china.org/melpa/
MELPA Stable | http://elpa.emacs-china.org/melpa-stable/
Marmalade | http://elpa.emacs-china.org/marmalade/
Org | http://elpa.emacs-china.org/org/
Sunrise Commander ELPA | http://elpa.emacs-china.org/sunrise-commander/
user42 ELPA | http://elpa.emacs-china.org/user42/
This brings two questions:
- Why are the official repositories not accessible from within China?
- Is it secure to download from these sources?
Related
I have a problem. If I copy any official code to enable package such elpy into my configuration I get:
Symbol's function definition is void: use-package
(use-package elpy
:ensure t
:init
(elpy-enable))
Please put this before using use-package:
(require 'package) ; Bring in to the environment all package management functions
;; A list of package repositories
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")
("elpa" . "https://elpa.gnu.org/packages/")))
(package-initialize) ; Initializes the package system and prepares it to be used
(unless package-archive-contents ; Unless a package archive already exists,
(package-refresh-contents)) ; Refresh package contents so that Emacs knows which packages to load
;; Initialize use-package on non-linux platforms
(unless (package-installed-p 'use-package) ; Unless "use-package" is installed, install "use-package"
(package-install 'use-package))
(require 'use-package) ; Once it's installed, we load it using require
;; Make sure packages are downloaded and installed before they are run
;; also frees you from having to put :ensure t after installing EVERY PACKAGE.
(setq use-package-always-ensure t)
I've got this in my init.el:
(require 'package)
(package-initialize)
(setq package-enable-at-startup nil)
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Bootstrapping use-package
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile (require 'use-package))
(use-package use-package
:config
(setq use-package-always-ensure t))
As far as I understand, this should be good to install all the packaged listed in
'(package-selected-packages
(quote
(org org-plus-contrib org-ref techela tuareg haskell-mode gnuplot gnuplot-mode helm-ispell ac-ispell paredit ox-tufte auctex json org-grep iedit wgrep helm geiser slime-company company-jedi zzz-to-char rainbow-delimiters avy ivy projectile twittering-mode zerodark-theme pretty-mode flycheck-clang-analyzer flycheck-irony flycheck yasnippet company-c-headers company-shell company-irony irony irony-mode company-lua mark-multiple expand-region popup-kill-ring dmenu ido-vertical-mode ido-vertical ox-html5slide centered-window-mode htmlize ox-twbs diminish erc-hl-nicks symon rainbow-mode switch-window dashboard smex company sudo-edit emms magit org-bullets hungry-delete beacon linum-relative spaceline fancy-battery exwm use-package)))
which is inside my custom-set-variables. However, when I do a first-time, clean (no existing elpa/ directory) startup of Emacs reading this init.el, not all of the packages are gotten and installed. But then I can do a package-install-selected-packages and, Emacs reports that it doesn't have anything in package-selected-packages. Looking at the variable confirms this. What could be going wrong? An older "working" version of this (with existing elpa/ directory) responds oddly to package-install-selected-packages, wanting to install e.g., auctex and some nine other packages that the package code above apparently isn't seeing or dealing with. I'm baffled as to why package-selected-packages seems to be so flaky for me. I'm assuming my older .emacs.d with the existing elpa/ has install info that is "working around" this failing package-selected-packages situation.
package-archives
(("marmalade" . "http://marmalade-repo.org/packages/") ("gnu" . "http://elpa.gnu.org/packages/") ("melpa" . "http://melpa.milkbox.net/packages/"))
When I look at the package-list-packages list, how do I know which of these three sources a certain row is sourced from?
In my trunk build, with multiple repositories enabled, the package-list-packages view contains an "Archive" column that is populated for available (uninstalled) packages, e.g.:
Package Version Status Archive Description
ace-window 0.5.0 available melpa-s... Quickly switch windows using `ace-jump-mode'.
ack 1.3 available gnu Interface to ack-like source code search tools
Similarly, when I press RET on a package in this view, I get something like this:
ac-slime is an available package.
Status: Available from melpa-stable -- Install
Archive: melpa-stable
Version: 0.7
Requires: auto-complete-1.4, slime-2.9, cl-lib-0.5
Summary: An auto-complete source using slime completions
Homepage: https://github.com/purcell/ac-slime
Again, the "Archive" shows this package's source.
Unfortunately, installed packages do not seem to include information about which archive they came from.
I have Emacs24, i want to use some modes like auto-complete.
Here is the thing, I installed 'linum' before and it's just working very well but others not working.
My .emacs file
(add-to-list 'load-path "/root/.scripts")
(require 'linum)
(global-linum-mode 1)
(require 'package)
(add-to-list 'package-archives '("melppa" . "http://melpa.milkbox.net/packages/"))
(package-initalize)
(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)
(require 'yasnippet)
auto-complete and yasnippet just doesn't working , i tried command 'auto-complete-mode' but its still same.
Any ideas ?
EDIT : I installed it from source not from ELPA and it worked.
I had a similar issue when I upgraded to Emacs 24. Have you tried running M-x auto-complete? When I did, I got an error message like the following:
gv-get: (popup-cursor ac-menu) is not a valid place expression
It turned out this was an already reported bug that can be fixed by recompiling your byte-code:
https://github.com/auto-complete/auto-complete/issues/222
https://github.com/auto-complete/auto-complete/issues/118
This solution worked for me:
$ find ~/.emacs.d/elpa -name '*.elc' | xargs rm
(to remove all compiled elisp in your elpa subdirectories)
... then, in an elisp interaction buffer, like scratch eval:
(byte-recompile-directory (expand-file-name "~/.emacs.d/elpa") 0)
... then re-start emacs.
I have installed some packages by using elpa in my Emacs, but how are they loaded when launching Emacs?
package-install is a part of package.el -- which You can see with describe-function. From package.el documentation:
;; At activation time we will set up the load-path and the info path,
;; and we will load the package's autoloads. If a package's
;; dependencies are not available, we will not activate that package.
So in every package there's a file
NAME-autoloads.el
and this file is loaded at start up.
The whole package is contained under the package-user-dir:
(setq package-user-dir "~/.emacs.d/site-lisp/package-install")
(require 'package)
Each package also contains NAME-pkg.el with package version and description. For example here're files related to tabbar package:
package-install # that's my package-user-dir
└── tabbar-2.0.1 # each package dir is in the separate dir
├── tabbar-autoloads.el # this file is loaded at start up
├── tabbar.el # the package itself. In this case it is just a single file
└── tabbar-pkg.el # information about the package for package managment
To quote the manual: 39.1.1 Summary: Sequence of Actions at Startup:
15. If package-enable-at-startup is non-nil, it calls the function package-initialize to activate any optional Emacs Lisp package that has been installed.
package-initialize is then calls package-activate which in turn calls package-activate-1 which ends with loading NAME-autoload.el:
(load (expand-file-name (concat name "-autoloads") pkg-dir) nil t)