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.devel Subject: Re: use-package.el -> Emacs core Date: Tue, 10 Nov 2015 12:01:32 +0000 Message-ID: <87k2pqqd0j.fsf@russet.org.uk> References: <564136F7.2020404@yandex.ru> <87mvum1bbg.fsf@pedrosilva.pt> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1447156913 9334 80.91.229.3 (10 Nov 2015 12:01:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 10 Nov 2015 12:01:53 +0000 (UTC) Cc: Pedro Silva , emacs-devel@gnu.org To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 10 13:01:48 2015 Return-path: Envelope-to: ged-emacs-devel@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 1Zw7cP-0000VY-3g for ged-emacs-devel@m.gmane.org; Tue, 10 Nov 2015 13:01:45 +0100 Original-Received: from localhost ([::1]:59142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw7cO-00060B-RY for ged-emacs-devel@m.gmane.org; Tue, 10 Nov 2015 07:01:44 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw7cK-0005zM-T0 for emacs-devel@gnu.org; Tue, 10 Nov 2015 07:01:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zw7cH-0001Dd-Kf for emacs-devel@gnu.org; Tue, 10 Nov 2015 07:01:40 -0500 Original-Received: from cheviot22.ncl.ac.uk ([128.240.234.22]:40031) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw7cH-0001DA-Eq for emacs-devel@gnu.org; Tue, 10 Nov 2015 07:01:37 -0500 Original-Received: from smtpauth-vm.ncl.ac.uk ([10.8.233.129] helo=smtpauth.ncl.ac.uk) by cheviot22.ncl.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1Zw7cC-0006KE-FV; Tue, 10 Nov 2015 12:01:32 +0000 Original-Received: from jangai.ncl.ac.uk ([10.66.67.223] helo=localhost) by smtpauth.ncl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1Zw7cC-0007Cn-EV; Tue, 10 Nov 2015 12:01:32 +0000 In-Reply-To: (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Tue, 10 Nov 2015 09:45:50 +0000") 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.22 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:193837 Archived-At: Jo=C3=A3o T=C3=A1vora writes: > Pedro Silva writes: > >> :ensure (automatic ELPA installation), :defer (lazy loading) and >> :commands (autoloading) are the things I most use in `use-package' >> that are not as easy to achieve with `with-eval-after-load'. > > Not as easy? Sure, more characters, but basically the same complexity. I > don't think it's worth a whole new language to be able to replace: > > (package-install 'foo) > Especially given that the use-package versions force the reader (or the > grepper) to look around for context, while the regular versions don't. use-package introduces a single (documented) form. So, it's easy to re-eval everything, and keeps all your code in one place. Trivial as this sounds, this is actually pretty useful. In your examples, you need to "progn" everything to achieve the same. > But perhaps I'm misinterpreting what these directives actually do, or > perhaps you can illustrate with some snippets of your own. What use-package does is syntactic sugar for sure, but it also does add some nice functionality. So, for example, this (use-package foo :load-path "~/foo" :commands foo-a foo-b foo-c :defer 5 ) actually does this... (progn (eval-and-compile (push "~/foo" load-path)) (run-with-idle-timer 5 nil #'require 'foo nil t) (unless (fboundp 'foo-a) (autoload #'foo-a "foo" nil t)) (unless (fboundp 'foo-b) (autoload #'foo-b "foo" nil t)) (unless (fboundp 'foo-c) (autoload #'foo-c "foo" nil t))) while the apparently much simpler: (use-package foo :load-path "~/foo" ) actually does this: (progn (eval-and-compile (push "~/foo" load-path)) (let ((now (current-time))) (message "%s..." "Loading package foo") (prog1 (if (not (require 'foo nil 'noerror)) (ignore (message (format "Could not load %s" 'foo)))) (let ((elapsed (float-time (time-subtract (current-time) now)))) (if (> elapsed 0.1) (message "%s...done (%.3fs)" "Loading package foo" elapsed) (message "%s...done" "Loading package foo")))))) A useful system for working out why your .emacs is so slow to load. *shrugs*. I really like it, and it's made my .emacs cleaner. Phil