aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorDamien Cassou2022-04-04 21:10:44 +0200
committerDamien Cassou2022-04-04 21:10:44 +0200
commit30b35d6d62302133c8d9cab2fb26852a9010675f (patch)
tree773cd4cdeb0b52dfae13336f385bfc821a4e4854 /doc/misc
parentffa5f0397af87c7258f58082408281bf3a5a2deb (diff)
downloademacs-30b35d6d62302133c8d9cab2fb26852a9010675f.tar.gz
emacs-30b35d6d62302133c8d9cab2fb26852a9010675f.zip
Update use-package.texi
Diffstat (limited to 'doc/misc')
-rw-r--r--doc/misc/use-package.texi219
1 files changed, 137 insertions, 82 deletions
diff --git a/doc/misc/use-package.texi b/doc/misc/use-package.texi
index cad42bdfa28..880af1203b6 100644
--- a/doc/misc/use-package.texi
+++ b/doc/misc/use-package.texi
@@ -17,8 +17,9 @@ later version.
17 17
18This document is distributed in the hope that it will be useful, 18This document is distributed in the hope that it will be useful,
19but WITHOUT ANY WARRANTY; without even the implied warranty of 19but WITHOUT ANY WARRANTY; without even the implied warranty of
20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE@. See the GNU
21General Public License for more details. 21General Public License for more details.
22
22@end quotation 23@end quotation
23@end copying 24@end copying
24 25
@@ -54,7 +55,8 @@ version 3 of the License, or (at your option) any later version.
54 55
55This document is distributed in the hope that it will be useful, but WITHOUT 56This document is distributed in the hope that it will be useful, but WITHOUT
56ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 57ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
57FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 58FOR A PARTICULAR PURPOSE@. See the GNU General Public License for more details.
59
58@end quotation 60@end quotation
59@end ifnottex 61@end ifnottex
60 62
@@ -62,6 +64,8 @@ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
62* Introduction:: 64* Introduction::
63* Installation:: 65* Installation::
64* Getting Started:: 66* Getting Started::
67* Basic Concepts::
68* Issues/Requests::
65* Keywords:: 69* Keywords::
66* FAQ:: 70* FAQ::
67* Debugging Tools:: 71* Debugging Tools::
@@ -72,44 +76,39 @@ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
72@detailmenu 76@detailmenu
73--- The Detailed Node Listing --- 77--- The Detailed Node Listing ---
74 78
75
76Installation 79Installation
77 80
78* Installing from an Elpa Archive:: 81* Installing from an Elpa Archive::
79* Installing from the Git Repository:: 82* Installing from the Git Repository::
80* Post-Installation Tasks:: 83* Post-Installation Tasks::
81 84
82
83
84
85Keywords 85Keywords
86 86
87* @code{:after}: @code{after}. 87* @code{after}::
88* @code{:bind-keymap}, @code{:bind-keymap*}: @code{bind-keymap} @code{bind-keymap*}. 88* @code{bind-keymap}, @code{bind-keymap*}: @code{bind-keymap} @code{bind-keymap*}.
89* @code{:bind}, @code{:bind*}: @code{bind} @code{bind*}. 89* @code{bind}, @code{bind*}: @code{bind} @code{bind*}.
90* @code{:commands}: @code{commands}. 90* @code{commands}::
91* @code{:preface}, @code{:init}, @code{:config}: @code{preface} @code{init} @code{config}. 91* @code{preface}, @code{init}, @code{config}: @code{preface} @code{init} @code{config}.
92* @code{:custom}: @code{custom}. 92* @code{custom}::
93* @code{:custom-face}: @code{custom-face}. 93* @code{custom-face}::
94* @code{:defer}, @code{:demand}: @code{defer} @code{demand}. 94* @code{defer}, @code{demand}: @code{defer} @code{demand}.
95* @code{:defines}, @code{:functions}: @code{defines} @code{functions}. 95* @code{defines}, @code{functions}: @code{defines} @code{functions}.
96* @code{:diminish}, @code{:delight}: @code{diminish} @code{delight}. 96* @code{diminish}, @code{delight}: @code{diminish} @code{delight}.
97* @code{:disabled}: @code{disabled}. 97* @code{disabled}::
98* @code{:ensure}, @code{:pin}: @code{ensure} @code{pin}. 98* @code{ensure}, @code{pin}: @code{ensure} @code{pin}.
99* @code{:hook}: @code{hook}. 99* @code{hook}::
100* @code{:if}, @code{:when}, @code{:unless}: @code{if} @code{when} @code{unless}. 100* @code{if}, @code{when}, @code{unless}: @code{if} @code{when} @code{unless}.
101* @code{:load-path}: @code{load-path}. 101* @code{load-path}::
102* @code{:mode}, @code{:interpreter}: @code{mode} @code{interpreter}. 102* @code{mode}, @code{interpreter}: @code{mode} @code{interpreter}.
103* @code{:magic}, @code{:magic-fallback}: @code{magic} @code{magic-fallback}. 103* @code{magic}, @code{magic-fallback}: @code{magic} @code{magic-fallback}.
104* @code{:no-require}: @code{no-require}. 104* @code{no-require}::
105* @code{:requires}: @code{requires}. 105* @code{requires}::
106
107
108 106
109@code{:bind}, @code{:bind*} 107@code{:bind}, @code{:bind*}
110 108
111* Binding to local keymaps:: 109* Binding to local keymaps::
112 110
111
113FAQ 112FAQ
114 113
115* FAQ - How to @dots{}?:: 114* FAQ - How to @dots{}?::
@@ -123,21 +122,31 @@ FAQ - How to @dots{}?
123FAQ - Issues and Errors 122FAQ - Issues and Errors
124 123
125* This is an issues:: 124* This is an issues::
125
126
126@end detailmenu 127@end detailmenu
127@end menu 128@end menu
128 129
129@node Introduction 130@node Introduction
130@chapter Introduction 131@chapter Introduction
131 132
132The @code{use-package} macro allows you to isolate package configuration 133The @code{use-package} macro allows you to isolate package configuration in your
133in your @file{.emacs} file in a way that is both performance-oriented and, 134@code{.emacs} file in a way that is both performance-oriented and, well, tidy. I
134well, tidy. I created it because I have over 400 packages that I use in 135created it because I have over 80 packages that I use in Emacs, and things
135Emacs, and things were getting difficult to manage. Yet with this utility 136were getting difficult to manage. Yet with this utility my total load time is
136my total load time is around 2 seconds, with no loss of functionality! 137around 2 seconds, with no loss of functionality!
138
139More text to come@dots{}
137 140
138@node Installation 141@node Installation
139@chapter Installation 142@chapter Installation
140 143
144@menu
145* Installing from an Elpa Archive::
146* Installing from the Git Repository::
147* Post-Installation Tasks::
148@end menu
149
141use-package can be installed using Emacs' package manager or manually from 150use-package can be installed using Emacs' package manager or manually from
142its development repository. 151its development repository.
143 152
@@ -163,7 +172,7 @@ To use Melpa:
163@lisp 172@lisp
164(require 'package) 173(require 'package)
165(add-to-list 'package-archives 174(add-to-list 'package-archives
166 '("melpa" . "https://melpa.org/packages/") t) 175 '("melpa" . "https://melpa.org/packages/") t)
167@end lisp 176@end lisp
168 177
169@itemize 178@itemize
@@ -174,7 +183,7 @@ To use Melpa-Stable:
174@lisp 183@lisp
175(require 'package) 184(require 'package)
176(add-to-list 'package-archives 185(add-to-list 'package-archives
177 '("melpa-stable" . "https://stable.melpa.org/packages/") t) 186 '("melpa-stable" . "https://stable.melpa.org/packages/") t)
178@end lisp 187@end lisp
179 188
180Once you have added your preferred archive, you need to update the 189Once you have added your preferred archive, you need to update the
@@ -225,7 +234,7 @@ Finally add this to your init file:
225(with-eval-after-load 'info 234(with-eval-after-load 'info
226 (info-initialize) 235 (info-initialize)
227 (add-to-list 'Info-directory-list 236 (add-to-list 'Info-directory-list
228 "~/.emacs.d/site-lisp/use-package/")) 237 "~/.emacs.d/site-lisp/use-package/"))
229@end lisp 238@end lisp
230 239
231Note that elements of @code{load-path} should not end with a slash, while those of 240Note that elements of @code{load-path} should not end with a slash, while those of
@@ -267,37 +276,75 @@ use-package-version’s value is "2.4.1"
267 276
268If you are completely new to use-package then see @ref{Getting Started}. 277If you are completely new to use-package then see @ref{Getting Started}.
269 278
270If you run into problems, then please see the @ref{FAQ}. Also see the 279If you run into problems, then please see the
271@ref{Debugging Tools}. 280@ref{FAQ}. Also see the @ref{Debugging Tools}.
272 281
273@node Getting Started 282@node Getting Started
274@chapter Getting Started 283@chapter Getting Started
275 284
276TODO. For now, see @code{README.md}. 285TODO@. For now, see @code{README.md}.
286
287@node Basic Concepts
288@chapter Basic Concepts
289
290@code{use-package} was created for few basic reasons, each of which drove the
291design in various ways. Understanding these reasons may help make some of
292those decisions clearer:
293
294@itemize
295@item
296To gather all configuration details of a package into one place, making
297it easier to copy, disable, or move it elsewhere in the init file.
298
299
300@item
301To reduce duplication and boilerplate, capturing several common practices
302as mere keywords both easy and intuitive to use.
303
304
305@item
306To make startup time of Emacs as quick as possible, without sacrificing
307the quantity of add-on packages used.
308
309
310@item
311To make it so errors encountered during startup disable only the package
312raising the error, and as little else as possible, leaving a close to a
313functional Emacs as possible.
314
315
316@item
317To allow byte-compilation of one's init file so that any warnings or
318errors seen are meaningful. In this way, even if byte-compilation is not
319used for speed (reason 3), it can still be used as a sanity check.
320@end itemize
321
322@node Issues/Requests
323@chapter Issues/Requests
277 324
278@node Keywords 325@node Keywords
279@chapter Keywords 326@chapter Keywords
280 327
281@menu 328@menu
282* @code{:after}: @code{after}. 329* @code{after}::
283* @code{:bind-keymap}, @code{:bind-keymap*}: @code{bind-keymap} @code{bind-keymap*}. 330* @code{bind-keymap}, @code{bind-keymap*}: @code{bind-keymap} @code{bind-keymap*}.
284* @code{:bind}, @code{:bind*}: @code{bind} @code{bind*}. 331* @code{bind}, @code{bind*}: @code{bind} @code{bind*}.
285* @code{:commands}: @code{commands}. 332* @code{commands}::
286* @code{:preface}, @code{:init}, @code{:config}: @code{preface} @code{init} @code{config}. 333* @code{preface}, @code{init}, @code{config}: @code{preface} @code{init} @code{config}.
287* @code{:custom}: @code{custom}. 334* @code{custom}::
288* @code{:custom-face}: @code{custom-face}. 335* @code{custom-face}::
289* @code{:defer}, @code{:demand}: @code{defer} @code{demand}. 336* @code{defer}, @code{demand}: @code{defer} @code{demand}.
290* @code{:defines}, @code{:functions}: @code{defines} @code{functions}. 337* @code{defines}, @code{functions}: @code{defines} @code{functions}.
291* @code{:diminish}, @code{:delight}: @code{diminish} @code{delight}. 338* @code{diminish}, @code{delight}: @code{diminish} @code{delight}.
292* @code{:disabled}: @code{disabled}. 339* @code{disabled}::
293* @code{:ensure}, @code{:pin}: @code{ensure} @code{pin}. 340* @code{ensure}, @code{pin}: @code{ensure} @code{pin}.
294* @code{:hook}: @code{hook}. 341* @code{hook}::
295* @code{:if}, @code{:when}, @code{:unless}: @code{if} @code{when} @code{unless}. 342* @code{if}, @code{when}, @code{unless}: @code{if} @code{when} @code{unless}.
296* @code{:load-path}: @code{load-path}. 343* @code{load-path}::
297* @code{:mode}, @code{:interpreter}: @code{mode} @code{interpreter}. 344* @code{mode}, @code{interpreter}: @code{mode} @code{interpreter}.
298* @code{:magic}, @code{:magic-fallback}: @code{magic} @code{magic-fallback}. 345* @code{magic}, @code{magic-fallback}: @code{magic} @code{magic-fallback}.
299* @code{:no-require}: @code{no-require}. 346* @code{no-require}::
300* @code{:requires}: @code{requires}. 347* @code{requires}::
301@end menu 348@end menu
302 349
303@node @code{after} 350@node @code{after}
@@ -341,6 +388,13 @@ When you nest selectors, such as @code{(:any (:all foo bar) (:all baz quux))}, i
341means that the package will be loaded when either both @code{foo} and @code{bar} have 388means that the package will be loaded when either both @code{foo} and @code{bar} have
342been loaded, or both @code{baz} and @code{quux} have been loaded. 389been loaded, or both @code{baz} and @code{quux} have been loaded.
343 390
391@strong{NOTE}: Pay attention if you set @code{use-package-always-defer} to t, and also use
392the @code{:after} keyword, as you will need to specify how the declared package is
393to be loaded: e.g., by some @code{:bind}. If you're not using one of the mechanisms
394that registers autoloads, such as @code{:bind} or @code{:hook}, and your package manager
395does not provide autoloads, it's possible that without adding @code{:demand t} to
396those declarations, your package will never be loaded.
397
344@node @code{bind-keymap} @code{bind-keymap*} 398@node @code{bind-keymap} @code{bind-keymap*}
345@section @code{:bind-keymap}, @code{:bind-keymap*} 399@section @code{:bind-keymap}, @code{:bind-keymap*}
346 400
@@ -400,8 +454,8 @@ The @code{:bind} keyword takes either a cons or a list of conses:
400@lisp 454@lisp
401(use-package hi-lock 455(use-package hi-lock
402 :bind (("M-o l" . highlight-lines-matching-regexp) 456 :bind (("M-o l" . highlight-lines-matching-regexp)
403 ("M-o r" . highlight-regexp) 457 ("M-o r" . highlight-regexp)
404 ("M-o w" . highlight-phrase))) 458 ("M-o w" . highlight-phrase)))
405@end lisp 459@end lisp
406 460
407The @code{:commands} keyword likewise takes either a symbol or a list of symbols. 461The @code{:commands} keyword likewise takes either a symbol or a list of symbols.
@@ -415,9 +469,9 @@ Examples:
415@lisp 469@lisp
416(use-package helm 470(use-package helm
417 :bind (("M-x" . helm-M-x) 471 :bind (("M-x" . helm-M-x)
418 ("M-<f5>" . helm-find-files) 472 ("M-<f5>" . helm-find-files)
419 ([f10] . helm-buffers-list) 473 ([f10] . helm-buffers-list)
420 ([S-f10] . helm-recentf))) 474 ([S-f10] . helm-recentf)))
421@end lisp 475@end lisp
422 476
423@menu 477@menu
@@ -434,7 +488,7 @@ supports this with a @code{:map} modifier, taking the local keymap to bind to:
434@lisp 488@lisp
435(use-package helm 489(use-package helm
436 :bind (:map helm-command-map 490 :bind (:map helm-command-map
437 ("C-c h" . helm-execute-persistent-action))) 491 ("C-c h" . helm-execute-persistent-action)))
438@end lisp 492@end lisp
439 493
440The effect of this statement is to wait until @code{helm} has loaded, and then to 494The effect of this statement is to wait until @code{helm} has loaded, and then to
@@ -447,13 +501,13 @@ first use of @code{:map} are applied to the global keymap:
447@lisp 501@lisp
448(use-package term 502(use-package term
449 :bind (("C-c t" . term) 503 :bind (("C-c t" . term)
450 :map term-mode-map 504 :map term-mode-map
451 ("M-p" . term-send-up) 505 ("M-p" . term-send-up)
452 ("M-n" . term-send-down) 506 ("M-n" . term-send-down)
453 :map term-raw-map 507 :map term-raw-map
454 ("M-o" . other-window) 508 ("M-o" . other-window)
455 ("M-p" . term-send-up) 509 ("M-p" . term-send-up)
456 ("M-n" . term-send-down))) 510 ("M-n" . term-send-down)))
457@end lisp 511@end lisp
458 512
459@node @code{commands} 513@node @code{commands}
@@ -506,9 +560,9 @@ As you might expect, you can use @code{:init} and @code{:config} together:
506(use-package color-moccur 560(use-package color-moccur
507 :commands (isearch-moccur isearch-all) 561 :commands (isearch-moccur isearch-all)
508 :bind (("M-s O" . moccur) 562 :bind (("M-s O" . moccur)
509 :map isearch-mode-map 563 :map isearch-mode-map
510 ("M-o" . isearch-moccur) 564 ("M-o" . isearch-moccur)
511 ("M-O" . isearch-moccur-all)) 565 ("M-O" . isearch-moccur-all))
512 :init 566 :init
513 (setq isearch-lazy-highlight t) 567 (setq isearch-lazy-highlight t)
514 :config 568 :config
@@ -761,7 +815,7 @@ equivalent:
761 815
762(use-package ace-jump-mode 816(use-package ace-jump-mode
763 :hook ((prog-mode . ace-jump-mode) 817 :hook ((prog-mode . ace-jump-mode)
764 (text-mode . ace-jump-mode))) 818 (text-mode . ace-jump-mode)))
765 819
766(use-package ace-jump-mode 820(use-package ace-jump-mode
767 :commands ace-jump-mode 821 :commands ace-jump-mode
@@ -878,22 +932,22 @@ This does exactly the same thing as the following:
878@node @code{magic} @code{magic-fallback} 932@node @code{magic} @code{magic-fallback}
879@section @code{:magic}, @code{:magic-fallback} 933@section @code{:magic}, @code{:magic-fallback}
880 934
881Similar to `:mode` and `:interpreter`, you can also use `:magic` and 935Similar to @code{:mode} and @code{:interpreter}, you can also use @code{:magic} and
882`:magic-fallback` to cause certain function to be run if the beginning of a 936@code{:magic-fallback} to cause certain function to be run if the beginning of a
883file matches a given regular expression. The difference between the two is 937file matches a given regular expression. The difference between the two is
884that `:magic-fallback` has a lower priority than `:mode`. For example: 938that @code{:magic-fallback} has a lower priority than @code{:mode}. For example:
885 939
886``` elisp 940@lisp
887(use-package pdf-tools 941(use-package pdf-tools
888 :load-path "site-lisp/pdf-tools/lisp" 942 :load-path "site-lisp/pdf-tools/lisp"
889 :magic ("%PDF" . pdf-view-mode) 943 :magic ("%PDF" . pdf-view-mode)
890 :config 944 :config
891 (pdf-tools-install)) 945 (pdf-tools-install))
892``` 946@end lisp
893 947
894This registers an autoloaded command for `pdf-view-mode`, defers loading of 948This registers an autoloaded command for @code{pdf-view-mode}, defers loading of
895`pdf-tools`, and runs `pdf-view-mode` if the beginning of a buffer matches the 949@code{pdf-tools}, and runs @code{pdf-view-mode} if the beginning of a buffer matches the
896string `"%PDF"`. 950string @code{"%PDF"}.
897 951
898@node @code{no-require} 952@node @code{no-require}
899@section @code{:no-require} 953@section @code{:no-require}
@@ -1001,4 +1055,5 @@ Please also see the @ref{FAQ}.
1001 1055
1002@printindex vr 1056@printindex vr
1003 1057
1058Emacs 28.0.92 (Org mode 9.5.2)
1004@bye 1059@bye