help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: use-package


From: Kaushal Modi
Subject: Re: use-package
Date: Tue, 03 May 2016 14:01:07 +0000

>
> Thanks. Just one question, for example my emacs_keys file contains stuff
> like
>
> (defun some-funny functions ()
> )
> (global-set-key [(f1)] 'save-buffer)
> (global-set-key [(f2)] 'some-funny-function)
>
> (provide 'emacs_keys)
>
> So using
>
>     -  use-package is possible?
>

Yes. Assuming that your emacs_keys.el is already in the load-path (i.e. you
are able to successfully do (require 'emacs_keys), you can do instead

    (use-package emacs_keys)

    -  and if so: would it shorten startup?
>

Most likely, not.

use-package speeds up startup times by delaying the loading the packages
that you can afford to.. for example, you do not need to load org-mode
until you are in a buffer with org-mode major mode or you call one of the
commands like org-agenda that autoloads org-mode. So if you load org-mode
using use-package and its ":defer t" or ":commands (...)" or similar
load-deferring options, you will see an improvement in the startup time.

use-package, very broadly put, is syntax sugar, a very elaborate macro, in
a good way.

To understand what it does, type the below, place cursor after the closing
parenthesis and do M-x pp-macroexpand-last-sexp.

    (use-package org-mode)

Now do the same with

    (use-package org-mode
      :defer t)

And once again do it with

    (use-package org-mode
      :mode ("\\.org\\'" . org-mode))

Study the raw elisp that all of the 3 macros above expand to and understand
them. That, in conjunction with reading the documentation on
https://github.com/jwiegley/use-package will make you understand what
use-package exactly does and how it saves you startup time.

If it helps, you can also go through few of my setup-*.el files here (
https://github.com/kaushalmodi/.emacs.d/tree/master/setup-files ) and see
how I use use-package for various packages. You can ignore the :config and
:init blocks in my use-package blocks and focus only on blocks like :defer,
:mode, :commands, :bind, etc which help me speedup my emacs startup.


-- 

-- 
Kaushal Modi


reply via email to

[Prev in Thread] Current Thread [Next in Thread]