-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is no good way to install and upgrade use-package
#219
Comments
I'm not sure that I follow.. When use-package is installed, package.el will find it and upgrade it after invoking I have additionaly set up so that I don't need to This is from the top of my init.el (when load-file-name
(load (expand-file-name
"load-path" (file-name-directory load-file-name)) nil t))
(setq
package-enable-at-startup nil
package-archives
'(("melpa-stable" . "http://stable.melpa.org/packages/")
("melpa" . "http://melpa.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("org" . "http://orgmode.org/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("sc" . "http://joseito.republika.pl/sunrise-commander/")))
(eval-when-compile
(require 'package)
(package-initialize t))
(unless (boundp 'package-pinned-packages)
(setq package-pinned-packages ()))
(defun require-package (package &optional min-version no-refresh)
"Install given PACKAGE, optionally requiring MIN-VERSION.
If NO-REFRESH is non-nil, the available package lists will not be
re-downloaded in order to locate PACKAGE."
(if (package-installed-p package min-version)
t
(if (or (assoc package package-archive-contents) no-refresh)
(package-install package)
(progn
(package-refresh-contents)
(require-package package min-version t)))))
(eval-when-compile
(require-package 'use-package)
(require 'use-package)) This is the load-path.el located besides my init.el In addition to byte compiling the effecive load-path (I have not cared a great deal about style in this particular file...) ;;; load-path.el
(defconst user-emacs-directory
(if (eq system-type 'ms-dos)
;; MS-DOS cannot have initial dot.
"~/_emacs.d/"
"~/.emacs.d/")
"Directory beneath which additional per-user Emacs-specific files are placed.
Various programs in Emacs store information in this directory.
Note that this should end with a directory separator.
See also `locate-user-emacs-file'.")
(defconst user-data-directory
(file-truename "~/.config/emacs-user-data"))
(defconst user-cache-directory
(file-truename "~/.cache/emacs-user-cache"))
(defconst user-lisp-directory
(expand-file-name "lisp" user-emacs-directory))
(defun load-path--take (n list)
"Returns a new list of the first N items in LIST, or all items if there are fewer than N.
This is just a copy of the fully expanded macro from dash."
(let (result)
(let
((num n)
(it 0))
(while
(< it num)
(when list
(setq result
(cons
(car list)
result))
(setq list
(cdr list)))
(setq it
(1+ it))))
(nreverse result)))
(defconst user-site-lisp-directory
(expand-file-name "site-lisp/shared" user-emacs-directory))
(defconst user-themes-directory
(expand-file-name "themes" user-emacs-directory))
(defconst user-notes-directory
(file-truename "~/notes"))
;; These should always exist
(make-directory user-data-directory t)
(make-directory user-cache-directory t)
;; emacs23 compat
(if (boundp 'custom-theme-load-path)
(add-to-list 'custom-theme-load-path user-themes-directory)
(add-to-list 'load-path user-themes-directory))
(defun add-to-load-path (path &optional dir)
(setq load-path
(cons (expand-file-name path (or dir user-emacs-directory)) load-path)))
(defun load-path-load-path ()
(let ((load-path load-path))
;; Add top-level lisp directories, in case they were not setup by the
;; environment.
(require 'package)
(package-initialize)
(dolist (dir (nreverse
(list user-lisp-directory
user-site-lisp-directory)))
(dolist (entry (nreverse (directory-files-and-attributes dir)))
(and
(cadr entry)
(not (string= (car entry) ".."))
(add-to-load-path (car entry) dir))))
(mapc #'add-to-load-path
(nreverse
(list
(expand-file-name "~/.config-private/emacs")
(expand-file-name "~/.opt/extempore/extras")
(expand-file-name "/usr/local/opt/extempore/extras")
(concat user-site-lisp-directory "/emms/lisp")
"/usr/local/share/emacs/site-lisp/"
"/usr/local/share/emacs/site-lisp/mu4e/"
"/opt/local/share/emacs/site-lisp/"
"/usr/share/emacs/site-lisp/SuperCollider/"
"/usr/share/emacs/site-lisp/supercollider/"
"/var/lib/gems/1.9.1/gems/trogdoro-el4r-1.0.10/data/emacs/site-lisp/")))
(let ((cl-p load-path))
(while cl-p
(setcar cl-p (file-name-as-directory
(expand-file-name (car cl-p))))
(setq cl-p (cdr cl-p))))
(when
(or (not (boundp 'emacs-version))
(string< emacs-version "24.3"))
(add-to-load-path
(expand-file-name "site-lisp/cl-lib" user-emacs-directory)))
(delete-dups
(delq nil (mapcar #'(lambda (x)
(if (file-directory-p x)
x
nil))
load-path)))))
(defmacro load-path-set-load-path ()
`(progn
(setq load-path ',(load-path-load-path))
(let ((failed nil))
(mapc #'(lambda (x)
(unless failed
(setq failed (not (file-directory-p x)))))
load-path)
(when failed
(require 'bytecomp)
(let ((byte-compile-verbose nil)
(byte-compile-warnings nil)
(use-package-verbose nil)
(ad-redefinition-action 'accept))
(byte-recompile-file "~/.emacs.d/load-path.el" t 0 t))))))
(load-path-set-load-path)
(eval-after-load "info"
#'(progn
(when (fboundp 'info-initialize)
(info-initialize)
(defun add-to-info-path (path &optional dir)
(setq Info-directory-list
(cons (expand-file-name path (or dir user-emacs-directory)) Info-directory-list)))
(mapc #'add-to-info-path
(nreverse
(list
(expand-file-name "~/.refdoc/info")))))))
(when (bound-and-true-p x-bitmap-file-path)
(add-to-list 'x-bitmap-file-path
(concat user-emacs-directory "/icons")))
(require 'cus-load nil t)
(provide 'load-path)
;;; load-path.el ends here
|
Why? I think there is no need to initialize use-package, of course you have to install use-package before using it, you can install use-package from ELPA like this way: ;; Setup package.el
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(package-initialize)
;; Bootstrap `use-package'
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
;; Use use-package now |
Running You are right. If I add However and idea behind |
@marcinant My solution only requires/uses |
My emacs starts in about 1-1.1seconds on my 2009 i7 desktop computer (provided files are loaded into disk cache).. IIRC, the |
I just also remembered my (use-package solarized-theme
:ensure t
:if window-system
:init
(progn
(setq solarized-use-less-bold t
solarized-use-more-italic t
solarized-emphasize-indicators nil
solarized-distinct-fringe-background nil
solarized-high-contrast-mode-line nil))
:config
(progn
(load "solarized-theme-autoloads" nil t)
(setq theme-dark 'solarized-dark
theme-bright 'solarized-light))) |
?
|
Just because
So,
It's their problem. They should use
Developer should just provide documentation how to configure package on |
@marcinant it runs twice unless you set |
I used strace to guide my decision of removing Since use-pakcage |
Hmm... is your .emacs available somewhere? Anyway I decided to use this dirty piece of code:
Now I need to switch my .emacs to use package and test it. |
yeah https://github.com/thomasf/dotfiles-thomasf-emacs I have one emacs per "workspace group" of desktops which more or less means one emacs per project.. I also have a default "home" emacs for all general emacsclient needs. Startup time is more important when working like that. |
After further code analysis I have to admit that I don't understand the idea behind Package.el is intended to load after user init file. IMHO this is just plain wrong. Could someone (an author) enlighten me and tell why is it designed in this way? |
It's not designed specifically for package.el.. John (the author) doesnt even use package.el. It's more or less up to the use-package user to do the integration part. |
Ok. Now I can see what the problem was. All my packages are not in load-path until |
Well, you may close this bug. However problem is still alive. Although |
I disagree that this is an use-package issue, after all it's elisp were talking about and it's as easy as invoking |
It's undocumented. It should be mentioned in readme that one has to invoke When someone will install this macro as ELPA package and initialize in the way described in readme then it's not going to work. |
btw. emacs-25, ie. the master branch now does this to the top of the user init.el ;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize) |
Well it's just wierd. Default policy is: use init.el to set up config with after-init-hooks, then 'package-initialize' is issued automatically by 'startup.el' right after 'init.el' is loaded. There is no good reason to run 'package-initialize' from 'init.el'. |
Weird or not, the default policy seems to be changing. I find it a bit less weird with |
I made a pull request to implement something similar to thomasf's setup, but a simpler way: #487 |
Sorry, but I disagree. There is simply no practical disadvantage to running In any case, Emacs now initializes the package system before loading the init file, thus rendering this entire debate superfluous. The feature will be released in Emacs 27. |
In any case, Emacs now initializes the package system before loading the init file, thus rendering this entire debate superfluous. The feature will be released in Emacs 27.
As long as this can be disabled, right?
|
In (setq package-enable-at-startup nil) |
Problem is that
use-package
is available as ELPA package and this is probably easiest way to install and upgrade.Unfortunately
use-package
should be initialized before Emacs initializes ELPA packages.So, when this macro is installed as ELPA package there is no way to
(require 'use-package)
because Emacs doesn't know whereuse-package
is.The only way I see is to add full path to
bind-key
anduse-package
as second argument torequire
.It works however manual update is required every time ELPA package is upgraded.
Any other ideas to solve this problem?
The text was updated successfully, but these errors were encountered: