From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: phillip.lord@russet.org.uk (Phillip Lord) Newsgroups: gmane.emacs.help Subject: Re: using use-package Date: Mon, 10 Aug 2015 10:52:16 +0100 Message-ID: <87r3nbh3n3.fsf@russet.org.uk> References: <20150805055619.13567.17B26335@ahiker.mooo.com> <17131863-cbb8-4a85-8470-490fe9a0c0d4@googlegroups.com> <66dceb24-5fef-4316-8c8b-e9a3e62b0fb8@googlegroups.com> <3594e2c6-bd02-412f-98df-9dd0f145277a@googlegroups.com> <01b4d996-aad3-44ff-a580-7950b25b7dc8@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1439200363 1789 80.91.229.3 (10 Aug 2015 09:52:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 10 Aug 2015 09:52:43 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Aug 10 11:52:35 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZOjkw-000493-QU for geh-help-gnu-emacs@m.gmane.org; Mon, 10 Aug 2015 11:52:34 +0200 Original-Received: from localhost ([::1]:57499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOjkv-0000gJ-T7 for geh-help-gnu-emacs@m.gmane.org; Mon, 10 Aug 2015 05:52:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOjkl-0000gC-B0 for help-gnu-emacs@gnu.org; Mon, 10 Aug 2015 05:52:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZOjki-0001mL-5h for help-gnu-emacs@gnu.org; Mon, 10 Aug 2015 05:52:23 -0400 Original-Received: from cheviot12.ncl.ac.uk ([128.240.234.12]:45263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOjkh-0001lz-VR for help-gnu-emacs@gnu.org; Mon, 10 Aug 2015 05:52:20 -0400 Original-Received: from smtpauth-vm.ncl.ac.uk ([10.8.233.129] helo=smtpauth.ncl.ac.uk) by cheviot12.ncl.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1ZOjkf-00026g-C5; Mon, 10 Aug 2015 10:52:17 +0100 Original-Received: from cpc6-benw10-2-0-cust45.gate.cable.virginm.net ([92.238.179.46] helo=localhost) by smtpauth.ncl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1ZOjkf-00007m-9l; Mon, 10 Aug 2015 10:52:17 +0100 In-Reply-To: (Stefan Monnier's message of "Sat, 8 Aug 2015 19:24:21 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 128.240.234.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:106435 Archived-At: Stefan Monnier writes: >> Putting in the core is rather some distance from promoting as the "one >> true way" > > FWIW, lots of use-package is designed to work around flaws in packages. > > E.g. the :load-path thingy should never be necessary since the package's > own autoloads should already take care of that. You are correct about the :load-path thingy, although I use this for my own packages which I run "straight from source" as it where, rather than install as a ELPA package proper. > Or to take another example from https://github.com/jwiegley/use-package: > > (use-package foo > :init > (setq foo-variable t) > :config > (foo-mode 1)) > > For any properly written foo-mode, the above can be replaced with > > (setq foo-variable t) > (foo-mode 1) > > and it should work just as well. No, you are missing (several) points of use-package. First (and trivially) the use-package statement groups everything syntactically. So, it's more like: (progn (setq foo-variable t) (foo-mode 1)) This is nicer because it groups all the configuration together, so you can move, comment, delete or eval it all together. Of course, `progn' achieves the same thing. However, `use-package' also gives you configurable feedback on load times. So if (require 'foo) takes a long time, use-package tells you, and tells you how long it takes. In your example, (foo-mode 1) will force an autoload. With use-package, also I can do (use-package foo :defer t ;;;etc ) which will achieve the same. Or (use-package foo :defer 10) will load foo in the idle cycle. Or (use-package foo :ensure t) will install from ELPA if `foo' is not present. Or (use-package foo :if window-system) will only load foo (and run the configuration) conditionally. use-package is entirely complementary to existing package system. But, it suffers from bootstrap. It's obviously not possible to do (use-package use-package :ensure t) or configure use-package in any other way with use-package. Instead, you have to do: (require 'package) (add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/") t) (when (not (package-installed-p 'use-package)) (package-install 'use-package))