From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sebastien Vauban Newsgroups: gmane.emacs.help Subject: Re: using use-package Date: Tue, 11 Aug 2015 11:20:11 +0200 Organization: Sebastien Vauban Message-ID: <86h9o6kwqc.fsf@example.com> 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 1439285132 3598 80.91.229.3 (11 Aug 2015 09:25:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Aug 2015 09:25:32 +0000 (UTC) To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Tue Aug 11 11:25:31 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 1ZP5oJ-0007iS-69 for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Aug 2015 11:25:31 +0200 Original-Received: from localhost ([::1]:33499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZP5oI-0004ZK-GU for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Aug 2015 05:25:30 -0400 Original-Path: usenet.stanford.edu!goblin3!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 97 Injection-Info: mx02.eternal-september.org; posting-host="6f05eaee171434c896d44feeaf7179f0"; logging-data="32509"; mail-complaints-to="abuse-VVbKFVtnif8H+i2N2EyTrmui9UKz+5OX@public.gmane.org"; posting-account="U2FsdGVkX1+mO5RH0jjmH7zErKktvASn" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (windows-nt) X-Archive: encrypt Cancel-Lock: sha1:xlBQ4wcnshMBpND1b8bahY48zTo= sha1:4Ci+JRZSq2tu+7y7/JBmOWBxqOY= X-Url: Under construction... Original-Xref: usenet.stanford.edu gnu.emacs.help:214174 X-BeenThere: help-gnu-emacs-mXXj517/zsQ@public.gmane.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-mXXj517/zsQ@public.gmane.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.help:106458 Archived-At: phillip.lord-WS8JpuUeUJXe9xe1eoZjHA@public.gmane.org (Phillip Lord) writes: > Stefan Monnier writes: >> 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. Just wanted to share how I do *some* of the above points in my config file. Here an example for `diff-hl', which indicates changes in the fringe: --8<---------------cut here---------------start------------->8--- (with-eval-after-load "diff-hl-autoloads" (idle-require 'diff-hl)) (with-eval-after-load "diff-hl" (global-diff-hl-mode) (define-key diff-hl-mode-map (kbd "C-x v >") 'diff-hl-next-hunk) (define-key diff-hl-mode-map (kbd "C-x v <") 'diff-hl-previous-hunk)) --8<---------------cut here---------------end--------------->8--- This is somehow trying to achieve (part of) the same goals as `use-package', but with standard Emacs (more or less, as `idle-require' is not in core). You see: - Differed load via the idle-require' package (otherwise, I just write "require") - Nice grouping of all customizations at the same place, To disable it, I'll edit the code and add "-XXX" in the first `with-eval-after-load': --8<---------------cut here---------------start------------->8--- (with-eval-after-load "diff-hl-autoloads-XXX" ; Diff-hl won't be req'ed (idle-require 'diff-hl)) --8<---------------cut here---------------end--------------->8--- Of course, I miss, for example, the real execution time of that block, once executed/loaded (and you can't advice a macro such as `with-eval-after-load', right, to add timings?). And I do have all ELPA paths in `load-path' unlike John (IIUC), though I don't understand yet how it works (differently) with `use-package'. Interested by comments... Best regards, Seb -- Sebastien Vauban