aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2022-12-11 09:34:02 +0800
committerPo Lu2022-12-11 09:34:02 +0800
commit13310643cd642bb1403bb2f8a5c27d1929725897 (patch)
treedafc767117c64ade8ce5b53487a4874450fb5d9b
parent0878279809c8acc8de703ae9774e89695b4ffc37 (diff)
parent5fbd12ff49410bbc150e677b527ca4939ffcaf5f (diff)
downloademacs-13310643cd642bb1403bb2f8a5c27d1929725897.tar.gz
emacs-13310643cd642bb1403bb2f8a5c27d1929725897.zip
Merge from origin/emacs-29
5fbd12ff494 Adapt manual names in emacs-news-mode b36bc692671 ; * etc/NEWS: Fix typos. f626b9f3856 ; * doc/misc/use-package.texi: Fix indexing. 56a6712bd6f ; * lisp/erc/erc.el (erc-default-target): Fix comment. dcf69a1da4a Respect some spaces in auth-source-pass--match-regexp acd462b0306 ; Improve the use-package manual 801c1c22de8 ; Prefer HTTPS to HTTP in some URLs 74a009dd96a Eglot: Handle LSP progress with Emacs progress reporters ... 0cfeb1c2bc9 Eglot: cleanup whitespace and indentation 465a9e78b96 Better test-custom-opts diagnostics bdbb7099784 ; Fix groff warnings in man pages d3d9676bf88 New script admin/check-man-pages c2aea9d1323 ; Mention flush-lines in kill-matching-lines docstring f5c3585e4dd ; Fix typos 58a483960dd ; Improve use-package-autoload-keymap docstring # Conflicts: # etc/NEWS
-rwxr-xr-xadmin/check-man-pages56
-rw-r--r--admin/cus-test.el32
-rw-r--r--admin/make-tarball.txt6
-rw-r--r--doc/man/etags.110
-rw-r--r--doc/misc/eglot.texi7
-rw-r--r--doc/misc/flymake.texi2
-rw-r--r--doc/misc/use-package.texi768
-rw-r--r--etc/NEWS.2918
-rw-r--r--lisp/erc/erc.el17
-rw-r--r--lisp/net/tramp-gvfs.el2
-rw-r--r--lisp/progmodes/csharp-mode.el2
-rw-r--r--lisp/progmodes/eglot.el114
-rw-r--r--lisp/progmodes/flymake.el5
-rw-r--r--lisp/replace.el5
-rw-r--r--lisp/textmodes/emacs-news-mode.el2
-rw-r--r--lisp/use-package/bind-key.el4
-rw-r--r--lisp/use-package/use-package-bind-key.el13
-rw-r--r--src/itree.c2
-rw-r--r--src/itree.h2
19 files changed, 722 insertions, 345 deletions
diff --git a/admin/check-man-pages b/admin/check-man-pages
new file mode 100755
index 00000000000..c7d781ba3d2
--- /dev/null
+++ b/admin/check-man-pages
@@ -0,0 +1,56 @@
1#!/bin/bash
2### check-man-pages - check man pages for errors
3
4## Copyright (C) 2022 Free Software Foundation, Inc.
5
6## Author: Stefan Kangas <stefankangas@gmail.com>
7
8## This file is part of GNU Emacs.
9
10## GNU Emacs is free software: you can redistribute it and/or modify
11## it under the terms of the GNU General Public License as published by
12## the Free Software Foundation, either version 3 of the License, or
13## (at your option) any later version.
14
15## GNU Emacs is distributed in the hope that it will be useful,
16## but WITHOUT ANY WARRANTY; without even the implied warranty of
17## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18## GNU General Public License for more details.
19
20## You should have received a copy of the GNU General Public License
21## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
22
23### Commentary:
24
25## Check Emacs man pages for errors using `man'.
26
27### Code:
28
29source "${0%/*}/emacs-shell-lib"
30
31exit_status=0
32
33cd "$PD"/../doc/man
34for page in *.1; do
35 # ctags.1 just includes the man page etags.1, which AFAICT will
36 # default to the one installed on the system (!), instead of the
37 # one in the repository. So checking it is pointless, and we will
38 # in any case already check etags.1 separately.
39 if [ "$page" == "ctags.1" ]; then
40 continue
41 fi
42 log=$(emacs_mktemp)
43 LC_ALL=C.UTF-8 MANROFFSEQ='' MANWIDTH=80 \
44 man --warnings=all,mac -E UTF-8 -l -Tutf8 -Z "$page" >/dev/null 2> "$log"
45 log_size=$(stat --format=%s "$log")
46 if [ "$log_size" -ne 0 ]; then
47 echo "doc/man/$page:"
48 # Point to the correct file for *compilation* buffers.
49 cat "$log" \
50 | sed 's/troff: man1\/\([^ ]\+\)\.1/troff: doc\/man\/\1.1/' \
51 | sed "s/<standard input>/doc\/man\/$page/"
52 exit_status=1
53 fi
54done
55
56exit $exit_status
diff --git a/admin/cus-test.el b/admin/cus-test.el
index 7e73f2e44aa..44897cd1060 100644
--- a/admin/cus-test.el
+++ b/admin/cus-test.el
@@ -145,7 +145,8 @@ Names should be as they appear in loaddefs.el.")
145(require 'cus-load) 145(require 'cus-load)
146 146
147(defvar cus-test-errors nil 147(defvar cus-test-errors nil
148 "List of problematic variables found by `cus-test-apropos'.") 148 "List of problematic variables found by `cus-test-apropos'.
149Each element is (VARIABLE . PROBLEM); see `cus-test--format-problem'.")
149 150
150(defvar cus-test-tested-variables nil 151(defvar cus-test-tested-variables nil
151 "List of options tested by last call of `cus-test-apropos'.") 152 "List of options tested by last call of `cus-test-apropos'.")
@@ -181,6 +182,15 @@ Set by `cus-test-noloads'.")
181;; (defvar cus-test-vars-cus-loaded nil 182;; (defvar cus-test-vars-cus-loaded nil
182;; "A list of options loaded by `custom-load-symbol'.") 183;; "A list of options loaded by `custom-load-symbol'.")
183 184
185(defun cus-test--format-error (err)
186 "Format an element of `cus-test-errors'."
187 (pcase err
188 (`(,var :type-error ,value ,type)
189 (format "variable: %s\n value: %S\n type: %S" var value type))
190 (`(,var :other-error ,e)
191 (format "variable: %s\n error: %S" var e))
192 (_ (format "%S" err))))
193
184(defun cus-test-apropos (regexp) 194(defun cus-test-apropos (regexp)
185 "Check the options matching REGEXP. 195 "Check the options matching REGEXP.
186The detected problematic options are stored in `cus-test-errors'." 196The detected problematic options are stored in `cus-test-errors'."
@@ -200,8 +210,7 @@ The detected problematic options are stored in `cus-test-errors'."
200 (let* ((type (custom-variable-type symbol)) 210 (let* ((type (custom-variable-type symbol))
201 (conv (widget-convert type)) 211 (conv (widget-convert type))
202 (get (or (get symbol 'custom-get) 'default-value)) 212 (get (or (get symbol 'custom-get) 'default-value))
203 values 213 values)
204 mismatch)
205 (when (default-boundp symbol) 214 (when (default-boundp symbol)
206 (push (funcall get symbol) values) 215 (push (funcall get symbol) values)
207 (push (eval (car (get symbol 'standard-value)) t) values)) 216 (push (eval (car (get symbol 'standard-value)) t) values))
@@ -215,7 +224,9 @@ The detected problematic options are stored in `cus-test-errors'."
215 ;; TODO for booleans, check for values that can be 224 ;; TODO for booleans, check for values that can be
216 ;; evaluated and are not t or nil. Usually a bug. 225 ;; evaluated and are not t or nil. Usually a bug.
217 (unless (widget-apply conv :match value) 226 (unless (widget-apply conv :match value)
218 (setq mismatch 'mismatch))) 227 (let ((err (list symbol :type-error value type)))
228 (unless (member err cus-test-errors)
229 (push err cus-test-errors)))))
219 values) 230 values)
220 231
221 ;; Store symbols with a custom-get property. 232 ;; Store symbols with a custom-get property.
@@ -231,13 +242,12 @@ The detected problematic options are stored in `cus-test-errors'."
231 (and (consp c-value) 242 (and (consp c-value)
232 (boundp symbol) 243 (boundp symbol)
233 (not (equal (eval (car c-value) t) (symbol-value symbol))) 244 (not (equal (eval (car c-value) t) (symbol-value symbol)))
234 (add-to-list 'cus-test-vars-with-changed-state symbol))) 245 (add-to-list 'cus-test-vars-with-changed-state symbol))))
235
236 (if mismatch
237 (push symbol cus-test-errors)))
238 246
239 (error 247 (error
240 (push symbol cus-test-errors) 248 (let ((err (list symbol :other-error alpha)))
249 (unless (member err cus-test-errors)
250 (push err cus-test-errors)))
241 (message "Error for %s: %s" symbol alpha)))) 251 (message "Error for %s: %s" symbol alpha))))
242 (cus-test-get-options regexp)) 252 (cus-test-get-options regexp))
243 (message "%s options tested" 253 (message "%s options tested"
@@ -292,7 +302,7 @@ currently defined groups."
292 (insert "No errors found by cus-test.") 302 (insert "No errors found by cus-test.")
293 (insert "The following variables seem to have problems:\n\n") 303 (insert "The following variables seem to have problems:\n\n")
294 (dolist (e cus-test-errors) 304 (dolist (e cus-test-errors)
295 (insert (symbol-name e) "\n"))))) 305 (insert (cus-test--format-error e) "\n")))))
296 306
297(defun cus-test-load-custom-loads () 307(defun cus-test-load-custom-loads ()
298 "Call `custom-load-symbol' on all atoms." 308 "Call `custom-load-symbol' on all atoms."
@@ -399,7 +409,7 @@ Returns a list of variables with suspicious types."
399 (message "No problems found") 409 (message "No problems found")
400 nil) 410 nil)
401 (message "The following options might have problems:") 411 (message "The following options might have problems:")
402 (cus-test-message cus-test-errors) 412 (cus-test-message (mapcar #'cus-test--format-error cus-test-errors))
403 cus-test-errors)) 413 cus-test-errors))
404 414
405(defun cus-test-deps () 415(defun cus-test-deps ()
diff --git a/admin/make-tarball.txt b/admin/make-tarball.txt
index d881b816125..45da3ed6be5 100644
--- a/admin/make-tarball.txt
+++ b/admin/make-tarball.txt
@@ -150,6 +150,12 @@ General steps (for each step, check for possible errors):
1504. autoreconf -i -I m4 --force 1504. autoreconf -i -I m4 --force
151 make bootstrap 151 make bootstrap
152 152
153 ./admin/check-man-pages
154
155 The above script checks for any mistakes in the source text of
156 manual pages. Fix any errors and re-run the script to verify.
157 Then do this:
158
153 make -C etc/refcards 159 make -C etc/refcards
154 make -C etc/refcards clean 160 make -C etc/refcards clean
155 161
diff --git a/doc/man/etags.1 b/doc/man/etags.1
index 8dbea25c4cf..d3d58b82123 100644
--- a/doc/man/etags.1
+++ b/doc/man/etags.1
@@ -209,7 +209,7 @@ otherwise. This is particularly useful when storing many predefined
209regexps in a file. 209regexps in a file.
210.br 210.br
211In its second form, \fIregexfile\fP is the name of a file that contains 211In its second form, \fIregexfile\fP is the name of a file that contains
212a number of arguments to the \fI\-\-regex\=\fP option, 212a number of arguments to the \fI\-\-regex=\fP option,
213one per line. Lines beginning with a space or tab are assumed 213one per line. Lines beginning with a space or tab are assumed
214to be comments, and ignored. 214to be comments, and ignored.
215 215
@@ -220,22 +220,22 @@ from shell interpretation.
220 220
221Tag the DEFVAR macros in the emacs source files: 221Tag the DEFVAR macros in the emacs source files:
222.br 222.br
223\fI\-\-regex\='/[ \\t]*DEFVAR_[A-Z_ \\t(]+"\\([^"]+\\)"/'\fP 223\fI\-\-regex='/[ \\t]*DEFVAR_[A-Z_ \\t(]+"\\([^"]+\\)"/'\fP
224.\"" This comment is to avoid confusion to Emacs syntax highlighting 224.\"" This comment is to avoid confusion to Emacs syntax highlighting
225.br 225.br
226 226
227Tag VHDL files (this example is a single long line, broken here for 227Tag VHDL files (this example is a single long line, broken here for
228formatting reasons): 228formatting reasons):
229.br 229.br
230\fI\-\-language\=none\ \-\-regex='/[\ \\t]*\\(ARCHITECTURE\\|\\ 230\fI\-\-language=none\ \-\-regex='/[\ \\t]*\\(ARCHITECTURE\\|\\
231CONFIGURATION\\)\ +[^\ ]*\ +OF/'\ \-\-regex\='/[\ \\t]*\\ 231CONFIGURATION\\)\ +[^\ ]*\ +OF/'\ \-\-regex='/[\ \\t]*\\
232\\(ATTRIBUTE\\|ENTITY\\|FUNCTION\\|PACKAGE\\(\ BODY\\)?\\ 232\\(ATTRIBUTE\\|ENTITY\\|FUNCTION\\|PACKAGE\\(\ BODY\\)?\\
233\\|PROCEDURE\\|PROCESS\\|TYPE\\)[\ \\t]+\\([^\ \\t(]+\\)/\\3/'\fP 233\\|PROCEDURE\\|PROCESS\\|TYPE\\)[\ \\t]+\\([^\ \\t(]+\\)/\\3/'\fP
234.br 234.br
235 235
236Tag Tcl files (this last example shows the usage of a \fItagregexp\fP): 236Tag Tcl files (this last example shows the usage of a \fItagregexp\fP):
237.br 237.br
238\fI\-\-lang\=none \-\-regex\='/proc[\ \\t]+\\([^\ \\t]+\\)/\\1/'\fP 238\fI\-\-lang=none \-\-regex='/proc[\ \\t]+\\([^\ \\t]+\\)/\\1/'\fP
239 239
240.br 240.br
241A regexp can be preceded by {\fIlang\fP}, thus restricting it to match 241A regexp can be preceded by {\fIlang\fP}, thus restricting it to match
diff --git a/doc/misc/eglot.texi b/doc/misc/eglot.texi
index b76f8bdfd71..2aff038b9ab 100644
--- a/doc/misc/eglot.texi
+++ b/doc/misc/eglot.texi
@@ -955,6 +955,13 @@ Note that you can still configure the excluded Emacs features manually
955to use Eglot in your @code{eglot-managed-mode-hook} or via some other 955to use Eglot in your @code{eglot-managed-mode-hook} or via some other
956mechanism. 956mechanism.
957 957
958@vindex eglot-report-progress
959@cindex progress
960@item eglot-report-progress
961Set this variable to true if you'd like progress notifications coming
962from the LSP server to be handled as Emacs's progress reporting
963facilities.
964
958@vindex eglot-workspace-configuration 965@vindex eglot-workspace-configuration
959@cindex server workspace configuration 966@cindex server workspace configuration
960@item eglot-workspace-configuration 967@item eglot-workspace-configuration
diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi
index 4561b760c04..80e1bceb8ec 100644
--- a/doc/misc/flymake.texi
+++ b/doc/misc/flymake.texi
@@ -847,7 +847,7 @@ Binding,,, elisp, The Emacs Lisp Reference Manual}) to be active.
847@findex flymake-proc-legacy-flymake 847@findex flymake-proc-legacy-flymake
848The backend @code{flymake-proc-legacy-flymake} was originally designed 848The backend @code{flymake-proc-legacy-flymake} was originally designed
849to be extended for supporting new syntax check tools and error message 849to be extended for supporting new syntax check tools and error message
850patterns. It is also controlled by its own set of customization variables 850patterns. It is also controlled by its own set of customization variables.
851 851
852@node Proc customization variables 852@node Proc customization variables
853@section Customization variables for the Proc backend 853@section Customization variables for the Proc backend
diff --git a/doc/misc/use-package.texi b/doc/misc/use-package.texi
index 4f0f8a26773..daf27ec5bbc 100644
--- a/doc/misc/use-package.texi
+++ b/doc/misc/use-package.texi
@@ -47,9 +47,9 @@ modify this GNU manual.''
47@node Top 47@node Top
48@top use-package User Manual 48@top use-package User Manual
49 49
50The @code{use-package} macro allows you to isolate package 50The @code{use-package} macro allows you to set up package
51customization in your init file in a declarative way. It takes care 51customization in your init file in a declarative way. It takes care
52of a lot of things for you that would otherwise require a lot of 52of many things for you that would otherwise require a lot of
53repetitive boilerplate code. It can help with common customization, 53repetitive boilerplate code. It can help with common customization,
54such as binding keys, setting up hooks, customizing user options and 54such as binding keys, setting up hooks, customizing user options and
55faces, autoloading, and more. It also helps you keep Emacs startup 55faces, autoloading, and more. It also helps you keep Emacs startup
@@ -57,8 +57,9 @@ fast, even when you use many (even hundreds) of packages.
57 57
58Note that use-package is not a package manager. Although use-package 58Note that use-package is not a package manager. Although use-package
59does have the useful capability to interface with the Emacs package 59does have the useful capability to interface with the Emacs package
60manager, its primary purpose is for the configuration and loading of 60manager, its primary purpose is help with the configuration and
61packages. 61loading of packages, not with managing their download, upgrades, and
62installation.
62 63
63@insertcopying 64@insertcopying
64 65
@@ -75,6 +76,8 @@ Appendices
75* Keyword extensions:: Adding new use-package keywords. 76* Keyword extensions:: Adding new use-package keywords.
76* History:: History and acknowledgments. 77* History:: History and acknowledgments.
77* GNU Free Documentation License:: The license for this manual. 78* GNU Free Documentation License:: The license for this manual.
79
80Index
78* Index:: 81* Index::
79@end menu 82@end menu
80@end ifnottex 83@end ifnottex
@@ -88,52 +91,58 @@ customization and use of packages in Emacs. It was created for a few
88basic reasons, each of which drove the design. Understanding these 91basic reasons, each of which drove the design. Understanding these
89reasons may help make some of those decisions clearer: 92reasons may help make some of those decisions clearer:
90 93
94@cindex reasons for developing use-package
91@enumerate 95@enumerate
92@item 96@item
93To gather all configuration details of a package into one place, 97Allow gathering all the configuration details of a package into one
94making it easier to copy, disable, or move it elsewhere in the init 98place, making it easier to copy, disable, or move it elsewhere in the
95file. 99init file.
96 100
97@item 101@item
98To reduce duplication and boilerplate, capturing several common 102Reduce duplication and repetitive boilerplate, capturing several
99practices as mere keywords both easy and intuitive to use. 103common practices as mere keywords both easy and intuitive to use.
100 104
101@item 105@item
102To make startup time of Emacs as quick as possible, without 106Make startup time of Emacs as short as possible, without sacrificing
103sacrificing the quantity of add-on packages used. 107the quantity of add-on packages used.
104 108
105@item 109@item
106To make it so errors encountered during startup disable only the 110Ensure that errors encountered during startup disable only the
107package raising the error, and as little else as possible, leaving as 111package(s) raising the error(s), and as little else as possible,
108close to a functional Emacs as possible. 112leaving Emacs as close to fully functional as possible.
109 113
110@item 114@item
111To allow byte-compilation of one's init file so that any warnings or 115Allow byte-compiling your init file, so that any warnings or errors
112errors seen are meaningful. In this way, even if byte-compilation is 116you see at startup are meaningful. In this way, even if
113not used for speed (reason 3), it can still be used as a sanity check. 117byte-compilation is not used for speed (see item 3 above), it can
118still be used as a sanity check.
114@end enumerate 119@end enumerate
115 120
116It is worth noting that use-package is not intended to replace the 121It is worth noting that use-package is not intended to replace the
117standard @w{@code{M-x customize}}. On the contrary, it is designed to 122standard customization command @w{@kbd{M-x customize}} (@pxref{Easy
118work together with it, for things that customize cannot do. 123Customization,,, emacs, GNU Emacs Manual}). On the contrary, it is
124designed to work together with it, for things that Customize cannot
125do.
119 126
120@c ---------------------------------------------------------------------------- 127@c ----------------------------------------------------------------------------
121@node Getting Started 128@node Getting Started
122@chapter Getting Started 129@chapter Getting Started
130@cindex quick-start instructions
123 131
124This chapter provides instructions and examples for quickly getting 132This chapter provides instructions and examples for quickly getting
125started with use-package. The first thing you need to do is make sure 133started with use-package. The first thing you need to do is make sure
126that @samp{use-package} itself is loaded. To do that, put this at the 134that @file{use-package} itself is loaded. To do that, put this at the
127top of your init file: 135top of your init file:
128 136
129@lisp 137@lisp
130(require 'use-package) 138(require 'use-package)
131@end lisp 139@end lisp
132 140
133The above makes the @code{use-macro} for in the rest of your init 141@cindex declaration
134file. In this manual, we call each call to @code{use-macro} a 142The above makes the @code{use-macro} available for us in the rest of
135@dfn{declaration}, to highlight the declarative nature of its 143your init file. In this manual, we say that each call to
136semantic. 144@code{use-macro} is a @dfn{declaration}, to highlight the declarative
145nature of its syntax.
137 146
138To unconditionally load a package named @samp{foo}, add the following 147To unconditionally load a package named @samp{foo}, add the following
139declaration to your init file: 148declaration to your init file:
@@ -143,62 +152,70 @@ declaration to your init file:
143@end lisp 152@end lisp
144 153
145@noindent 154@noindent
146This declaration is equivalent to using @code{require}, with some 155This declaration is equivalent to using @code{require} (@pxref{Named
147use-package specific error handling added in. Just like require, it 156Features,,, elisp, GNU Emacs Lisp Reference Manual}), with some
148needs the package @samp{foo} to be installed and available in your 157use-package specific error handling added in. Just like
149@code{load-path} (@pxref{Installing packages}). 158@code{require}, it needs the package @samp{foo} to be installed and
159available via your @code{load-path} (@pxref{Installing packages}).
150 160
151To evaluate Lisp code @emph{before} the @samp{foo} package is loaded, 161To evaluate some Lisp @emph{before} the @samp{foo} package is loaded,
152use the @code{:init} keyword: 162use the @code{:init} keyword:
153 163
154@lisp 164@lisp
165@group
155(use-package foo 166(use-package foo
156 :init 167 :init
157 (setq foo-variable t)) 168 (setq foo-variable t))
169@end group
158@end lisp 170@end lisp
159 171
160Similarly, @code{:config} can be used to execute code @emph{after} a 172Similarly, @code{:config} can be used to execute code @emph{after} a
161package is loaded. In cases where loading is done lazily 173package is loaded. In cases where loading is done lazily
162(@pxref{Loading Packages}), this execution is deferred until after the 174(@pxref{Loading Packages}), this execution is deferred until after the
163autoload occurs. As you might expect, you can use @code{:init} and 175loading actually occurs. As you might expect, you can use
164@code{:config} together: 176@code{:init} and @code{:config} together:
165 177
166@lisp 178@lisp
179@group
167(use-package foo 180(use-package foo
168 :init 181 :init
169 (setq foo-variable t) 182 (setq foo-variable t)
170 :config 183 :config
171 (foo-mode 1)) 184 (foo-mode 1))
185@end group
172@end lisp 186@end lisp
173 187
174The above declarations will all load the @samp{foo} package 188The above declarations will load the @samp{foo} package
175immediately. In most cases, this is not necessary or desirable, as 189immediately. In most cases, this is not necessary or desirable, as
176that will slow down Emacs startup. Instead, you should try to set 190that will slow down Emacs startup. Instead, you should try to set
177things up so that packages are only loaded when they are actually 191things up so that packages are only loaded when they are actually
178needed (autoloading). If you have installed a package from 192needed (a.k.a. ``autoloading''). If you have installed a package from
179@acronym{GNU ELPA} that provides it's own autoloads, it is often 193@acronym{GNU ELPA} that provides it's own autoloads, it is often
180enough to say: 194enough to say:
181 195
182@lisp 196@lisp
197@group
183(use-package foo 198(use-package foo
184 :defer t) 199 :defer t)
200@end group
185@end lisp 201@end lisp
186 202
187@noindent 203@noindent
188This will avoid loading the package. Now, when you run any autoloaded 204This will avoid loading the package. Now, when you run any autoloaded
189command, the package @samp{foo} is loaded automatically. Package 205command, the package @samp{foo} is loaded automatically. (Which
190authors will make their own decisions about which commands are marked 206commands from a package are marked to auto-load by default is the
191to autoload by default. 207decision of the package authors.)
192 208
193In some cases, you might need or want to provide your own autoloads. 209In some cases, you might need or want to provide your own autoloads.
194The below more complex example autoloads the commands 210The more complex example below autoloads the commands
195@code{isearch-moccur} and @code{isearch-all} from 211@code{isearch-moccur} and @code{isearch-all} from the package
196@file{color-moccur.el}, and binds keys both globally and in 212@file{color-moccur.el}, and binds keys both globally and in
197@code{isearch-mode-map}. When one of these commands are used, the 213@code{isearch-mode-map}. When one of these two commands are used, the
198package is loaded. At that point, @code{moccur-edit} is also loaded, 214package will be loaded. At that point, @code{moccur-edit} is also loaded,
199to allow editing of the @code{moccur} buffer. 215to allow editing of the @code{moccur} buffer.
200 216
201@lisp 217@lisp
218@group
202(use-package color-moccur 219(use-package color-moccur
203 :commands (isearch-moccur isearch-all) 220 :commands (isearch-moccur isearch-all)
204 :bind (("M-s O" . moccur) 221 :bind (("M-s O" . moccur)
@@ -209,6 +226,7 @@ to allow editing of the @code{moccur} buffer.
209 (setq isearch-lazy-highlight t) 226 (setq isearch-lazy-highlight t)
210 :config 227 :config
211 (use-package moccur-edit)) 228 (use-package moccur-edit))
229@end group
212@end lisp 230@end lisp
213 231
214Some packages will suggest ready-made @code{use-package} declarations 232Some packages will suggest ready-made @code{use-package} declarations
@@ -220,8 +238,8 @@ That should be enough to get you started!
220@c ---------------------------------------------------------------------------- 238@c ----------------------------------------------------------------------------
221@node Loading Packages 239@node Loading Packages
222@chapter Loading Packages 240@chapter Loading Packages
241@cindex loading packages with use-package
223 242
224@cindex loading packages
225Before use-package can load an Emacs Lisp package, it must be 243Before use-package can load an Emacs Lisp package, it must be
226available in a directory on your @code{load-path}. When you install 244available in a directory on your @code{load-path}. When you install
227packages using the built-in @code{install-package} command, it will do 245packages using the built-in @code{install-package} command, it will do
@@ -230,15 +248,15 @@ packages) are always available.
230 248
231If you install packages manually, you must make sure they are 249If you install packages manually, you must make sure they are
232available on your @code{load-path}. @xref{Lisp Libraries,,, emacs, 250available on your @code{load-path}. @xref{Lisp Libraries,,, emacs,
233GNU Emacs Manual} for details. 251GNU Emacs Manual}, for details.
234 252
235Some packages have more than one library. In those cases, you might 253Some packages have more than one library. In those cases, you might
236need more than one @code{use-package} declaration to make sure it is 254need more than one @code{use-package} declaration to make sure the
237properly loaded. For complex configurations, you might also need more 255package is properly loaded. For complex configurations, you might
238than one declaration for a package with the same name. 256also need more than one declaration for a package with the same name.
239 257
240use-package can interface with @samp{package.el} to install packages 258use-package can interface with @samp{package.el} to install packages
241on Emacs start. @xref{Installing packages} for details. 259on Emacs start. @xref{Installing packages}, for details.
242 260
243@menu 261@menu
244* Loading basics:: How and when packages are loaded. 262* Loading basics:: How and when packages are loaded.
@@ -254,32 +272,38 @@ on Emacs start. @xref{Installing packages} for details.
254@node Loading basics 272@node Loading basics
255@section How and when use-package loads packages 273@section How and when use-package loads packages
256 274
257The @code{use-package} macro either will either load a package 275The call to the @code{use-package} macro will load a package either
258immediately, or when they are first used (autoloading). In the 276immediately, or when the package is first used (via autoloading). In the
259simplest case, a @code{use-package} declaration loads a package when 277simplest case, a @code{use-package} declaration loads a package when
260it is evaluated.@footnote{This happens both at run-time and at 278it is evaluated.@footnote{This happens both at run-time and at
261compile-time. @xref{Byte-compiling}.} If the declaration is in your 279compile-time. @xref{Byte-compiling}.} If the declaration is in your
262init file, this happens automatically each time Emacs is started. 280init file, this happens automatically each time Emacs is started.
263 281
264For example, the below declaration immediately loads the library 282For example, the declaration below immediately loads the library
265@code{foo}, just like @code{require} would. If the library @samp{foo} 283@code{foo}, just like @code{require} would:
266is not available in your @code{load-path}, it logs a warning to the
267@samp{*Messages*} buffer:
268 284
269@lisp 285@lisp
270(use-package foo) 286(use-package foo)
271@end lisp 287@end lisp
272 288
289@noindent
290If the library @samp{foo} is not available in your @code{load-path},
291the declaration logs a warning to the @samp{*Messages*} buffer.
292
293@cindex package vs library
294@c So, confusingly, (use-package foo) actually means to use the
295@c _library_ foo.el, not all of the _package_ foo's libraries?
296@c Should this be explicitly explained here?
273Note that a ``package'' is different from an Emacs Lisp ``library''. 297Note that a ``package'' is different from an Emacs Lisp ``library''.
274The above declaration tells use-package to load the @emph{library} 298The above declaration tells use-package to load the @emph{library}
275@file{foo.el}, which the overwhelming majority of cases also resides 299@file{foo.el}, which in the overwhelming majority of cases also
276in a @emph{package} named @code{foo}. But the @code{foo} package 300resides in a @emph{package} named @code{foo}. But the package
277might also contain a library named @file{foo-extra.el}. If that 301@code{foo} might also contain a library named @file{foo-extra.el}. If
278library is not loaded automatically, you will need a separate 302that library is not loaded automatically, you will need a separate
279@code{use-package} declaration to make sure that it is. This manual 303@code{use-package} declaration to make sure that it is loaded when
280will often use these terms interchangeably, as this distinction does 304needed. This manual will often use the terms ``package'' and
281not usually matter, but you should keep it in mind for the cases when 305``library'' interchangeably, as this distinction does not usually
282it does. 306matter, but you should keep it in mind for the cases when it does.
283 307
284The details of how and when you should load a package might differ 308The details of how and when you should load a package might differ
285from one package to another. When in doubt, refer to the package 309from one package to another. When in doubt, refer to the package
@@ -287,17 +311,19 @@ documentation for details.
287 311
288@node Deferring loading 312@node Deferring loading
289@section Deferring package loading 313@section Deferring package loading
314@cindex deferring loading of package
290 315
291@cindex autoloading packages 316@cindex autoloading packages
292@cindex loading lazily 317@cindex loading lazily
318@cindex lazy loading of packages
293In the examples we have seen so far, use-package loads packages every 319In the examples we have seen so far, use-package loads packages every
294time you start Emacs, even if that package is never used. That will 320time you start Emacs, even if that package is never used. That will
295make starting Emacs slower. use-package therefore tries to set things 321make starting Emacs slower. use-package therefore allows setting
296up in such a way that it only loads packages when a command is first 322things up in such a way that packages are only loaded when some of the
297used (either with @kbd{M-x} or some key binding). This is based on 323package's commands is first used (either with @kbd{M-x} or via some key
298autoloading, a full description of which is outside the scope of this 324binding). This is based on autoloading, a full description of which
299manual. @xref{Autoload,,, elisp, GNU Emacs Lisp Reference Manual} for 325is outside the scope of this manual. @xref{Autoload,,, elisp, GNU
300the full story. 326Emacs Lisp Reference Manual}, for the full story.
301 327
302@cindex triggers, for loading packages 328@cindex triggers, for loading packages
303Some @code{use-package} keywords provide autoload @dfn{triggers} that 329Some @code{use-package} keywords provide autoload @dfn{triggers} that
@@ -320,8 +346,10 @@ this package from being immediately loaded. Here is an example of
320using @code{:defer} to postpone loading the package @samp{foo}: 346using @code{:defer} to postpone loading the package @samp{foo}:
321 347
322@lisp 348@lisp
349@group
323(use-package foo 350(use-package foo
324 :defer t) 351 :defer t)
352@end group
325@end lisp 353@end lisp
326 354
327Using @code{:defer t} by itself like this is rarely useful. 355Using @code{:defer t} by itself like this is rarely useful.
@@ -331,21 +359,25 @@ Typically, you would only use it together with a keyword like
331 359
332@subheading Defer loading until idle for N seconds 360@subheading Defer loading until idle for N seconds
333 361
334You can also give a numeric argument @var{N} to @w{@code{:defer}} to 362@findex :defer@r{, with a numeric argument}
363You can also give a numeric argument @var{n} to @w{@code{:defer}} to
335specify that a package should be loaded (if it hasn't already) after 364specify that a package should be loaded (if it hasn't already) after
336Emacs has been idle for @var{N} seconds. For example, use this to 365Emacs has been idle for @var{n} seconds. For example, use the
337make use-package load @samp{foo} after 30 seconds of idle time: 366following to make use-package load @samp{foo} after 30 seconds of idle
367time:
338 368
339@lisp 369@lisp
370@group
340(use-package foo 371(use-package foo
341 :defer 30) 372 :defer 30)
373@end group
342@end lisp 374@end lisp
343 375
344@subheading When to use @code{:defer} 376@subheading When to use @code{:defer}
345 377
346When using autoloading keywords, there is no need to also use 378When using autoloading keywords, there is no need to also use
347@code{:defer}. It doesn't hurt anything to add it in this case, 379@code{:defer}. It doesn't hurt to add it in this case, perhaps for
348perhaps for extra clarity, but it is redundant. 380extra clarity, but it is redundant.
349 381
350You should use @code{:defer} to force deferred loading, in cases when 382You should use @code{:defer} to force deferred loading, in cases when
351use-package isn't creating any autoloads for you. For example, you 383use-package isn't creating any autoloads for you. For example, you
@@ -357,6 +389,8 @@ autoloads already set up.
357 389
358@subheading Making @w{@code{:defer t}} the default 390@subheading Making @w{@code{:defer t}} the default
359 391
392@cindex defer loading by default
393@cindex lazy loading by default
360@vindex use-package-always-defer 394@vindex use-package-always-defer
361If you customize the user option @code{use-package-always-defer} to 395If you customize the user option @code{use-package-always-defer} to
362non-@code{nil}, the @code{use-package} macro will behave as if 396non-@code{nil}, the @code{use-package} macro will behave as if
@@ -366,6 +400,7 @@ individual declarations using either @w{@code{:defer nil}} or
366 400
367@node Forcing loading 401@node Forcing loading
368@section Forcing package to load immediately 402@section Forcing package to load immediately
403@cindex forcing immediate loading
369 404
370@findex :demand 405@findex :demand
371The presence of autoloading trigger keywords can be overridden using 406The presence of autoloading trigger keywords can be overridden using
@@ -380,6 +415,8 @@ If you specify both @w{@code{:demand t}} and @w{@code{:defer t}}, the
380 415
381@node Conditional loading 416@node Conditional loading
382@section Loading packages conditionally 417@section Loading packages conditionally
418@cindex conditional loading
419@cindex loading conditions
383 420
384@findex :if 421@findex :if
385@findex :when 422@findex :when
@@ -398,8 +435,10 @@ For example, if you only want to load @samp{foo} in graphical Emacs
398sessions, you could use the following: 435sessions, you could use the following:
399 436
400@lisp 437@lisp
438@group
401(use-package foo 439(use-package foo
402 :if (display-graphic-p)) 440 :if (display-graphic-p))
441@end group
403@end lisp 442@end lisp
404 443
405@subheading Some common use cases 444@subheading Some common use cases
@@ -407,39 +446,46 @@ sessions, you could use the following:
407Here are some common cases for conditional loading, and how to achieve 446Here are some common cases for conditional loading, and how to achieve
408them. 447them.
409 448
449@c FIXME: Too many redundant examples? E.g., why do we need both an
450@c example for system-type and window-system? or both of the last 2
451@c examples?
410@itemize 452@itemize
411 453
412@item Operating system 454@item
455Operating system
413 456
414This example loads a package only on GNU/Linux. See the 457The following example loads a package only on GNU/Linux. See the
415@code{system-type} docstring for other valid values. 458docstring of @code{system-type} for other valid values.
416 459
417@lisp 460@lisp
418:if (eq system-type 'gnu/linux) 461:if (eq system-type 'gnu/linux)
419@end lisp 462@end lisp
420 463
421@item Window system 464@item
465Window system
422 466
423This example loads a package only on macOS and X. See the 467The example below loads a package only on macOS and X. See the
424@code{window-system} docstring for valid values. 468docstring of @code{window-system} for valid values.
425 469
426@lisp 470@lisp
427:if (memq window-system '(ns x)) 471:if (memq window-system '(ns x))
428@end lisp 472@end lisp
429 473
430@item Installed package 474@item
475Installed package
431 476
432This example loads a package only when the @samp{foo} package is 477The following example loads a package only when the @samp{foo} package
433installed. 478is installed.
434 479
435@lisp 480@lisp
436:if (package-installed-p 'foo) 481:if (package-installed-p 'foo)
437@end lisp 482@end lisp
438 483
439@item Libraries in @code{load-path} 484@item
485Libraries in @code{load-path}
440 486
441This example loads a package only when @file{foo.el} is available in 487The example below loads a package only when @file{foo.el} is available
442your @code{load-path} (for example, if you installed that file 488in your @code{load-path} (for example, if you installed that file
443manually): 489manually):
444 490
445@lisp 491@lisp
@@ -450,38 +496,45 @@ manually):
450@subheading Making conditional loading affect @code{:preface} and @code{:ensure} 496@subheading Making conditional loading affect @code{:preface} and @code{:ensure}
451 497
452@cindex conditional loading before @code{:preface} or @code{:ensure} 498@cindex conditional loading before @code{:preface} or @code{:ensure}
453If you need to conditionalize a use-package form so that the condition 499If you need to make a use-package form conditional so that the condition
454occurs before even @code{:ensure} or @code{:preface}, use @code{when} 500occurs before even @code{:ensure} (@pxref{Install package}) or
455around the use-package form itself. For example: 501@code{:preface} (@pxref{Preface keyword}), use @code{when}
502around the @code{use-package} form itself. For example:
456 503
457@lisp 504@lisp
505@group
458(when (memq window-system '(mac ns)) 506(when (memq window-system '(mac ns))
459 (use-package foo 507 (use-package foo
460 :ensure t)) 508 :ensure t))
509@end group
461@end lisp 510@end lisp
462 511
463@node Loading sequentially 512@node Loading sequentially
464@section Loading packages in sequence 513@section Loading packages in sequence
514@cindex loading a package after other packages
465 515
466@findex :after 516@findex :after
467Sometimes it only makes sense to configure a package after another one 517Sometimes it only makes sense to configure a package after another one
468has been loaded, because certain variables or functions are not in 518has been loaded, because certain variables or functions are not in
469scope until that time. This can achieved with the @code{:after} 519scope until that time. This can be achieved with the @code{:after}
470keyword, which allows a fairly rich description of the exact 520keyword, which allows a fairly rich description of the exact
471conditions when loading should occur. It takes either a symbol 521conditions when loading should occur. The @code{:after} keyword takes
472indicating the package name, a list of such symbols, or a list of 522as argument either a symbol indicating the package name, a list of
473selectors (see below). 523such symbols, or a list of selectors (see below).
474 524
475Here is an example of using the @acronym{GNU ELPA} packages hydra, 525Here is an example of using the @acronym{GNU} @acronym{ELPA} packages
476ivy, and ivy-hydra. Note that ivy-hydra will always be loaded last: 526@file{hydra}, @file{ivy}, and @file{ivy-hydra}. Note that
527@file{ivy-hydra} will always be loaded last:
477 528
478@lisp 529@lisp
479(use-package hydra) 530(use-package hydra)
480 531
481(use-package ivy) 532(use-package ivy)
482 533
534@group
483(use-package ivy-hydra 535(use-package ivy-hydra
484 :after (ivy hydra)) 536 :after (ivy hydra))
537@end group
485@end lisp 538@end lisp
486 539
487In this case, because the declarations are evaluated in the order they 540In this case, because the declarations are evaluated in the order they
@@ -494,11 +547,12 @@ moving things around in your init file is less likely to break things.
494 547
495@subheading Using @code{:after} selectors 548@subheading Using @code{:after} selectors
496 549
497@findex :all (with :after) 550@findex :all@r{, (with @code{:after})}
498@findex :any (with :after) 551@findex :any@r{, (with @code{:after})}
552@cindex list of selectors, for @code{:after}
499The @code{:after} keyword also accepts a list of selectors. By 553The @code{:after} keyword also accepts a list of selectors. By
500default, @code{:after (foo bar)} is the same as @w{@code{:after (:all 554default, @w{@code{:after (foo bar)}} is the same as @w{@code{:after
501foo bar)}}, meaning that loading of the given package will not happen 555(:all foo bar)}}, meaning that loading of the given package will not happen
502until both @code{foo} and @code{bar} have been loaded. Here are some 556until both @code{foo} and @code{bar} have been loaded. Here are some
503of the other possibilities: 557of the other possibilities:
504 558
@@ -510,22 +564,25 @@ of the other possibilities:
510:after (:any (:all foo bar) (:all baz quux)) 564:after (:any (:all foo bar) (:all baz quux))
511@end verbatim 565@end verbatim
512 566
513When you nest selectors, such as @code{(:any (:all foo bar) (:all baz 567When you nest selectors, such as in @w{@code{(:any (:all foo bar)
514quux))}, it means that the package will be loaded when either both 568(:all baz quux))}}, it means that the package will be loaded when
515@code{foo} and @code{bar} have been loaded, or when both @code{baz} 569either both @code{foo} and @code{bar} have been loaded, or when both
516and @code{quux} have been loaded. 570@code{baz} and @code{quux} have been loaded.
517 571
572@cindex @code{use-package-always-defer}, with @code{:after}
518Pay attention when setting @code{use-package-always-defer} to a 573Pay attention when setting @code{use-package-always-defer} to a
519non-@code{nil} value, and also using the @code{:after} keyword. In 574non-@code{nil} value, and also using the @code{:after} keyword. In
520this case, you will need to specify how the declared package is to be 575that case, you will need to specify how the declared package is to be
521loaded: for example, by some @code{:bind}. If you are not using one 576loaded: for example, by some @code{:bind} (@pxref{Global
522of the keywords that registers autoloads, such as @code{:bind} or 577keybindings}). If you are not using one of the keywords that
523@code{:hook}, and your package manager does not provide autoloads, it 578registers autoloads, such as @code{:bind} or @code{:hook}
524is possible that your package will never be loaded if you do not add 579(@pxref{Hooks}), and your package manager does not provide autoloads,
525@code{:demand t} to those declarations. 580it is possible that your package will never be loaded if you do not
581add @code{:demand t} to those declarations.
526 582
527@node Load dependencies 583@node Load dependencies
528@section Prevent loading if dependencies are missing 584@section Prevent loading if dependencies are missing
585@cindex prevent loading package if dependencies are missing
529 586
530@findex :requires 587@findex :requires
531While the @code{:after} keyword delays loading until the dependencies 588While the @code{:after} keyword delays loading until the dependencies
@@ -536,22 +593,29 @@ loads the package if the dependencies are not available when the
536'foo)}} evaluates to a non-@code{nil} value. For example: 593'foo)}} evaluates to a non-@code{nil} value. For example:
537 594
538@lisp 595@lisp
596@group
539(use-package abbrev 597(use-package abbrev
540 :requires foo) 598 :requires foo)
599@end group
541@end lisp 600@end lisp
542 601
602@noindent
543This is the same as: 603This is the same as:
544 604
545@lisp 605@lisp
606@group
546(use-package abbrev 607(use-package abbrev
547 :if (featurep 'foo)) 608 :if (featurep 'foo))
609@end group
548@end lisp 610@end lisp
549 611
550As a convenience, a list of such packages may be specified: 612As a convenience, a list of such packages may be specified:
551 613
552@lisp 614@lisp
615@group
553(use-package abbrev 616(use-package abbrev
554 :requires (foo bar baz)) 617 :requires (foo bar baz))
618@end group
555@end lisp 619@end lisp
556 620
557For more complex logic, such as that supported by @code{:after}, 621For more complex logic, such as that supported by @code{:after},
@@ -559,64 +623,81 @@ simply use @code{:if} and the appropriate Lisp expression.
559 623
560@node Load path 624@node Load path
561@section Setting a custom @code{load-path} 625@section Setting a custom @code{load-path}
626@cindex custom @code{load-path} for loading a package
627@cindex @code{load-path}, add directories for loading a package
562 628
563@findex :load-path 629@findex :load-path
564If a package resides in some directory that is not in your 630If a package resides in some directory that is not in your
565@code{load-path}, use the @code{:load-path} keyword to add it. It 631@code{load-path}, use the @code{:load-path} keyword to add it. It
566takes a symbol, a function, a string or a list of strings. If the 632takes as argument a symbol, a function, a string or a list of strings.
567path is relative, it is expanded within @code{user-emacs-directory}. 633If a directory is specified as a relative file name, it is expanded
634relative to @code{user-emacs-directory}.
568 635
569For example: 636For example:
570 637
571@lisp 638@lisp
639@group
572(use-package ess-site 640(use-package ess-site
573 :load-path "site-lisp/ess/lisp/" 641 :load-path "site-lisp/ess/lisp/"
574 :commands R) 642 :commands R)
643@end group
575@end lisp 644@end lisp
576 645
577Note that when using a symbol or a function to provide a dynamically 646Note that when using a symbol or a function to provide a dynamically
578generated list of paths, you must inform the byte-compiler of this 647generated list of directories, you must inform the byte-compiler of this
579definition so that the value is available at byte-compilation time. 648definition so that the value is available at byte-compilation time.
580This is done by using the special form @code{eval-and-compile} (as 649This is done by using the special form @code{eval-and-compile} (as
581opposed to @code{eval-when-compile}). Further, this value is fixed at 650opposed to @code{eval-when-compile}, @pxref{Eval During Compile,,,
651elisp, GNU Emacs Lisp Reference Manual}). Further, this value is fixed at
582whatever was determined during compilation, to avoid looking up the 652whatever was determined during compilation, to avoid looking up the
583same information again on each startup. For example: 653same information again on each startup. For example:
584 654
655@c FIXME: the below should use shell-command-to-string, surely?
585@lisp 656@lisp
657@group
586(eval-and-compile 658(eval-and-compile
587 (defun ess-site-load-path () 659 (defun ess-site-load-path ()
588 (shell-command "find ~ -path ess/lisp"))) 660 (shell-command "find ~ -path ess/lisp")))
661@end group
589 662
663@group
590(use-package ess-site 664(use-package ess-site
591 :load-path (lambda () (list (ess-site-load-path))) 665 :load-path (lambda () (list (ess-site-load-path)))
592 :commands R) 666 :commands R)
667@end group
593@end lisp 668@end lisp
594 669
595@node Manual autoloads 670@node Manual autoloads
596@section Setting up autoloads manually 671@section Setting up autoloads manually
672@cindex autoloads for packages, setting up manually
673@cindex package autoloads, setting up manually
597 674
598@findex :commands 675@findex :commands
599@findex :autoload 676@findex :autoload
600To autoload an interactive command, use the @code{:commands} keyword. 677To autoload an interactive command, use the @code{:commands} keyword.
601When you use the @code{:commands} keyword, it creates autoloads for 678When you use the @code{:commands} keyword, it creates autoloads for
602those commands (which defers loading of the module until they are 679those commands (which defers loading of the module until those commands are
603used). The @code{:commands} keyword takes either a symbol or a list 680used). The @code{:commands} keyword takes either a symbol or a list
604of symbols. 681of symbols as its argument.
605 682
606The @code{:autoload} keyword works like @code{:commands}, but is used 683The @code{:autoload} keyword works like @code{:commands}, but is used
607to autoload non-interactive functions. Here is an example: 684to autoload non-interactive functions. Here is an example:
608 685
609@lisp 686@lisp
687@group
610(use-package org-crypt 688(use-package org-crypt
611 :autoload org-crypt-use-before-save-magic) 689 :autoload org-crypt-use-before-save-magic)
690@end group
612@end lisp 691@end lisp
613 692
614@c ---------------------------------------------------------------------------- 693@c ----------------------------------------------------------------------------
615@node Configuring Packages 694@node Configuring Packages
616@chapter Configuring Packages 695@chapter Configuring Packages
696@cindex configure packages using @code{use-package}
697@cindex customize package configuration
617 698
618This chapter describes the various keywords provided by 699This chapter describes the various keywords provided by
619@code{use-package} that helps you configure packages. 700@code{use-package} that help you configure packages.
620 701
621@menu 702@menu
622* Lisp Configuration:: Using Lisp to configure packages. 703* Lisp Configuration:: Using Lisp to configure packages.
@@ -631,6 +712,7 @@ This chapter describes the various keywords provided by
631 712
632@node Lisp Configuration 713@node Lisp Configuration
633@section Using Lisp code for configuring packages 714@section Using Lisp code for configuring packages
715@cindex configure package using Lisp forms
634 716
635The most general way to add customizations are the @code{:preface}, 717The most general way to add customizations are the @code{:preface},
636@code{:init}, and @code{:config} keywords. They all accept one or 718@code{:init}, and @code{:config} keywords. They all accept one or
@@ -657,19 +739,22 @@ function and variable definitions that will:
657 739
658@enumerate 740@enumerate
659@item 741@item
660Make the byte-compiler happy. It will not complain about functions 742@c FIXME: ``within a guard block''? what's that??
743Make the byte-compiler happy: it will not complain about functions
661whose definitions are unknown because you have them within a guard 744whose definitions are unknown because you have them within a guard
662block. 745block.
663 746
664@item 747@item
665Define code that can be used in an @code{:if} test. 748Define functions and variables that will be used in an @code{:if}
749test.
666@end enumerate 750@end enumerate
667 751
668Note that whatever is specified within @code{:preface} is evaluated 752Note that whatever is specified within @code{:preface} is evaluated
669both at load time and at byte-compilation time, in order to ensure 753both at load time and at byte-compilation time, in order to ensure
670that definitions are seen by both the Lisp evaluator and the 754that definitions are seen by both the Lisp evaluator and the
671byte-compiler. Therefore, you should avoid having any side-effects in 755byte-compiler. Therefore, you should avoid having any side-effects in
672your preface, and restrict it to symbol declarations and definitions. 756your @code{:preface} forms, and restrict them to symbol declarations
757and definitions.
673 758
674@node Init keyword 759@node Init keyword
675@subsection @code{:init} is evaluated before loading package 760@subsection @code{:init} is evaluated before loading package
@@ -677,10 +762,11 @@ your preface, and restrict it to symbol declarations and definitions.
677@findex :init 762@findex :init
678The @code{:init} section is evaluated just before the package is 763The @code{:init} section is evaluated just before the package is
679loaded. Note that the @code{:init} form is run unconditionally -- 764loaded. Note that the @code{:init} form is run unconditionally --
680even if the @code{foo} package happens to not exist on your system. 765even if the package happens to not exist on your system. You must
681You must therefore remember to restrict @code{:init} code to only what 766therefore remember to restrict @code{:init} code to what would succeed
682would succeed either way. @code{:init} also always happens before 767either way; put the rest in the @code{:config} section. @code{:init}
683package load, whether @code{:config} has been deferred or not. 768also always happens before package load, whether @code{:config} has
769been deferred or not.
684 770
685@node Config keyword 771@node Config keyword
686@subsection @code{:config} is evaluated after loading package 772@subsection @code{:config} is evaluated after loading package
@@ -698,58 +784,68 @@ Emacs start as quickly as possible.
698 784
699@node Best practices 785@node Best practices
700@subheading When to use @code{:preface}, @code{:config} and @code{:init}? 786@subheading When to use @code{:preface}, @code{:config} and @code{:init}?
787@cindex tips for using @code{:preface}, @code{:config}, @code{:init}
701 788
702Where possible, it is better to avoid @code{:preface}, @code{:config} 789Where possible, it is better to avoid @code{:preface}, @code{:config}
703and @code{:init}. Instead, prefer autoloading keywords such as 790and @code{:init}. Instead, prefer autoloading keywords such as
704@code{:bind}, @code{:hook}, and @code{:mode}, as they will take care 791@code{:bind} (@pxref{Key bindings}), @code{:hook} (@pxref{Hooks}), and
792@code{:mode} (@pxref{Modes and interpreters}), as they will take care
705of setting up autoloads for you without any need for boilerplate code. 793of setting up autoloads for you without any need for boilerplate code.
706For example, consider the following declaration: 794For example, consider the following declaration:
707 795
708@lisp 796@lisp
797@group
709(use-package foo 798(use-package foo
710 :init 799 :init
711 (add-hook 'some-hook 'foo-mode)) 800 (add-hook 'some-hook 'foo-mode))
801@end group
712@end lisp 802@end lisp
713 803
804@noindent
714This has two problems. First, it will unconditionally load the 805This has two problems. First, it will unconditionally load the
715package @samp{foo} on startup, which will make things slower. You can 806package @samp{foo} on startup, which will make things slower. You can
716fix this by adding @code{:defer t}: 807fix this by adding @w{@code{:defer t}}:
717 808
718@lisp 809@lisp
810@group
719(use-package foo 811(use-package foo
720 :defer t 812 :defer t
721 :init 813 :init
722 (add-hook 'some-hook 'foo-mode)) 814 (add-hook 'some-hook 'foo-mode))
815@end group
723@end lisp 816@end lisp
724 817
818@noindent
725This is better, as @samp{foo} is now only loaded when it is actually 819This is better, as @samp{foo} is now only loaded when it is actually
726needed (that is, when the hook @samp{some-hook} is run). 820needed (that is, when the hook @samp{some-hook} is run).
727 821
728The second problem is that there is a lot of boilerplate that you have 822The second problem is that there is a lot of boilerplate that you have
729to write. In this case, it might not be so bad, but avoiding that was 823to write. In this case, it might not be so bad, but avoiding that was
730what use-package was made to avoid. The better option in this case is 824what use-package was made to allow. The better option in this case is
731therefore to use @code{:hook} (@xref{Hooks}), which also implies 825therefore to use @code{:hook} (@pxref{Hooks}), which also implies
732@w{@code{:defer t}}. The above is thereby reduced down to: 826@w{@code{:defer t}}. The above is thereby reduced down to:
733 827
734@lisp 828@lisp
829@group
735(use-package foo 830(use-package foo
736 :hook some-hook) 831 :hook some-hook)
832@end group
737@end lisp 833@end lisp
738 834
739use-package will set up autoloading for you, and your Emacs startup 835Now use-package will set up autoloading for you, and your Emacs
740time will not suffer one bit. 836startup time will not suffer one bit.
741 837
742@node Key bindings 838@node Key bindings
743@section Key bindings 839@section Key bindings
744 840
745@cindex :bind 841@cindex binding keys for package commands
746@cindex binding keys 842@cindex key bindings for package commands
747@cindex key bindings 843One common thing to do when loading a package is to bind keys to
748One common thing to do when loading a package is to bind a key to
749commands within that module. Without use-package, this would be done 844commands within that module. Without use-package, this would be done
750using a combination of @code{keymap-local-set}, 845using a combination of @code{keymap-local-set},
751@code{keymap-global-set} and various autoloads. With use-package, you 846@code{keymap-global-set} and various autoloads. With use-package, you
752can simplify this using the @code{:bind} keyword. 847can simplify this using the @code{:bind} keyword, as described in this
848section.
753 849
754@menu 850@menu
755* Global keybindings:: Bindings you can use anywhere. 851* Global keybindings:: Bindings you can use anywhere.
@@ -761,25 +857,29 @@ can simplify this using the @code{:bind} keyword.
761 857
762@node Global keybindings 858@node Global keybindings
763@subsection Global keybindings 859@subsection Global keybindings
860@cindex global keybindings
764 861
765@findex :bind 862@findex :bind
766To bind keys globally, the @code{:bind} keyword takes either a single 863To bind keys globally, the @code{:bind} keyword takes as its argument
767cons or a list of conses. Every cons has the form @code{(@var{key} 864either a single cons or a list of conses. Each cons has the form
768. @var{command}}, where @var{key} is a string indicating the key to 865@w{@code{(@var{key} . @var{command})}}, where @var{key} is a string
769bind, and @var{command} is the name of a command (a symbol). The 866indicating the key to bind, and @var{command} is the name of a command
770syntax for the keys is similar to the syntax used by the @code{kbd} 867(a symbol). The syntax for the keys is similar to the syntax used by
771function (@pxref{Init Rebinding,,, emacs, GNU Emacs Manual} for more 868the @code{kbd} function (see @ref{Init Rebinding,,, emacs, GNU Emacs
772information). 869Manual}, for more information).
773 870
774@subheading Using @code{:bind} with a single cons 871@subheading Using @code{:bind} with a single cons
775 872
776Here is an example of using a single cons: 873Here is an example of using a single cons:
777 874
778@lisp 875@lisp
876@group
779(use-package ace-jump-mode 877(use-package ace-jump-mode
780 :bind ("C-." . ace-jump-mode)) 878 :bind ("C-." . ace-jump-mode))
879@end group
781@end lisp 880@end lisp
782 881
882@noindent
783This does two things: first, it creates an autoload for the 883This does two things: first, it creates an autoload for the
784@code{ace-jump-mode} command and defers loading of the 884@code{ace-jump-mode} command and defers loading of the
785@code{ace-jump-mode} package until you actually use it. Second, it 885@code{ace-jump-mode} package until you actually use it. Second, it
@@ -790,73 +890,100 @@ binds the key @code{C-.} to that command globally.
790Here is an example of using @code{:bind} with a list of conses: 890Here is an example of using @code{:bind} with a list of conses:
791 891
792@lisp 892@lisp
893@group
793(use-package hi-lock 894(use-package hi-lock
794 :bind (("M-o l" . highlight-lines-matching-regexp) 895 :bind (("M-o l" . highlight-lines-matching-regexp)
795 ("M-o r" . highlight-regexp) 896 ("M-o r" . highlight-regexp)
796 ("M-o w" . highlight-phrase))) 897 ("M-o w" . highlight-phrase)))
898@end group
797@end lisp 899@end lisp
798 900
901@noindent
902This binds the three key sequences to the corresponding commands.
903
799@subheading Using special keys 904@subheading Using special keys
905@cindex binding function keys with @code{:bind}
906@cindex @code{:bind}, and function keys
800 907
908@c FIXME: TAB vs [tab] -- is letter-case important? In general, these
909@c are two different keys: one is an ASCII character, the other a
910@c function key on GUI frames.
801Inside key strings, special keys like @kbd{TAB} or @kbd{F1}--@kbd{F12} 911Inside key strings, special keys like @kbd{TAB} or @kbd{F1}--@kbd{F12}
802have to be written inside angle brackets, e.g. @code{"C-<up>"}. 912have to be written inside angle brackets, e.g., @code{"C-<up>"}.
913@c FIXME: ``Some combinations''? which ones?
803Standalone special keys (and some combinations) can be written in 914Standalone special keys (and some combinations) can be written in
804square brackets, e.g.@ @code{[tab]} instead of @code{"<tab>"}. 915square brackets, e.g.@ @code{[tab]} instead of @code{"<tab>"}.
805 916
806Examples: 917Examples:
807 918
808@lisp 919@lisp
920@group
809(use-package helm 921(use-package helm
810 :bind (("M-x" . helm-M-x) 922 :bind (("M-x" . helm-M-x)
811 ("M-<f5>" . helm-find-files) 923 ("M-<f5>" . helm-find-files)
812 ([f10] . helm-buffers-list) 924 ([f10] . helm-buffers-list)
813 ([S-f10] . helm-recentf))) 925 ([S-f10] . helm-recentf)))
926@end group
814@end lisp 927@end lisp
815 928
816@subheading Remapping commands 929@subheading Remapping commands
930@cindex remapping commands with @code{:bind}
931@cindex @code{:bind}, and remapping of commands
817 932
818Remapping commands with @code{:bind} and @code{bind-key} works as 933Remapping of commands with @code{:bind} and @code{bind-key} works as
819expected, because when the binding is a vector, it is passed straight 934expected, because when the binding is a vector, it is passed straight
820to @code{define-key}. @xref{Remapping Commands,,, elisp, GNU Emacs 935to @code{define-key}. @xref{Remapping Commands,,, elisp, GNU Emacs
821Lisp Reference Manual}) for more information about command remapping. 936Lisp Reference Manual}), for more information about command remapping.
822For example, the following declaration will rebind 937For example, the following declaration will rebind
823@code{fill-paragraph} (bound to @kbd{M-q} by default) to 938@code{fill-paragraph} (bound to @kbd{M-q} by default) to
824@code{unfill-toggle}: 939@code{unfill-toggle}:
825 940
826@lisp 941@lisp
942@group
827(use-package unfill 943(use-package unfill
828 :bind ([remap fill-paragraph] . unfill-toggle)) 944 :bind ([remap fill-paragraph] . unfill-toggle))
945@end group
829@end lisp 946@end lisp
830 947
948@c FIXME: Should the below be an Appendix?
831@subheading What @code{:bind} does behind the scenes 949@subheading What @code{:bind} does behind the scenes
950@cindex @code{:bind}, internals
832 951
833To understand what @code{:bind} does behind the scenes, it might be 952To understand what @code{:bind} does behind the scenes, it might be
834useful to consider an example: 953useful to consider an example:
835 954
836@lisp 955@lisp
956@group
837(use-package ace-jump-mode 957(use-package ace-jump-mode
838 :bind ("C-." . ace-jump-mode)) 958 :bind ("C-." . ace-jump-mode))
959@end group
839@end lisp 960@end lisp
840 961
962@noindent
841This could be expressed in a much more verbose way with the 963This could be expressed in a much more verbose way with the
842@code{:commands} and @code{:init} keywords. 964@code{:commands} and @code{:init} keywords:
843 965
844@lisp 966@lisp
967@group
845(use-package ace-jump-mode 968(use-package ace-jump-mode
846 :commands ace-jump-mode 969 :commands ace-jump-mode
847 :init 970 :init
848 (bind-key "C-." 'ace-jump-mode)) 971 (bind-key "C-." 'ace-jump-mode))
972@end group
849@end lisp 973@end lisp
850 974
975@noindent
851Without using even the @code{:commands} keyword, we could also write 976Without using even the @code{:commands} keyword, we could also write
852the above like so: 977the above like so:
853 978
854@lisp 979@lisp
980@group
855(use-package ace-jump-mode 981(use-package ace-jump-mode
856 :defer t 982 :defer t
857 :init 983 :init
858 (autoload 'ace-jump-mode "ace-jump-mode" nil t) 984 (autoload 'ace-jump-mode "ace-jump-mode" nil t)
859 (bind-key "C-." 'ace-jump-mode)) 985 (bind-key "C-." 'ace-jump-mode))
986@end group
860@end lisp 987@end lisp
861 988
862Although these three forms are all equivalent, the first form is 989Although these three forms are all equivalent, the first form is
@@ -864,28 +991,33 @@ usually the best, as it will save some typing.
864 991
865@node Binding in keymaps 992@node Binding in keymaps
866@subsection Key bindings in local keymaps 993@subsection Key bindings in local keymaps
994@cindex local keybindings
867 995
868@findex :map, inside :bind 996@findex :map@r{, inside} :bind
869Slightly different from binding a key to a keymap, is binding a key 997Slightly different from binding a key to a keymap, is binding a key
870@emph{within} a local keymap that only exists after the package is 998@emph{within} a local keymap that only exists after the package is
871loaded. @code{use-package} supports this with a @code{:map} modifier, 999loaded. @code{use-package} supports this with a @code{:map} modifier,
872taking the local keymap to bind to: 1000taking the local keymap to bind to:
873 1001
874@lisp 1002@lisp
1003@group
875(use-package helm 1004(use-package helm
876 :bind (:map helm-command-map 1005 :bind (:map helm-command-map
877 ("C-c h" . helm-execute-persistent-action))) 1006 ("C-c h" . helm-execute-persistent-action)))
1007@end group
878@end lisp 1008@end lisp
879 1009
880The effect of this statement is to wait until @code{helm} has loaded, 1010@noindent
881and then to bind the key @code{C-c h} to 1011The effect of this is to wait until @code{helm} has loaded, and then
1012to bind the key sequence @kbd{C-c h} to
882@code{helm-execute-persistent-action} within Helm's local keymap, 1013@code{helm-execute-persistent-action} within Helm's local keymap,
883@code{helm-command-map}. 1014@code{helm-command-map}.
884 1015
885Multiple uses of @code{:map} may be specified. Any binding occurring 1016Multiple uses of @code{:map} may be specified. Any binding occurring
886before the first use of @code{:map} are applied to the global keymap: 1017before the first use of @code{:map} are applied to the global keymap:
887 1018
888@lisp 1019@lisp
1020@group
889(use-package term 1021(use-package term
890 :bind (("C-c t" . term) 1022 :bind (("C-c t" . term)
891 :map term-mode-map 1023 :map term-mode-map
@@ -895,21 +1027,23 @@ before the first use of @code{:map} are applied to the global keymap:
895 ("M-o" . other-window) 1027 ("M-o" . other-window)
896 ("M-p" . term-send-up) 1028 ("M-p" . term-send-up)
897 ("M-n" . term-send-down))) 1029 ("M-n" . term-send-down)))
1030@end group
898@end lisp 1031@end lisp
899 1032
900@node Binding to a keymap 1033@node Binding to a keymap
901@subsection Binding to keymaps 1034@subsection Binding to keymaps
1035@cindex binding keys to keymaps
902 1036
903@findex :bind-keymap, inside :bind 1037@findex :bind-keymap
904Normally @code{:bind} expects that commands are functions that will be 1038Normally @code{:bind} expects that commands are functions that will be
905autoloaded from the given package. However, this does not work if one of 1039autoloaded from the given package. However, this does not work if one of
906those commands is actually a keymap, since keymaps are not functions, 1040those commands is actually a keymap, since keymaps are not functions,
907and cannot be autoloaded using the built-in @code{autoload} function. 1041and cannot be autoloaded using the built-in @code{autoload} function.
908 1042
909To handle this case, @code{use-package} offers a special, limited 1043To handle this case, @code{use-package} offers a special, limited
910variant of @code{:bind} called @code{:bind-keymap}. The only difference 1044variant of @code{:bind} called @code{:bind-keymap}. The only difference
911is that the ``commands'' bound to by @code{:bind-keymap} must be keymaps 1045is that the ``commands'' bound to by @code{:bind-keymap} must be keymaps
912defined in the package, rather than command functions. This is handled 1046defined in the package, rather than interactive functions. This is handled
913behind the scenes by generating custom code that loads the package 1047behind the scenes by generating custom code that loads the package
914containing the keymap, and then re-executes your keypress after the 1048containing the keymap, and then re-executes your keypress after the
915first load, to reinterpret that keypress as a prefix key. 1049first load, to reinterpret that keypress as a prefix key.
@@ -917,31 +1051,35 @@ first load, to reinterpret that keypress as a prefix key.
917For example: 1051For example:
918 1052
919@lisp 1053@lisp
1054@group
920(use-package foo 1055(use-package foo
921 :bind-keymap ("C-c p" . foo-command-map)) 1056 :bind-keymap ("C-c p" . foo-command-map))
1057@end group
922@end lisp 1058@end lisp
923 1059
924@node Binding to repeat-maps 1060@node Binding to repeat-maps
925@subsection Binding to repeat-maps 1061@subsection Binding to repeat-maps
1062@cindex keybinding for @code{repeat-mode} keymaps
926 1063
927@findex :repeat-map, inside :bind 1064@findex :repeat-map@r{, inside} :bind
928@cindex repeat-mode and use-package, using 1065@cindex @code{repeat-mode} and use-package, using
929A special case of binding within a local keymap is when that keymap is 1066A special case of binding within a local keymap is when that keymap is
930used by @code{repeat-mode} @pxref{Repeating,,, emacs, GNU Emacs 1067used by @code{repeat-mode} (@pxref{Repeating,,, emacs, GNU Emacs
931Manual}. These keymaps are usually defined specifically for 1068Manual}). These keymaps are usually defined specifically for
932this. Using the @code{:repeat-map} keyword, and passing it a name for 1069this. Using the @code{:repeat-map} keyword, and passing it a name for
933the map it defines, will bind all following keys inside that map, and 1070the map it defines, will bind all the following keys inside that map, and
934(by default) set the @code{repeat-map} property of each bound command 1071(by default) set the @code{repeat-map} property of each bound command
935to that map. 1072to that map.
936 1073
937The following example creates a keymap called 1074The following example creates a keymap called
938@code{git-gutter+-repeat-map}, makes four bindings in it as above, 1075@code{git-gutter+-repeat-map}, makes four bindings in it, then sets
939then sets the @code{repeat-map} property of each bound command 1076the @code{repeat-map} property of each bound command
940(@code{git-gutter+-next-hunk} @code{git-gutter+-previous-hunk}, 1077(@code{git-gutter+-next-hunk}, @code{git-gutter+-previous-hunk},
941@code{git-gutter+-stage-hunks} and @code{git-gutter+-revert-hunk}) to 1078@code{git-gutter+-stage-hunks}, and @code{git-gutter+-revert-hunk}) to
942that keymap. 1079that keymap.
943 1080
944@lisp 1081@lisp
1082@group
945(use-package git-gutter+ 1083(use-package git-gutter+
946 :bind 1084 :bind
947 (:repeat-map git-gutter+-repeat-map 1085 (:repeat-map git-gutter+-repeat-map
@@ -949,16 +1087,19 @@ that keymap.
949 ("p" . git-gutter+-previous-hunk) 1087 ("p" . git-gutter+-previous-hunk)
950 ("s" . git-gutter+-stage-hunks) 1088 ("s" . git-gutter+-stage-hunks)
951 ("r" . git-gutter+-revert-hunk))) 1089 ("r" . git-gutter+-revert-hunk)))
1090@end group
952@end lisp 1091@end lisp
953 1092
954@findex :exit, inside :repeat-map and :bind 1093@findex :exit@r{, inside} :repeat-map@r{ and} :bind
1094@cindex binding commands used at end of repeat series
955Specifying @code{:exit} inside the scope of @code{:repeat-map} will 1095Specifying @code{:exit} inside the scope of @code{:repeat-map} will
956prevent the @code{repeat-map} property being set, so that the command 1096prevent the @code{repeat-map} property from being set, so that the command
957can be used from within the repeat map, but after it using it the repeat 1097can be used from within the repeat map, but after using it the repeat
958map will no longer be available. This is useful for commands often used 1098map will no longer be available. This is useful for commands often used
959at the end of a series of repeated commands: 1099at the end of a series of repeated commands. Example:
960 1100
961@lisp 1101@lisp
1102@group
962(use-package git-gutter+ 1103(use-package git-gutter+
963 :bind 1104 :bind
964 (:repeat-map my/git-gutter+-repeat-map 1105 (:repeat-map my/git-gutter+-repeat-map
@@ -970,14 +1111,16 @@ at the end of a series of repeated commands:
970 ("c" . magit-commit-create) 1111 ("c" . magit-commit-create)
971 ("C" . magit-commit) 1112 ("C" . magit-commit)
972 ("b" . magit-blame))) 1113 ("b" . magit-blame)))
1114@end group
973@end lisp 1115@end lisp
974 1116
975@findex :continue, inside :repeat-map and :bind 1117@findex :continue@r{, inside} :repeat-map@r{ and} :bind
976Specifying @code{:continue} @emph{forces} setting the 1118Specifying @code{:continue} @emph{forces} setting the
977@code{repeat-map} property (just like @emph{not} specifying 1119@code{repeat-map} property (just like @emph{not} specifying
978@code{:exit}), so the above snippet is equivalent to: 1120@code{:exit}), so the above snippet is equivalent to:
979 1121
980@lisp 1122@lisp
1123@group
981(use-package git-gutter+ 1124(use-package git-gutter+
982 :bind 1125 :bind
983 (:repeat-map my/git-gutter+-repeat-map 1126 (:repeat-map my/git-gutter+-repeat-map
@@ -990,10 +1133,12 @@ Specifying @code{:continue} @emph{forces} setting the
990 ("p" . git-gutter+-previous-hunk) 1133 ("p" . git-gutter+-previous-hunk)
991 ("s" . git-gutter+-stage-hunks) 1134 ("s" . git-gutter+-stage-hunks)
992 ("r" . git-gutter+-revert-hunk))) 1135 ("r" . git-gutter+-revert-hunk)))
1136@end group
993@end lisp 1137@end lisp
994 1138
995@node Displaying keybindings 1139@node Displaying keybindings
996@subsection Displaying personal keybinding 1140@subsection Displaying personal keybindings
1141@cindex display your keybindings
997 1142
998@findex describe-personal-keybindings 1143@findex describe-personal-keybindings
999The @code{:bind} keyword uses the @code{bind-keys} macro from the 1144The @code{:bind} keyword uses the @code{bind-keys} macro from the
@@ -1001,7 +1146,7 @@ The @code{:bind} keyword uses the @code{bind-keys} macro from the
1001all keybindings you make, so that you can display them separately from 1146all keybindings you make, so that you can display them separately from
1002the default keybindings. 1147the default keybindings.
1003 1148
1004Use @w{@code{M-x describe-personal-keybindings}} to see all 1149Use @w{@kbd{M-x describe-personal-keybindings}} to see all
1005keybindings you've set using either the @code{:bind} keyword or the 1150keybindings you've set using either the @code{:bind} keyword or the
1006@code{bind-keys} macro. 1151@code{bind-keys} macro.
1007 1152
@@ -1010,7 +1155,8 @@ keybindings you've set using either the @code{:bind} keyword or the
1010 1155
1011@cindex hooks 1156@cindex hooks
1012@findex :hook 1157@findex :hook
1013The @code{:hook} keyword allows adding functions onto hooks. It takes 1158The @code{:hook} keyword allows adding functions to hooks. It takes
1159@c FIXME: The actual forms accepted by :hook are different, see below!
1014one argument of the form @var{hooks}, specifying one or more functions 1160one argument of the form @var{hooks}, specifying one or more functions
1015to add to one or more hooks. For the purposes of @code{:hook}, the 1161to add to one or more hooks. For the purposes of @code{:hook}, the
1016name of hook variables should always exclude the @samp{-hook} suffix. 1162name of hook variables should always exclude the @samp{-hook} suffix.
@@ -1021,17 +1167,21 @@ that sets up autoloads for @code{company-mode} from the @samp{company}
1021package, and adds @samp{company-mode} to @code{prog-mode-hook}: 1167package, and adds @samp{company-mode} to @code{prog-mode-hook}:
1022 1168
1023@lisp 1169@lisp
1170@group
1024(use-package company 1171(use-package company
1025 :commands company-mode 1172 :commands company-mode
1026 :init 1173 :init
1027 (add-hook 'prog-mode-hook #'company-mode)) 1174 (add-hook 'prog-mode-hook #'company-mode))
1175@end group
1028@end lisp 1176@end lisp
1029 1177
1030Using @code{:hook}, this can be simplified to: 1178Using @code{:hook}, this can be simplified to:
1031 1179
1032@lisp 1180@lisp
1181@group
1033(use-package company 1182(use-package company
1034 :hook (prog-mode . company-mode)) 1183 :hook (prog-mode . company-mode))
1184@end group
1035@end lisp 1185@end lisp
1036 1186
1037Here, @code{:hook} will automatically set up autoloads for the 1187Here, @code{:hook} will automatically set up autoloads for the
@@ -1044,8 +1194,10 @@ function you want to add is the same as the package name with
1044simplify the above to the equivalent: 1194simplify the above to the equivalent:
1045 1195
1046@lisp 1196@lisp
1197@group
1047(use-package company 1198(use-package company
1048 :hook prog-mode) 1199 :hook prog-mode)
1200@end group
1049@end lisp 1201@end lisp
1050 1202
1051@cindex multiple hooks 1203@cindex multiple hooks
@@ -1053,21 +1205,29 @@ You can also provide a list of hooks. When multiple hooks should be
1053applied, the following examples are all equivalent: 1205applied, the following examples are all equivalent:
1054 1206
1055@lisp 1207@lisp
1208@group
1056(use-package company 1209(use-package company
1057 :hook (prog-mode text-mode)) 1210 :hook (prog-mode text-mode))
1211@end group
1058 1212
1213@group
1059(use-package company 1214(use-package company
1060 :hook ((prog-mode text-mode) . company-mode)) 1215 :hook ((prog-mode text-mode) . company-mode))
1216@end group
1061 1217
1218@group
1062(use-package company 1219(use-package company
1063 :hook ((prog-mode . company-mode) 1220 :hook ((prog-mode . company-mode)
1064 (text-mode . company-mode))) 1221 (text-mode . company-mode)))
1222@end group
1065 1223
1224@group
1066(use-package company 1225(use-package company
1067 :commands company-mode 1226 :commands company-mode
1068 :init 1227 :init
1069 (add-hook 'prog-mode-hook #'company-mode) 1228 (add-hook 'prog-mode-hook #'company-mode)
1070 (add-hook 'text-mode-hook #'company-mode)) 1229 (add-hook 'text-mode-hook #'company-mode))
1230@end group
1071@end lisp 1231@end lisp
1072 1232
1073One common mistake when using @code{:hook} is to forget to omit the 1233One common mistake when using @code{:hook} is to forget to omit the
@@ -1076,9 +1236,11 @@ automatically. Therefore, the following will not work, as it attempts
1076to add a function to non-existent @code{prog-mode-hook-hook}: 1236to add a function to non-existent @code{prog-mode-hook-hook}:
1077 1237
1078@lisp 1238@lisp
1239@group
1079;; DOES NOT WORK 1240;; DOES NOT WORK
1080(use-package ace-jump-mode 1241(use-package ace-jump-mode
1081 :hook (prog-mode-hook . ace-jump-mode)) 1242 :hook (prog-mode-hook . ace-jump-mode))
1243@end group
1082@end lisp 1244@end lisp
1083 1245
1084@vindex use-package-hook-name-suffix 1246@vindex use-package-hook-name-suffix
@@ -1095,12 +1257,16 @@ implied by @code{:hook}.
1095 1257
1096@node Modes and interpreters 1258@node Modes and interpreters
1097@section Modes and interpreters 1259@section Modes and interpreters
1260@cindex @code{auto-mode-alist} customization
1261@cindex @code{interpreter-mode-alist} customization
1262@cindex setting up major modes
1098 1263
1099@findex :mode 1264@findex :mode
1100@findex :interpreter 1265@findex :interpreter
1101Similar to @code{:bind}, you can use @code{:mode} and 1266Similar to @code{:bind}, you can use @code{:mode} and
1102@code{:interpreter} to establish a deferred binding within the 1267@code{:interpreter} to establish a deferred binding within the
1103@code{auto-mode-alist} and @code{interpreter-mode-alist} variables. 1268@code{auto-mode-alist} and @code{interpreter-mode-alist} variables
1269(@pxref{Auto Major Mode,,, elisp, GNU Emacs Lisp Reference Manual}).
1104The specifier to either keyword can be a cons cell, a list of cons 1270The specifier to either keyword can be a cons cell, a list of cons
1105cells, or a string or regexp. 1271cells, or a string or regexp.
1106 1272
@@ -1112,51 +1278,63 @@ first line of the file (known as the ``shebang'') matches the string
1112@code{"ruby"}: 1278@code{"ruby"}:
1113 1279
1114@lisp 1280@lisp
1281@group
1115(use-package ruby-mode 1282(use-package ruby-mode
1116 :mode "\\.rb\\'" 1283 :mode "\\.rb\\'"
1117 :interpreter "ruby") 1284 :interpreter "ruby")
1285@end group
1118@end lisp 1286@end lisp
1119 1287
1120The default @code{python-mode} configuration can be reproduced using 1288The default @code{python-mode} configuration can be reproduced using
1121the below declaration. Note that the package that should be loaded 1289the declaration below. Note that the package that should be loaded
1122differs from the mode name in this case, so we must use a cons: 1290differs from the mode name in this case, so we must use a cons:
1123 1291
1124@lisp 1292@lisp
1293@group
1125;; The package is "python" but the mode is "python-mode": 1294;; The package is "python" but the mode is "python-mode":
1126(use-package python 1295(use-package python
1127 :mode ("\\.py\\'" . python-mode) 1296 :mode ("\\.py\\'" . python-mode)
1128 :interpreter ("python" . python-mode)) 1297 :interpreter ("python" . python-mode))
1298@end group
1129@end lisp 1299@end lisp
1130 1300
1131Both the @code{:mode} and @code{:interpreter} keywords also accept a 1301Both the @code{:mode} and @code{:interpreter} keywords also accept a
1132list of regexps: 1302list of regexps:
1133 1303
1134@lisp 1304@lisp
1305@group
1135(use-package foo 1306(use-package foo
1136 ;; Equivalent to "\\(ba[rz]\\)\\'": 1307 ;; Equivalent to "\\(ba[rz]\\)\\'":
1137 :mode ("\\.bar\\'" "\\.baz\\'") 1308 :mode ("\\.bar\\'" "\\.baz\\'")
1138 ;; Equivalent to "\\(foo[ab]\\)": 1309 ;; Equivalent to "\\(foo[ab]\\)":
1139 :interpreter ("fooa" "foob")) 1310 :interpreter ("fooa" "foob"))
1311@end group
1140@end lisp 1312@end lisp
1141 1313
1142@node Magic handlers 1314@node Magic handlers
1143@section Magic handlers 1315@section Magic handlers
1316@cindex @code{magic-mode-alist} customization
1144 1317
1145@findex :magic 1318@findex :magic
1146@findex :magic-fallback 1319@findex :magic-fallback
1147Similar to @code{:mode} and @code{:interpreter}, you can also use 1320Similar to @code{:mode} and @code{:interpreter}, you can also use
1148@code{:magic} and @code{:magic-fallback} to cause certain function to 1321@code{:magic} and @code{:magic-fallback} to cause certain function to
1149be run if the beginning of a file matches a given regular expression. 1322be run if the beginning of a file matches a given regular expression,
1150The difference between @code{:magic} and @code{:magic-fallback}, is 1323as if these regular expressions were added to @code{magic-mode-alist}
1151that the latter has a lower priority than @code{:mode}. 1324and @code{magic-fallback-mode-alist} (@pxref{Auto Major Mode,,, elisp,
1325GNU Emacs Lisp Reference Manual}). The difference between
1326@code{:magic} and @code{:magic-fallback}, is that the latter has a
1327lower priority than @code{:mode}.
1152 1328
1153Here is an example: 1329Here is an example:
1154 1330
1155@lisp 1331@lisp
1332@group
1156(use-package pdf-tools 1333(use-package pdf-tools
1157 :magic ("%PDF" . pdf-view-mode) 1334 :magic ("%PDF" . pdf-view-mode)
1158 :config 1335 :config
1159 (pdf-tools-install :no-query)) 1336 (pdf-tools-install :no-query))
1337@end group
1160@end lisp 1338@end lisp
1161 1339
1162This registers an autoloaded command for @code{pdf-view-mode}, defers 1340This registers an autoloaded command for @code{pdf-view-mode}, defers
@@ -1165,53 +1343,67 @@ beginning of a buffer matches the string @code{"%PDF"}.
1165 1343
1166@node User options 1344@node User options
1167@section User options 1345@section User options
1346@cindex customization of variables
1347@cindex variable customizations
1348@cindex user options, setting
1168 1349
1169@findex :custom 1350@findex :custom
1170In Emacs, you normally set customizable variables (user options) using 1351In Emacs, you normally set customizable variables (user options) using
1171the @code{M-x customize} interface (@pxref{Easy Customization,,, 1352the @code{M-x customize} interface (@pxref{Easy Customization,,,
1172emacs, GNU Emacs Manual}). We recommended this method for most users. 1353emacs, GNU Emacs Manual}). We recommend this method for most users.
1173However, it is also possible to set them in your @code{use-package} 1354However, it is also possible to set them in your @code{use-package}
1174declarations by using the @code{:custom} keyword. 1355declarations by using the @code{:custom} keyword.
1175 1356
1176@lisp 1357@lisp
1358@group
1177(use-package comint 1359(use-package comint
1178 :defer t 1360 :defer t
1179 :custom 1361 :custom
1180 (comint-buffer-maximum-size 20000 "Increase comint buffer size.") 1362 (comint-buffer-maximum-size 20000 "Increase comint buffer size.")
1181 (comint-prompt-read-only t "Make the prompt read only.")) 1363 (comint-prompt-read-only t "Make the prompt read only."))
1364@end group
1182@end lisp 1365@end lisp
1183 1366
1184This is better than using @code{setq} in a @code{:config} block, as 1367This is better than using @code{setq} in a @code{:config} block, as
1185customizable variables might have some code associated with it that 1368customizable variables might have some code associated with it that
1186Emacs will execute when you assign values to them. In Emacs 29, there 1369Emacs will execute when you assign values to them. (In Emacs 29 and
1187is also the new @code{setopt} macro that does this for you. 1370later, there is also the new @code{setopt} macro that does this for
1188 1371you.)
1189Note that the values customized using this keyword are @emph{not} 1372
1190saved in the standard Emacs @code{custom-file}. You should therefore 1373Note that the values customized using @code{:custom} are @emph{not}
1191set each user option using either the @code{:custom} keyword @emph{or} 1374saved in the standard Emacs @code{custom-file} (@pxref{Saving
1192@w{@code{M-x customize-option}}, which will save customized values in 1375Customizations,,, emacs, GNU Emacs Manual}). You should therefore set
1193the Emacs @code{custom-file}. Do not use both for the same variable, 1376each user option using either the @code{:custom} keyword @emph{or}
1194as this risk having conflicting values in your use-package declaration 1377@w{@kbd{M-x customize-option}} command; the latter will save
1195and your @code{custom-file}. This can lead to problems that are both 1378customized values in the Emacs @code{custom-file}. Do not use both
1196tricky and tedious to debug. 1379for the same variable, as this risks having conflicting values in your
1380use-package declaration and your @code{custom-file}, which can lead to
1381problems that are both tricky and tedious to debug.
1197 1382
1198@node Faces 1383@node Faces
1199@section Faces 1384@section Faces
1385@cindex faces, setting
1386@cindex customization of faces
1200 1387
1201@findex :custom-face 1388@findex :custom-face
1202The @code{:custom-face} keyword allows customization of package custom 1389The @code{:custom-face} keyword allows customization of package's
1203faces. 1390faces. Example:
1204 1391
1205@lisp 1392@lisp
1393@group
1206(use-package eruby-mode 1394(use-package eruby-mode
1207 :custom-face 1395 :custom-face
1208 (eruby-standard-face ((t (:slant italic))))) 1396 (eruby-standard-face ((t (:slant italic)))))
1397@end group
1209 1398
1399@group
1210(use-package example 1400(use-package example
1211 :custom-face 1401 :custom-face
1212 (example-1-face ((t (:foreground "LightPink")))) 1402 (example-1-face ((t (:foreground "LightPink"))))
1213 (example-2-face ((t (:foreground "LightGreen"))) face-defspec-spec)) 1403 (example-2-face ((t (:foreground "LightGreen"))) face-defspec-spec))
1404@end group
1214 1405
1406@group
1215(use-package zenburn-theme 1407(use-package zenburn-theme
1216 :preface 1408 :preface
1217 (setq my/zenburn-colors-alist 1409 (setq my/zenburn-colors-alist
@@ -1220,17 +1412,19 @@ faces.
1220 (region ((t (:background ,(alist-get my/zenburn-colors-alist 'cyan))))) 1412 (region ((t (:background ,(alist-get my/zenburn-colors-alist 'cyan)))))
1221 :config 1413 :config
1222 (load-theme 'zenburn t)) 1414 (load-theme 'zenburn t))
1415@end group
1223@end lisp 1416@end lisp
1224 1417
1225@node Hiding minor modes 1418@node Hiding minor modes
1226@section Hiding minor modes with diminish and delight 1419@section Hiding minor modes with diminish and delight
1420@cindex hiding minor modes
1227 1421
1228@code{use-package} supports the diminish and delight packages, both of 1422@code{use-package} supports the @file{diminish} and @file{delight}
1229which make it possible remove or change minor mode strings in your 1423packages, both of which make it possible to remove or change minor mode
1230mode-line. Which one to use is up to you, but you should normally 1424strings in your mode-line. Which one to use is up to you, but you
1231only use one or the other -- never both.@footnote{When in doubt, you 1425should normally only use one or the other -- never both.@footnote{When
1232might as well use diminish.} To use either of them, you must first 1426in doubt, you might as well use @file{diminish}.} To use either of them, you
1233install the corresponding package from @acronym{GNU ELPA}. 1427must first install the corresponding package from @acronym{GNU} @acronym{ELPA}.
1234 1428
1235@menu 1429@menu
1236* Diminish:: Hiding minor modes with Diminish. 1430* Diminish:: Hiding minor modes with Diminish.
@@ -1241,61 +1435,72 @@ install the corresponding package from @acronym{GNU ELPA}.
1241@subsection Diminish 1435@subsection Diminish
1242 1436
1243@findex :diminish 1437@findex :diminish
1244When diminish@footnote{The diminish package is installable from 1438When diminish@footnote{The @file{diminish} package is installable from
1245@acronym{GNU ELPA}.} is installed, you can use the @code{:diminish} 1439@acronym{GNU} @acronym{ELPA}.} is installed, you can use the @code{:diminish}
1246keyword. If diminish is not installed, the @code{:diminish} keyword 1440keyword. If @file{diminish} is not installed, the @code{:diminish} keyword
1247does nothing. 1441does nothing.
1248 1442
1249First, add the following declaration to the beginning of your init 1443First, add the following declaration to the beginning of your init
1250file. The optional @w{@code{:ensure t}} makes sure the package is 1444file.
1251installed if it isn't already (@pxref{Installing packages}).
1252 1445
1253@lisp 1446@lisp
1254(use-package diminish :ensure t) 1447(use-package diminish :ensure t)
1255@end lisp 1448@end lisp
1256 1449
1257The @code{:diminish} keyword takes either a minor mode symbol, a cons 1450@noindent
1258of the symbol and its replacement string, or just a replacement 1451The optional @w{@code{:ensure t}} makes sure the package is installed
1259string, in which case the minor mode symbol is guessed to be the 1452if it isn't already (@pxref{Installing packages}).
1260package name with @samp{-mode} appended at the end: 1453
1454The @code{:diminish} keyword takes as its argument either a minor mode
1455symbol, a cons of the symbol and its replacement string, or just a
1456replacement string, in which case the minor mode symbol is guessed to
1457be the package name with @samp{-mode} appended at the end:
1261 1458
1262@lisp 1459@lisp
1460@group
1263(use-package abbrev 1461(use-package abbrev
1264 :diminish abbrev-mode 1462 :diminish abbrev-mode
1265 :config 1463 :config
1266 (if (file-exists-p abbrev-file-name) 1464 (if (file-exists-p abbrev-file-name)
1267 (quietly-read-abbrev-file))) 1465 (quietly-read-abbrev-file)))
1466@end group
1268@end lisp 1467@end lisp
1269 1468
1270@node Delight 1469@node Delight
1271@subsection Delight 1470@subsection Delight
1272 1471
1273@findex :delight 1472@findex :delight
1274When delight@footnote{The @samp{delight} package is installable from 1473When @file{delight}@footnote{The @file{delight} package is installable from
1275GNU ELPA.} is installed, you can use the @code{:delight} keyword. If 1474@acronym{GNU} @acronym{ELPA}.} is installed, you can use the
1276delight is not installed, the @code{:delight} keyword does nothing. 1475@code{:delight} keyword. If @file{delight} is not installed, the
1476@code{:delight} keyword does nothing.
1277 1477
1278First, add the following declaration to the beginning of your init 1478First, add the following declaration to the beginning of your init
1279file. The optional @w{@code{:ensure t}} makes sure the package is 1479file.
1280installed if it isn't already (@pxref{Installing packages}).
1281 1480
1282@lisp 1481@lisp
1283(use-package delight :ensure t) 1482(use-package delight :ensure t)
1284@end lisp 1483@end lisp
1285 1484
1286The @code{:delight} keyword takes a minor mode symbol, a replacement 1485@noindent
1287string, or quoted mode line data (in which case the minor mode symbol 1486The optional @w{@code{:ensure t}} makes sure the package is installed
1288is assumed to be the package name with @samp{-mode} appended at the 1487if it isn't already (@pxref{Installing packages}).
1289end), both of these, or several lists of both. @xref{Mode Line 1488
1290Data,,, elisp, GNU Emacs Lisp Reference Manual}. If no arguments are 1489The @code{:delight} keyword takes as its argument a minor mode symbol,
1291provided, the default mode name is hidden completely. 1490a replacement string, or quoted mode line data (in which case the
1491minor mode symbol is assumed to be the package name with @samp{-mode}
1492appended at the end), both of these, or several lists of both.
1493@xref{Mode Line Data,,, elisp, GNU Emacs Lisp Reference Manual}. If
1494no arguments are provided, the default mode name is hidden completely.
1292 1495
1293For example, the following hides everything for the @samp{foo-mode} 1496For example, the following hides everything for the @samp{foo-mode}
1294minor mode in the @samp{foo} package: 1497minor mode in the @samp{foo} package:
1295 1498
1296@lisp 1499@lisp
1500@group
1297(use-package foo 1501(use-package foo
1298 :delight) 1502 :delight)
1503@end group
1299@end lisp 1504@end lisp
1300 1505
1301If the mode name doesn't match the package name with @samp{-mode} 1506If the mode name doesn't match the package name with @samp{-mode}
@@ -1303,28 +1508,35 @@ appended, provide a symbol instead. For example, the following hides
1303@code{auto-revert-mode} from the mode line: 1508@code{auto-revert-mode} from the mode line:
1304 1509
1305@lisp 1510@lisp
1511@group
1306;; Don't show anything for auto-revert-mode, which doesn't match 1512;; Don't show anything for auto-revert-mode, which doesn't match
1307;; its package name. 1513;; its package name.
1308(use-package autorevert 1514(use-package autorevert
1309 :delight auto-revert-mode) 1515 :delight auto-revert-mode)
1516@end group
1310@end lisp 1517@end lisp
1311 1518
1312You can also run arbitrary Lisp code. For example, to replace 1519You can also use arbitrary Lisp code as argument of @code{:delight}.
1313@samp{foo-mode} with the value of the current buffer: 1520For example, to replace @samp{foo-mode} with the value of the current
1521buffer:
1314 1522
1315@lisp 1523@lisp
1524@group
1316(use-package foo 1525(use-package foo
1317 :delight '(:eval buffer-file-name)) 1526 :delight '(:eval buffer-file-name))
1527@end group
1318@end lisp 1528@end lisp
1319 1529
1320Here is an example of hiding several built-in minor modes: 1530Here is an example of hiding several built-in minor modes:
1321 1531
1322@lisp 1532@lisp
1533@group
1323;; Completely hide visual-line-mode and change auto-fill-mode to " AF". 1534;; Completely hide visual-line-mode and change auto-fill-mode to " AF".
1324(use-package emacs 1535(use-package emacs
1325 :delight 1536 :delight
1326 (auto-fill-function " AF") 1537 (auto-fill-function " AF")
1327 (visual-line-mode)) 1538 (visual-line-mode))
1539@end group
1328@end lisp 1540@end lisp
1329 1541
1330@c ---------------------------------------------------------------------------- 1542@c ----------------------------------------------------------------------------
@@ -1334,7 +1546,7 @@ Here is an example of hiding several built-in minor modes:
1334The standard Emacs package manager is documented in the Emacs manual 1546The standard Emacs package manager is documented in the Emacs manual
1335(@pxref{Package Installation,,, emacs, GNU Emacs Manual}). The 1547(@pxref{Package Installation,,, emacs, GNU Emacs Manual}). The
1336@code{use-package} macro provides the @code{:ensure} and @code{:pin} 1548@code{use-package} macro provides the @code{:ensure} and @code{:pin}
1337keywords, that interface with that package manager to automatically 1549keywords that interface with that package manager to automatically
1338install packages. This is particularly useful if you use your init 1550install packages. This is particularly useful if you use your init
1339file on more than one system. 1551file on more than one system.
1340 1552
@@ -1346,6 +1558,7 @@ file on more than one system.
1346 1558
1347@node Install package 1559@node Install package
1348@section Installing package 1560@section Installing package
1561@cindex installing packages from archives
1349 1562
1350@findex :ensure 1563@findex :ensure
1351The @code{:ensure} keyword makes use-package ask the Emacs package 1564The @code{:ensure} keyword makes use-package ask the Emacs package
@@ -1355,25 +1568,32 @@ system.
1355For example: 1568For example:
1356 1569
1357@lisp 1570@lisp
1571@group
1358(use-package magit 1572(use-package magit
1359 :ensure t) 1573 :ensure t)
1574@end group
1360@end lisp 1575@end lisp
1361 1576
1362If you need to install a different package from the one named by 1577If you need to install a different package from the one named by
1363@code{use-package}, you can use a symbol: 1578@code{use-package}, you can use a symbol:
1364 1579
1365@lisp 1580@lisp
1581@group
1366(use-package tex 1582(use-package tex
1367 :ensure auctex) 1583 :ensure auctex)
1584@end group
1368@end lisp 1585@end lisp
1369 1586
1587@vindex use-package-always-ensure
1370You can customize the user option @code{use-package-always-ensure} to 1588You can customize the user option @code{use-package-always-ensure} to
1371non-@code{nil} if you want this behavior to be global for all 1589a non-@code{nil} value if you want this behavior to be global for all
1372packages. 1590packages:
1373 1591
1374@lisp 1592@lisp
1593@group
1375(require 'use-package-ensure) 1594(require 'use-package-ensure)
1376(setq use-package-always-ensure t) 1595(setq use-package-always-ensure t)
1596@end group
1377@end lisp 1597@end lisp
1378 1598
1379@noindent 1599@noindent
@@ -1382,23 +1602,27 @@ You can override the above setting for a single package by adding
1382 1602
1383@node Pinning packages 1603@node Pinning packages
1384@section Pinning packages using @code{:pin} 1604@section Pinning packages using @code{:pin}
1605@cindex installing package from specific archive
1606@cindex pinning a package to archive
1385 1607
1386@findex :pin 1608@findex :pin
1387use-package can pin a package to a specific archive using the 1609use-package can @dfn{pin} a package to a specific archive using the
1388@code{:pin} keyword.@footnote{The @code{:pin} keyword has no effect on 1610@code{:pin} keyword.@footnote{The @code{:pin} keyword has no effect on
1389Emacs versions older than 24.4.} This allows you to mix and match 1611Emacs versions older than 24.4.} This allows you to mix and match
1390packages from different archives. The primary use-case for this is 1612packages from different archives. The primary use-case for this is
1391preferring to install packages from @acronym{GNU ELPA} or 1613preferring to install packages from @acronym{GNU} @acronym{ELPA} or
1392@acronym{NonGNU ELPA} (indicated by @code{gnu} and @code{nongnu}, 1614@acronym{NonGNU} @acronym{ELPA} (indicated by @code{gnu} and @code{nongnu},
1393respectively), while installing specific packages from third-party 1615respectively), while installing specific packages from third-party
1394archives. 1616archives.
1395 1617
1396For example: 1618For example:
1397 1619
1398@lisp 1620@lisp
1621@group
1399(use-package company 1622(use-package company
1400 :ensure t 1623 :ensure t
1401 :pin gnu) ; GNU ELPA 1624 :pin gnu) ; GNU ELPA
1625@end group
1402@end lisp 1626@end lisp
1403 1627
1404@vindex use-package-always-pin 1628@vindex use-package-always-pin
@@ -1410,6 +1634,7 @@ strongly encourage you to customize @code{use-package-always-pin} to
1410package that has been specifically marked for release by its 1634package that has been specifically marked for release by its
1411developer, and not a development snapshot. 1635developer, and not a development snapshot.
1412 1636
1637@cindex manual update of packages
1413@c FIXME: This needs clarifying. AFAIK, :ensure does not update packages. 1638@c FIXME: This needs clarifying. AFAIK, :ensure does not update packages.
1414If you want to manually keep a package updated and ignore upstream 1639If you want to manually keep a package updated and ignore upstream
1415updates, you can pin it to @samp{manual}. This will work as long as 1640updates, you can pin it to @samp{manual}. This will work as long as
@@ -1419,10 +1644,12 @@ you have not customized a repository to use that name in the
1419Example: 1644Example:
1420 1645
1421@lisp 1646@lisp
1647@group
1422(use-package org 1648(use-package org
1423 :ensure t 1649 :ensure t
1424 ;; ignore org-mode from upstream and use a manually installed version 1650 ;; ignore org-mode from upstream and use a manually installed version
1425 :pin manual) 1651 :pin manual)
1652@end group
1426@end lisp 1653@end lisp
1427 1654
1428@code{use-package} signals an error if you try to pin a package to an 1655@code{use-package} signals an error if you try to pin a package to an
@@ -1431,10 +1658,13 @@ from the special @samp{manual} archive).
1431 1658
1432@node Other package managers 1659@node Other package managers
1433@section Non-standard package managers 1660@section Non-standard package managers
1661@cindex non-standard package managers
1662@cindex package managers, other than @file{package.el}
1663@cindex installing using non-standard package managers
1434 1664
1435By default, use-package assumes that you are using the built-in 1665By default, use-package assumes that you are using the Emacs built-in
1436@code{package.el} package manager. We expect that most users will 1666@file{package.el} package manager. We expect that most users will
1437find that it is more than capable enough, even for advanced use cases. 1667find that it is capable enough, even for advanced use cases.
1438 1668
1439@vindex use-package-ensure-function 1669@vindex use-package-ensure-function
1440However, some users might prefer to use a third-party package manager 1670However, some users might prefer to use a third-party package manager
@@ -1450,12 +1680,13 @@ them directly to the developers of that package manager.
1450@c ---------------------------------------------------------------------------- 1680@c ----------------------------------------------------------------------------
1451@node Byte-compiling 1681@node Byte-compiling
1452@chapter Byte-compiling your init file 1682@chapter Byte-compiling your init file
1683@cindex byte-compiling your init file
1453 1684
1454Some users might want to byte-compile their init file to make Emacs 1685Some users might want to byte-compile their init file to make Emacs
1455startup even faster. This is not recommended in most cases, as the 1686startup faster. This is not recommended in most cases, as the
1456speed-up is often too small to be worth it, and can lead to confusion 1687speed-up is often too small to be worth it, and can lead to confusion
1457if the byte-compiled files are out-of-date. If you still want to do 1688if the byte-compiled files are out-of-date. If you still want to do
1458it, read on. 1689it, this chapter explains how to do that.
1459 1690
1460@code{use-package} always loads every library that it can while a file 1691@code{use-package} always loads every library that it can while a file
1461is being byte-compiled. This helps silence spurious warnings about 1692is being byte-compiled. This helps silence spurious warnings about
@@ -1463,23 +1694,27 @@ unknown variables and functions.
1463 1694
1464@findex :defines 1695@findex :defines
1465@findex :functions 1696@findex :functions
1697@cindex silence byte-compilation warnings
1466However, there are times when this is just not enough. For those 1698However, there are times when this is just not enough. For those
1467times, use the @code{:defines} and @code{:functions} keywords to 1699times, use the @code{:defines} and @code{:functions} keywords to
1468introduce dummy variable and function declarations solely for the sake 1700introduce dummy variable and function declarations solely for the sake
1469of silencing byte-compiler warnings. For example: 1701of silencing byte-compiler warnings. For example:
1470 1702
1471@lisp 1703@lisp
1704@group
1472(use-package texinfo 1705(use-package texinfo
1473 :defines texinfo-section-list 1706 :defines texinfo-section-list
1474 :commands texinfo-mode 1707 :commands texinfo-mode
1475 :init 1708 :init
1476 (add-to-list 'auto-mode-alist '("\\.texi$" . texinfo-mode))) 1709 (add-to-list 'auto-mode-alist '("\\.texi$" . texinfo-mode)))
1710@end group
1477@end lisp 1711@end lisp
1478 1712
1479If you need to silence a missing function warning, you can use 1713If you need to silence a missing function warning, you can use
1480@code{:functions}: 1714@code{:functions}:
1481 1715
1482@lisp 1716@lisp
1717@group
1483(use-package ruby-mode 1718(use-package ruby-mode
1484 :mode "\\.rb\\'" 1719 :mode "\\.rb\\'"
1485 :interpreter "ruby" 1720 :interpreter "ruby"
@@ -1488,12 +1723,14 @@ If you need to silence a missing function warning, you can use
1488 (defun my-ruby-mode-hook () 1723 (defun my-ruby-mode-hook ()
1489 (require 'inf-ruby) 1724 (require 'inf-ruby)
1490 (inf-ruby-keys)) 1725 (inf-ruby-keys))
1726@end group
1491 1727
1492 (add-hook 'ruby-mode-hook 'my-ruby-mode-hook)) 1728 (add-hook 'ruby-mode-hook 'my-ruby-mode-hook))
1493@end lisp 1729@end lisp
1494 1730
1495@findex :no-require 1731@findex :no-require
1496@cindex prevent a package from loading at compile-time 1732@cindex prevent a package from loading at compile-time
1733@cindex package loading at byte-compilation time, prevent
1497Normally, @code{use-package} will load each package at compile time 1734Normally, @code{use-package} will load each package at compile time
1498before compiling the configuration, to ensure that any necessary 1735before compiling the configuration, to ensure that any necessary
1499symbols are in scope to satisfy the byte-compiler. At times this can 1736symbols are in scope to satisfy the byte-compiler. At times this can
@@ -1503,21 +1740,23 @@ configuration to the @code{eval-after-load} hook. In such cases, use
1503the @code{:no-require} keyword: 1740the @code{:no-require} keyword:
1504 1741
1505@lisp 1742@lisp
1743@group
1506(use-package foo 1744(use-package foo
1507 :no-require t 1745 :no-require t
1508 :config 1746 :config
1509 (message "Evaluate this immediately after loading `foo'")) 1747 (message "Evaluate this immediately after loading `foo'"))
1748@end group
1510@end lisp 1749@end lisp
1511 1750
1512@c ---------------------------------------------------------------------------- 1751@c ----------------------------------------------------------------------------
1513@node Troubleshooting 1752@node Troubleshooting
1514@chapter Troubleshooting 1753@chapter Troubleshooting
1515 1754
1516@cindex troubleshooting 1755@cindex troubleshooting use-package
1517@cindex debugging 1756@cindex debugging use-package
1518If an error occurs while initializing or configuring a package, this 1757If an error occurs while initializing or configuring a package, this
1519will not stop your Emacs from loading. Instead, @code{use-package} 1758will not stop your Emacs from loading. Instead, @code{use-package}
1520captures the error and reports it in a special @code{*Warnings*} popup 1759captures the error and reports it in a special @file{*Warnings*} popup
1521buffer, so that you can debug the situation in an otherwise functional 1760buffer, so that you can debug the situation in an otherwise functional
1522Emacs. 1761Emacs.
1523 1762
@@ -1528,11 +1767,13 @@ that flag, add the following to your init file (these options are
1528documented below): 1767documented below):
1529 1768
1530@lisp 1769@lisp
1770@group
1531(when init-file-debug 1771(when init-file-debug
1532 (setq use-package-verbose t 1772 (setq use-package-verbose t
1533 use-package-expand-minimally nil 1773 use-package-expand-minimally nil
1534 use-package-compute-statistics t 1774 use-package-compute-statistics t
1535 debug-on-error t)) 1775 debug-on-error t))
1776@end group
1536@end lisp 1777@end lisp
1537 1778
1538@cindex reporting bugs 1779@cindex reporting bugs
@@ -1552,6 +1793,8 @@ their output in any bugs you file for use-package.
1552 1793
1553@node Troubleshooting Options 1794@node Troubleshooting Options
1554@section Options that help when troubleshooting 1795@section Options that help when troubleshooting
1796@cindex options for troubleshooting
1797@cindex troubleshooting, options that help
1555 1798
1556@vindex use-package-expand-minimally 1799@vindex use-package-expand-minimally
1557By default, use-package will attempts to catch and report errors that 1800By default, use-package will attempts to catch and report errors that
@@ -1568,9 +1811,10 @@ the error object (as generated by @code{condition-case}). For
1568example: 1811example:
1569 1812
1570@lisp 1813@lisp
1814@group
1571(use-package example 1815(use-package example
1572 ;; Note that errors are never trapped in the preface, since doing so would 1816 ;; Note that errors are never trapped in the preface, since
1573 ;; hide definitions from the byte-compiler. 1817 ;; doing so would hide definitions from the byte-compiler.
1574 :preface (message "I'm here at byte-compile and load time") 1818 :preface (message "I'm here at byte-compile and load time")
1575 :init (message "I'm always here at startup") 1819 :init (message "I'm always here at startup")
1576 :config 1820 :config
@@ -1580,20 +1824,23 @@ example:
1580 :no-require t 1824 :no-require t
1581 :catch (lambda (keyword err) 1825 :catch (lambda (keyword err)
1582 (message (error-message-string err)))) 1826 (message (error-message-string err))))
1827@end group
1583@end lisp 1828@end lisp
1584 1829
1585Evaluating the above form will print these messages: 1830Evaluating the above form will print these messages:
1586 1831
1587@verbatim 1832@verbatim
1588I’m here at byte-compile and load time 1833I'm here at byte-compile and load time
1589I’m always here at startup 1834I'm always here at startup
1590Configuring package example... 1835Configuring package example...
1591I’m always here after the package is loaded 1836I'm always here after the package is loaded
1592oops 1837oops
1593@end verbatim 1838@end verbatim
1594 1839
1595@node Gathering Statistics 1840@node Gathering Statistics
1596@section Gathering Statistics 1841@section Gathering Statistics
1842@cindex gathering use-package statistics
1843@cindex usage statistics for use-package
1597 1844
1598@vindex use-package-verbose 1845@vindex use-package-verbose
1599When a package is loaded, and if you have @code{use-package-verbose} 1846When a package is loaded, and if you have @code{use-package-verbose}
@@ -1616,21 +1863,21 @@ buffer displayed is a tabulated list. To sort rows based on a
1616particular column, move point to it and type @kbd{S}, or click the 1863particular column, move point to it and type @kbd{S}, or click the
1617column name at the top of the buffer on graphical displays. 1864column name at the top of the buffer on graphical displays.
1618 1865
1619@cindex use-package-reset-statistics 1866@findex use-package-reset-statistics
1620To reset all statistics that use-package has gathered for the current 1867To reset all statistics that use-package has gathered for the current
1621Emacs invocation, run the command @kbd{M-x use-package-reset-statistics}. 1868Emacs invocation, run the command @kbd{M-x use-package-reset-statistics}.
1622 1869
1623Note that, if you are setting @code{use-package-compute-statistics} 1870Note that if you are setting @code{use-package-compute-statistics}
1624directly in your init file, and not with @code{customize}, you must do 1871directly in your init file, and not with @code{customize}, you must do
1625this after loading @code{use-package}, but before any 1872this after loading @code{use-package}, but before any
1626@code{use-package} forms. 1873@code{use-package} forms.
1627 1874
1628@node Disabling a package 1875@node Disabling a package
1629@section Disabling a package 1876@section Disabling a package
1630
1631@cindex disable package 1877@cindex disable package
1878
1632@findex :disabled 1879@findex :disabled
1633The @code{:disabled} keyword inhibits loading a package, and all it's 1880The @code{:disabled} keyword inhibits loading a package, and all its
1634customizations. It is equivalent to commenting out or deleting the 1881customizations. It is equivalent to commenting out or deleting the
1635definition. 1882definition.
1636 1883
@@ -1641,8 +1888,10 @@ you're not currently using.
1641This example disables the @samp{foo} package: 1888This example disables the @samp{foo} package:
1642 1889
1643@lisp 1890@lisp
1891@group
1644(use-package foo 1892(use-package foo
1645 :disabled) 1893 :disabled)
1894@end group
1646@end lisp 1895@end lisp
1647 1896
1648When byte-compiling your init file, use-package omits disabled 1897When byte-compiling your init file, use-package omits disabled
@@ -1652,6 +1901,8 @@ faster.
1652@c ---------------------------------------------------------------------------- 1901@c ----------------------------------------------------------------------------
1653@node Keyword extensions 1902@node Keyword extensions
1654@appendix Keyword extensions 1903@appendix Keyword extensions
1904@cindex keyword extension
1905@cindex extending use-package keywords
1655 1906
1656use-package is based on an extensible framework that makes it easy for 1907use-package is based on an extensible framework that makes it easy for
1657package authors to add new keywords, or modify the behavior of 1908package authors to add new keywords, or modify the behavior of
@@ -1666,7 +1917,7 @@ be optionally enabled.
1666@end menu 1917@end menu
1667 1918
1668@node use-package-ensure-system-package 1919@node use-package-ensure-system-package
1669@section :use-package-ensure-system-package 1920@appendixsec :use-package-ensure-system-package
1670 1921
1671@findex :ensure-system-package 1922@findex :ensure-system-package
1672The @code{:ensure-system-package} keyword allows you to ensure certain 1923The @code{:ensure-system-package} keyword allows you to ensure certain
@@ -1688,14 +1939,16 @@ Now you can use the @code{:ensure-system-package} keyword.
1688Here's an example usage: 1939Here's an example usage:
1689 1940
1690@lisp 1941@lisp
1942@group
1691(use-package foo 1943(use-package foo
1692 :ensure-system-package foo) 1944 :ensure-system-package foo)
1945@end group
1693@end lisp 1946@end lisp
1694 1947
1695This will expect a global binary package to exist called @code{foo}. 1948This will expect a global binary package to exist called @code{foo}.
1696If it does not, it will use your system package manager to attempt an 1949If it does not, it will use your system package manager to attempt an
1697install of a binary by the same name asynchronously. This requires 1950install of a binary by the same name asynchronously. This requires
1698the GNU ELPA package 1951the @acronym{GNU} @acronym{ELPA} package
1699@uref{https://gitlab.com/jabranham/system-packages,@samp{system-packages}}, 1952@uref{https://gitlab.com/jabranham/system-packages,@samp{system-packages}},
1700so for this to work you must install that first. 1953so for this to work you must install that first.
1701 1954
@@ -1703,8 +1956,10 @@ One way of making sure it is installed is with @code{use-package}
1703together with @code{:ensure}. 1956together with @code{:ensure}.
1704 1957
1705@lisp 1958@lisp
1959@group
1706(use-package system-packages 1960(use-package system-packages
1707 :ensure t) 1961 :ensure t)
1962@end group
1708@end lisp 1963@end lisp
1709 1964
1710For example, on a @code{Debian GNU/Linux} system, this would call 1965For example, on a @code{Debian GNU/Linux} system, this would call
@@ -1714,9 +1969,11 @@ If the package is named differently than the binary, you can use a
1714cons in the form of @code{(binary . package-name)}. For example: 1969cons in the form of @code{(binary . package-name)}. For example:
1715 1970
1716@lisp 1971@lisp
1972@group
1717(use-package foo 1973(use-package foo
1718 :ensure-system-package 1974 :ensure-system-package
1719 (foocmd . foo)) 1975 (foocmd . foo))
1976@end group
1720@end lisp 1977@end lisp
1721 1978
1722On a @code{Debian GNU/Linux} system, this would call @code{apt install 1979On a @code{Debian GNU/Linux} system, this would call @code{apt install
@@ -1725,36 +1982,42 @@ foo} if Emacs could not locate the executable
1725@code{executable-find} function, which is what @samp{system-packages} 1982@code{executable-find} function, which is what @samp{system-packages}
1726uses internally.} 1983uses internally.}
1727 1984
1728@code{:ensure-system-package} can also take a cons where its 1985@code{:ensure-system-package} can also take a cons where the
1729@code{cdr} is a string that will get called by 1986@code{cdr} is a string that will get called by
1730@code{(async-shell-command)} to install if it isn't found. This does 1987@code{(async-shell-command)} to install if it isn't found. This does
1731not depend upon any external package. 1988not depend on any external package.
1732 1989
1733@lisp 1990@lisp
1991@group
1734(use-package tern 1992(use-package tern
1735 :ensure-system-package (tern . "npm i -g tern")) 1993 :ensure-system-package (tern . "npm i -g tern"))
1994@end group
1736@end lisp 1995@end lisp
1737 1996
1738To install several packages, you can pass in a list of conses: 1997To install several packages, you can pass in a list of conses:
1739 1998
1740@lisp 1999@lisp
2000@group
1741(use-package ruby-mode 2001(use-package ruby-mode
1742 :ensure-system-package 2002 :ensure-system-package
1743 ((rubocop . "gem install rubocop") 2003 ((rubocop . "gem install rubocop")
1744 (ruby-lint . "gem install ruby-lint") 2004 (ruby-lint . "gem install ruby-lint")
1745 (ripper-tags . "gem install ripper-tags") 2005 (ripper-tags . "gem install ripper-tags")
1746 (pry . "gem install pry"))) 2006 (pry . "gem install pry")))
2007@end group
1747@end lisp 2008@end lisp
1748 2009
1749Finally, in case the package dependency does not provide a global 2010Finally, in case the package dependency does not provide a global
1750executable, you can ensure packages exist by checking the presence of a 2011executable, you can ensure that packages exist by checking the
1751file path by providing a string like so: 2012presence of a file by providing a string like so:
1752 2013
1753@lisp 2014@lisp
2015@group
1754(use-package dash-at-point 2016(use-package dash-at-point
1755 :if (eq system-type 'darwin) 2017 :if (eq system-type 'darwin)
1756 :ensure-system-package 2018 :ensure-system-package
1757 ("/Applications/Dash.app" . "brew cask install dash")) 2019 ("/Applications/Dash.app" . "brew cask install dash"))
2020@end group
1758@end lisp 2021@end lisp
1759 2022
1760@code{:ensure-system-package} will use @code{system-packages-install} 2023@code{:ensure-system-package} will use @code{system-packages-install}
@@ -1768,7 +2031,8 @@ commands. Custom commands should include the call to sudo in the
1768command if needed. 2031command if needed.
1769 2032
1770@node Creating an extension 2033@node Creating an extension
1771@section How to create an extension keyword 2034@appendixsec How to create an extension keyword
2035@cindex extension keywords
1772 2036
1773This section describes how to create a new keyword. 2037This section describes how to create a new keyword.
1774 2038
@@ -1794,6 +2058,7 @@ Define a normalizer for your keyword by defining a function named
1794after the keyword, for example: 2058after the keyword, for example:
1795 2059
1796@lisp 2060@lisp
2061@group
1797(defun use-package-normalize/:pin (name-symbol keyword args) 2062(defun use-package-normalize/:pin (name-symbol keyword args)
1798 (use-package-only-one (symbol-name keyword) args 2063 (use-package-only-one (symbol-name keyword) args
1799 (lambda (label arg) 2064 (lambda (label arg)
@@ -1803,6 +2068,7 @@ after the keyword, for example:
1803 (t 2068 (t
1804 (use-package-error 2069 (use-package-error
1805 ":pin wants an archive name (a string)")))))) 2070 ":pin wants an archive name (a string)"))))))
2071@end group
1806@end lisp 2072@end lisp
1807 2073
1808@item 2074@item
@@ -1810,13 +2076,13 @@ Create a handler.
1810 2076
1811Once you have a normalizer, you must create a handler for the keyword. 2077Once you have a normalizer, you must create a handler for the keyword.
1812 2078
1813Handlers can affect the handling of keywords in two ways. First, it 2079Handlers can affect the handling of keywords in two ways. First, they
1814can modify the @code{state} plist before recursively processing the 2080can modify the @code{state} plist before recursively processing the
1815remaining keywords, to influence keywords that pay attention to the 2081remaining keywords, to influence keywords that pay attention to the
1816state (one example is the state keyword @code{:deferred}, not to be 2082state (one example is the state keyword @code{:deferred}, not to be
1817confused with the @code{use-package} keyword @code{:defer}). Then, 2083confused with the @code{use-package} keyword @code{:defer}). Then,
1818once the remaining keywords have been handled and their resulting 2084once the remaining keywords have been handled and their resulting
1819forms returned, the handler may manipulate, extend, or just ignore 2085forms returned, the handlers may manipulate, extend, or just ignore
1820those forms. 2086those forms.
1821 2087
1822The task of each handler is to return a @emph{list of forms} 2088The task of each handler is to return a @emph{list of forms}
@@ -1830,6 +2096,7 @@ minimum code necessary is emitted as the result of a
1830This is an example handler: 2096This is an example handler:
1831 2097
1832@lisp 2098@lisp
2099@group
1833(defun use-package-handler/:pin (name-symbol keyword archive-name rest state) 2100(defun use-package-handler/:pin (name-symbol keyword archive-name rest state)
1834 (let ((body (use-package-process-keywords name-symbol rest state))) 2101 (let ((body (use-package-process-keywords name-symbol rest state)))
1835 ;; This happens at macro expansion time, not when the expanded code is 2102 ;; This happens at macro expansion time, not when the expanded code is
@@ -1841,16 +2108,17 @@ This is an example handler:
1841 body 2108 body
1842 `((push '(,name-symbol . ,archive-name) 2109 `((push '(,name-symbol . ,archive-name)
1843 package-pinned-packages)))))) 2110 package-pinned-packages))))))
2111@end group
1844@end lisp 2112@end lisp
1845 2113
1846@item 2114@item
1847Test it. 2115Test it.
1848 2116
1849After the keyword has been inserted into @code{use-package-keywords}, 2117After the keyword has been inserted into @code{use-package-keywords},
1850and a normalizer and a handler defined, you can now test it by seeing 2118and a normalizer and a handler has been defined, you can now test the
1851how usages of the keyword will expand. For this, use @code{M-x 2119keyword by seeing how usages of the keyword will expand. For this,
1852pp-macroexpand-last-sexp} with the cursor set immediately after the 2120use @w{@kbd{M-x pp-macroexpand-last-sexp}} with the cursor set
1853@code{(use-package ...)} expression. 2121immediately after the @code{(use-package @dots{})} expression.
1854@end enumerate 2122@end enumerate
1855 2123
1856@c ---------------------------------------------------------------------------- 2124@c ----------------------------------------------------------------------------
diff --git a/etc/NEWS.29 b/etc/NEWS.29
index 67711fd7666..e4a19e29869 100644
--- a/etc/NEWS.29
+++ b/etc/NEWS.29
@@ -2002,14 +2002,14 @@ After Emacs 29.1, some aspects of EUDC will be deprecated. The goal
2002of these deprecations is to simplify EUDC server configuration by 2002of these deprecations is to simplify EUDC server configuration by
2003making 'eudc-server-hotlist' the only place to add servers. There 2003making 'eudc-server-hotlist' the only place to add servers. There
2004will not be a need to set the server using the 'eudc-set-server' 2004will not be a need to set the server using the 'eudc-set-server'
2005function. Instead, the 'eudc-server-hotlist' variable should be 2005command. Instead, the 'eudc-server-hotlist' user option should be
2006customized to have an entry for the server. The plan is to obsolete 2006customized to have an entry for the server. The plan is to obsolete
2007the 'eudc-hotlist' editor since Customize is sufficient for changing 2007the 'eudc-hotlist' package since Customize is sufficient for changing
2008'eudc-server-hotlist'. How the 'eudc-server' variable works in this 2008'eudc-server-hotlist'. How the 'eudc-server' user option works in this
2009context is to-be-determined; it can't be removed, because that would 2009context is to-be-determined; it can't be removed, because that would
2010break compatibility, but it may become synchronized with 2010break compatibility, but it may become synchronized with
2011'eudc-server-hotlist' so that 'eudc-server' is always equal to (first 2011'eudc-server-hotlist' so that 'eudc-server' is always equal to '(car
2012eudc-server-hotlist). The first entry in 'eudc-server-hotlist' is the 2012eudc-server-hotlist)'. The first entry in 'eudc-server-hotlist' is the
2013first server tried by 'eudc-expand-try-all'. The hotlist 2013first server tried by 'eudc-expand-try-all'. The hotlist
2014simplification will allow 'eudc-query-form' to show a drop down of 2014simplification will allow 'eudc-query-form' to show a drop down of
2015possible servers, instead of requiring a call to 'eudc-set-server' 2015possible servers, instead of requiring a call to 'eudc-set-server'
@@ -2967,7 +2967,7 @@ Protocol (LSP).
2967use-package is shipped with Emacs. It provides the 'use-package' 2967use-package is shipped with Emacs. It provides the 'use-package'
2968macro, which allows you to isolate package configuration in your init 2968macro, which allows you to isolate package configuration in your init
2969file in a way that is declarative, tidy, and performance-oriented. 2969file in a way that is declarative, tidy, and performance-oriented.
2970See the new Info manual 'use-package' for more. 2970See the new Info manual "(use-package) Top" for more.
2971 2971
2972+++ 2972+++
2973** New commands 'image-crop' and 'image-cut'. 2973** New commands 'image-crop' and 'image-cut'.
@@ -3017,13 +3017,13 @@ when visiting JSON files.
3017A major mode based on the tree-sitter library for editing programs 3017A major mode based on the tree-sitter library for editing programs
3018in the TypeScript language. It includes support for font-locking, 3018in the TypeScript language. It includes support for font-locking,
3019indentation, and navigation. This mode will be auto-enabled for 3019indentation, and navigation. This mode will be auto-enabled for
3020files with the '.ts' extension. 3020files with the ".ts" extension.
3021 3021
3022** New major mode 'tsx-ts-mode'. 3022** New major mode 'tsx-ts-mode'.
3023A major mode based on the tree-sitter library for editing programs 3023A major mode based on the tree-sitter library for editing programs
3024in the TypeScript language, with support for TSX. It includes 3024in the TypeScript language, with support for TSX. It includes
3025support for font-locking, indentation, and navigation. This mode 3025support for font-locking, indentation, and navigation. This mode
3026will be auto-enabled for files with the '.tsx' extension. 3026will be auto-enabled for files with the ".tsx" extension.
3027 3027
3028** New major mode 'c-ts-mode'. 3028** New major mode 'c-ts-mode'.
3029A major mode based on the tree-sitter library for editing programs 3029A major mode based on the tree-sitter library for editing programs
@@ -4418,7 +4418,7 @@ variable for compatibility but its limiting powers have been taken away.
4418This function returns a completion table designed to ease 4418This function returns a completion table designed to ease
4419communication between Emacs's completion facilities and external tools 4419communication between Emacs's completion facilities and external tools
4420offering completion services, particularly tools whose full working 4420offering completion services, particularly tools whose full working
4421set is too big to transfer to Emacs's every time a completion is 4421set is too big to transfer to Emacs every time a completion is
4422needed. The table uses new 'external' completion style exclusively 4422needed. The table uses new 'external' completion style exclusively
4423and cannot work with regular styles such as 'basic' or 'flex'. 4423and cannot work with regular styles such as 'basic' or 'flex'.
4424 4424
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 268d83dc449..6bb2e013c3b 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -5994,18 +5994,17 @@ See also `erc-downcase'."
5994 (and (erc--target-channel-p erc--target) 5994 (and (erc--target-channel-p erc--target)
5995 (erc-get-channel-user (erc-current-nick)) t)) 5995 (erc-get-channel-user (erc-current-nick)) t))
5996 5996
5997;; This function happens to return nil in channel buffers previously 5997;; While `erc-default-target' happens to return nil in channel buffers
5998;; parted or those from which a user had been kicked. While this 5998;; you've parted or from which you've been kicked, using it to detect
5999;; "works" for detecting whether a channel is currently subscribed to, 5999;; whether a channel is currently joined may become unreliable in the
6000;; new code should consider using 6000;; future. For now, new code should consider using
6001;; 6001;;
6002;; (erc-get-channel-user (erc-current-nick)) 6002;; (erc-get-channel-user (erc-current-nick))
6003;; 6003;;
6004;; instead. For retrieving a target regardless of subscription or 6004;; and expect a nicer option eventually. For retrieving a target
6005;; connection status, use replacements based on `erc--target'. 6005;; regardless of subscription or connection status, use replacements
6006;; (Coming soon.) 6006;; based on `erc--target' instead. See also `erc--default-target'.
6007;; 6007
6008;; TODO deprecate this
6009(defun erc-default-target () 6008(defun erc-default-target ()
6010 "Return the current default target (as a character string) or nil if none." 6009 "Return the current default target (as a character string) or nil if none."
6011 (let ((tgt (car erc-default-recipients))) 6010 (let ((tgt (car erc-default-recipients)))
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 73f773e8f4d..da7641774fb 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -690,7 +690,7 @@ It has been changed in GVFS 1.14.")
690 ("gvfs-set-attribute" . "set")) 690 ("gvfs-set-attribute" . "set"))
691 "List of cons cells, mapping \"gvfs-<command>\" to \"gio <command>\".") 691 "List of cons cells, mapping \"gvfs-<command>\" to \"gio <command>\".")
692 692
693;; <http://www.pygtk.org/docs/pygobject/gio-constants.html> 693;; <https://www.pygtk.org/docs/pygobject/gio-constants.html>
694(eval-and-compile 694(eval-and-compile
695 (defconst tramp-gvfs-file-attributes 695 (defconst tramp-gvfs-file-attributes
696 '("name" 696 '("name"
diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
index f08e8d6506e..d0465b26f05 100644
--- a/lisp/progmodes/csharp-mode.el
+++ b/lisp/progmodes/csharp-mode.el
@@ -505,7 +505,7 @@ compilation and evaluation time conflicts."
505 505
506(defun csharp--compilation-error-file-resolve () 506(defun csharp--compilation-error-file-resolve ()
507 "Resolve an msbuild error to a (filename . dirname) cons cell." 507 "Resolve an msbuild error to a (filename . dirname) cons cell."
508 ;; http://stackoverflow.com/a/18049590/429091 508 ;; https://stackoverflow.com/a/18049590/429091
509 (cons (match-string 1) (file-name-directory (match-string 4)))) 509 (cons (match-string 1) (file-name-directory (match-string 4))))
510 510
511(defconst csharp-compilation-re-msbuild-error 511(defconst csharp-compilation-re-msbuild-error
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index cafb99c6d80..a53f62fc565 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -387,6 +387,11 @@ done by `eglot-reconnect'."
387 "String displayed in mode line when Eglot is active." 387 "String displayed in mode line when Eglot is active."
388 :type 'string) 388 :type 'string)
389 389
390(defcustom eglot-report-progress t
391 "If non-nil, show progress of long running LSP server work"
392 :type 'boolean
393 :version "29.1")
394
390(defvar eglot-withhold-process-id nil 395(defvar eglot-withhold-process-id nil
391 "If non-nil, Eglot will not send the Emacs process id to the language server. 396 "If non-nil, Eglot will not send the Emacs process id to the language server.
392This can be useful when using docker to run a language server.") 397This can be useful when using docker to run a language server.")
@@ -471,6 +476,7 @@ This can be useful when using docker to run a language server.")
471 (TextDocumentEdit (:textDocument :edits) ()) 476 (TextDocumentEdit (:textDocument :edits) ())
472 (TextEdit (:range :newText)) 477 (TextEdit (:range :newText))
473 (VersionedTextDocumentIdentifier (:uri :version) ()) 478 (VersionedTextDocumentIdentifier (:uri :version) ())
479 (WorkDoneProgress (:kind) (:title :message :percentage :cancellable))
474 (WorkspaceEdit () (:changes :documentChanges)) 480 (WorkspaceEdit () (:changes :documentChanges))
475 (WorkspaceSymbol (:name :kind) (:containerName :location :data))) 481 (WorkspaceSymbol (:name :kind) (:containerName :location :data)))
476 "Alist (INTERFACE-NAME . INTERFACE) of known external LSP interfaces. 482 "Alist (INTERFACE-NAME . INTERFACE) of known external LSP interfaces.
@@ -541,7 +547,7 @@ on unknown notifications and errors on unknown requests."))
541 for type = (or (cdr (assoc k types)) t) ;; FIXME: enforce nil type? 547 for type = (or (cdr (assoc k types)) t) ;; FIXME: enforce nil type?
542 unless (cl-typep v type) 548 unless (cl-typep v type)
543 do (eglot--error "A `%s' must have a %s as %s, but has %s" 549 do (eglot--error "A `%s' must have a %s as %s, but has %s"
544 interface-name ))) 550 interface-name)))
545 t)) 551 t))
546 552
547(eval-and-compile 553(eval-and-compile
@@ -832,6 +838,9 @@ treated as in `eglot--dbind'."
832 (project 838 (project
833 :documentation "Project associated with server." 839 :documentation "Project associated with server."
834 :accessor eglot--project) 840 :accessor eglot--project)
841 (progress-reporters
842 :initform (make-hash-table :test #'equal) :accessor eglot--progress-reporters
843 :documentation "Maps LSP progress tokens to progress reporters.")
835 (inhibit-autoreconnect 844 (inhibit-autoreconnect
836 :initform t 845 :initform t
837 :documentation "Generalized boolean inhibiting auto-reconnection if true." 846 :documentation "Generalized boolean inhibiting auto-reconnection if true."
@@ -1126,11 +1135,11 @@ INTERACTIVE is t if called interactively."
1126 (let ((buffer (current-buffer))) 1135 (let ((buffer (current-buffer)))
1127 (cl-labels 1136 (cl-labels
1128 ((maybe-connect 1137 ((maybe-connect
1129 () 1138 ()
1130 (remove-hook 'post-command-hook #'maybe-connect nil) 1139 (remove-hook 'post-command-hook #'maybe-connect nil)
1131 (eglot--when-live-buffer buffer 1140 (eglot--when-live-buffer buffer
1132 (unless eglot--managed-mode 1141 (unless eglot--managed-mode
1133 (apply #'eglot--connect (eglot--guess-contact)))))) 1142 (apply #'eglot--connect (eglot--guess-contact))))))
1134 (when buffer-file-name 1143 (when buffer-file-name
1135 (add-hook 'post-command-hook #'maybe-connect 'append nil))))) 1144 (add-hook 'post-command-hook #'maybe-connect 'append nil)))))
1136 1145
@@ -1182,7 +1191,7 @@ Each function is passed the server as an argument")
1182 (list "sh" "-c" 1191 (list "sh" "-c"
1183 (string-join (cons "stty raw > /dev/null;" 1192 (string-join (cons "stty raw > /dev/null;"
1184 (mapcar #'shell-quote-argument contact)) 1193 (mapcar #'shell-quote-argument contact))
1185 " ")) 1194 " "))
1186 contact)) 1195 contact))
1187 1196
1188(defvar-local eglot--cached-server nil 1197(defvar-local eglot--cached-server nil
@@ -1236,7 +1245,7 @@ This docstring appeases checkdoc, that's all."
1236 ,@more-initargs))))) 1245 ,@more-initargs)))))
1237 (spread (lambda (fn) (lambda (server method params) 1246 (spread (lambda (fn) (lambda (server method params)
1238 (let ((eglot--cached-server server)) 1247 (let ((eglot--cached-server server))
1239 (apply fn server method (append params nil)))))) 1248 (apply fn server method (append params nil))))))
1240 (server 1249 (server
1241 (apply 1250 (apply
1242 #'make-instance class 1251 #'make-instance class
@@ -1570,7 +1579,7 @@ Doubles as an indicator of snippet support."
1570 (setq-local markdown-fontify-code-blocks-natively t) 1579 (setq-local markdown-fontify-code-blocks-natively t)
1571 (insert string) 1580 (insert string)
1572 (let ((inhibit-message t) 1581 (let ((inhibit-message t)
1573 (message-log-max nil)) 1582 (message-log-max nil))
1574 (ignore-errors (delay-mode-hooks (funcall mode)))) 1583 (ignore-errors (delay-mode-hooks (funcall mode))))
1575 (font-lock-ensure) 1584 (font-lock-ensure)
1576 (string-trim (buffer-string))))) 1585 (string-trim (buffer-string)))))
@@ -1855,8 +1864,8 @@ If it is activated, also signal textDocument/didOpen."
1855 (force-mode-line-update t)))))) 1864 (force-mode-line-update t))))))
1856 1865
1857(defun eglot-manual () "Open documentation." 1866(defun eglot-manual () "Open documentation."
1858 (declare (obsolete info "29.1")) 1867 (declare (obsolete info "29.1"))
1859 (interactive) (info "(eglot)")) 1868 (interactive) (info "(eglot)"))
1860 1869
1861(easy-menu-define eglot-menu nil "Eglot" 1870(easy-menu-define eglot-menu nil "Eglot"
1862 `("Eglot" 1871 `("Eglot"
@@ -1960,17 +1969,17 @@ Uses THING, FACE, DEFS and PREPEND."
1960 'keymap (let ((map (make-sparse-keymap))) 1969 'keymap (let ((map (make-sparse-keymap)))
1961 (define-key map [mode-line down-mouse-1] eglot-server-menu) 1970 (define-key map [mode-line down-mouse-1] eglot-server-menu)
1962 map)) 1971 map))
1963 ,@(when last-error 1972 ,@(when last-error
1964 `("/" ,(eglot--mode-line-props 1973 `("/" ,(eglot--mode-line-props
1965 "error" 'compilation-mode-line-fail 1974 "error" 'compilation-mode-line-fail
1966 '((mouse-3 eglot-clear-status "Clear this status")) 1975 '((mouse-3 eglot-clear-status "Clear this status"))
1967 (format "An error occurred: %s\n" (plist-get last-error 1976 (format "An error occurred: %s\n" (plist-get last-error
1968 :message))))) 1977 :message)))))
1969 ,@(when (cl-plusp pending) 1978 ,@(when (cl-plusp pending)
1970 `("/" ,(eglot--mode-line-props 1979 `("/" ,(eglot--mode-line-props
1971 (format "%d" pending) 'warning 1980 (format "%d" pending) 'warning
1972 '((mouse-3 eglot-forget-pending-continuations 1981 '((mouse-3 eglot-forget-pending-continuations
1973 "Forget pending continuations")) 1982 "Forget pending continuations"))
1974 "Number of outgoing, \ 1983 "Number of outgoing, \
1975still unanswered LSP requests to the server\n")))))))) 1984still unanswered LSP requests to the server\n"))))))))
1976 1985
@@ -1988,13 +1997,13 @@ still unanswered LSP requests to the server\n"))))))))
1988(defalias 'eglot--diag-data 'flymake-diagnostic-data) 1997(defalias 'eglot--diag-data 'flymake-diagnostic-data)
1989 1998
1990(cl-loop for i from 1 1999(cl-loop for i from 1
1991 for type in '(eglot-note eglot-warning eglot-error ) 2000 for type in '(eglot-note eglot-warning eglot-error)
1992 do (put type 'flymake-overlay-control 2001 do (put type 'flymake-overlay-control
1993 `((mouse-face . highlight) 2002 `((mouse-face . highlight)
1994 (priority . ,(+ 50 i)) 2003 (priority . ,(+ 50 i))
1995 (keymap . ,(let ((map (make-sparse-keymap))) 2004 (keymap . ,(let ((map (make-sparse-keymap)))
1996 (define-key map [mouse-1] 2005 (define-key map [mouse-1]
1997 (eglot--mouse-call 'eglot-code-actions)) 2006 (eglot--mouse-call 'eglot-code-actions))
1998 map))))) 2007 map)))))
1999 2008
2000 2009
@@ -2051,6 +2060,27 @@ COMMAND is a symbol naming the command."
2051 "Handle notification telemetry/event.") ;; noop, use events buffer 2060 "Handle notification telemetry/event.") ;; noop, use events buffer
2052 2061
2053(cl-defmethod eglot-handle-notification 2062(cl-defmethod eglot-handle-notification
2063 (server (_method (eql $/progress)) &key token value)
2064 "Handle $/progress notification identified by TOKEN from SERVER."
2065 (when eglot-report-progress
2066 (cl-flet ((fmt (&rest args) (mapconcat #'identity args " ")))
2067 (eglot--dbind ((WorkDoneProgress) kind title percentage message) value
2068 (pcase kind
2069 ("begin"
2070 (let* ((prefix (format (concat "[eglot] %s %s:" (when percentage " "))
2071 (eglot-project-nickname server) token))
2072 (pr (puthash token
2073 (if percentage
2074 (make-progress-reporter prefix 0 100 percentage 1 0)
2075 (make-progress-reporter prefix nil nil nil 1 0))
2076 (eglot--progress-reporters server))))
2077 (progress-reporter-update pr percentage (fmt title message))))
2078 ("report"
2079 (when-let ((pr (gethash token (eglot--progress-reporters server))))
2080 (progress-reporter-update pr percentage (fmt title message))))
2081 ("end" (remhash token (eglot--progress-reporters server))))))))
2082
2083(cl-defmethod eglot-handle-notification
2054 (_server (_method (eql textDocument/publishDiagnostics)) &key uri diagnostics 2084 (_server (_method (eql textDocument/publishDiagnostics)) &key uri diagnostics
2055 &allow-other-keys) ; FIXME: doesn't respect `eglot-strict-mode' 2085 &allow-other-keys) ; FIXME: doesn't respect `eglot-strict-mode'
2056 "Handle notification publishDiagnostics." 2086 "Handle notification publishDiagnostics."
@@ -2174,7 +2204,7 @@ THINGS are either registrations or unregisterations (sic)."
2174 (append 2204 (append
2175 (eglot--VersionedTextDocumentIdentifier) 2205 (eglot--VersionedTextDocumentIdentifier)
2176 (list :languageId 2206 (list :languageId
2177 (eglot--language-id (eglot--current-server-or-lose)) 2207 (eglot--language-id (eglot--current-server-or-lose))
2178 :text 2208 :text
2179 (eglot--widening 2209 (eglot--widening
2180 (buffer-substring-no-properties (point-min) (point-max)))))) 2210 (buffer-substring-no-properties (point-min) (point-max))))))
@@ -2636,7 +2666,7 @@ If BUFFER, switch to it before."
2636 uri range)))))) 2666 uri range))))))
2637 (if (vectorp response) response (and response (list response))))))) 2667 (if (vectorp response) response (and response (list response)))))))
2638 2668
2639(cl-defun eglot--lsp-xref-helper (method &key extra-params capability ) 2669(cl-defun eglot--lsp-xref-helper (method &key extra-params capability)
2640 "Helper for `eglot-find-declaration' & friends." 2670 "Helper for `eglot-find-declaration' & friends."
2641 (let ((eglot--lsp-xref-refs (eglot--lsp-xrefs-for-method 2671 (let ((eglot--lsp-xref-refs (eglot--lsp-xrefs-for-method
2642 method 2672 method
@@ -2668,7 +2698,7 @@ If BUFFER, switch to it before."
2668 (get-text-property 0 'eglot--lsp-workspaceSymbol probe) 2698 (get-text-property 0 'eglot--lsp-workspaceSymbol probe)
2669 (eglot--dbind ((Location) uri range) location 2699 (eglot--dbind ((Location) uri range) location
2670 (list (eglot--xref-make-match name uri range)))) 2700 (list (eglot--xref-make-match name uri range))))
2671 (eglot--lsp-xrefs-for-method :textDocument/definition)))) 2701 (eglot--lsp-xrefs-for-method :textDocument/definition))))
2672 2702
2673(cl-defmethod xref-backend-references ((_backend (eql eglot)) _identifier) 2703(cl-defmethod xref-backend-references ((_backend (eql eglot)) _identifier)
2674 (or 2704 (or
@@ -2707,7 +2737,7 @@ for which LSP on-type-formatting should be requested."
2707 `(:textDocument/onTypeFormatting 2737 `(:textDocument/onTypeFormatting
2708 :documentOnTypeFormattingProvider 2738 :documentOnTypeFormattingProvider
2709 ,`(:position ,(eglot--pos-to-lsp-position beg) 2739 ,`(:position ,(eglot--pos-to-lsp-position beg)
2710 :ch ,(string on-type-format)))) 2740 :ch ,(string on-type-format))))
2711 ((and beg end) 2741 ((and beg end)
2712 `(:textDocument/rangeFormatting 2742 `(:textDocument/rangeFormatting
2713 :documentRangeFormattingProvider 2743 :documentRangeFormattingProvider
@@ -3280,24 +3310,24 @@ at point. With prefix argument, prompt for ACTION-KIND."
3280 (eglot--project server)))))) 3310 (eglot--project server))))))
3281 (cl-labels 3311 (cl-labels
3282 ((handle-event 3312 ((handle-event
3283 (event) 3313 (event)
3284 (pcase-let* ((`(,desc ,action ,file ,file1) event) 3314 (pcase-let* ((`(,desc ,action ,file ,file1) event)
3285 (action-type (cl-case action 3315 (action-type (cl-case action
3286 (created 1) (changed 2) (deleted 3))) 3316 (created 1) (changed 2) (deleted 3)))
3287 (action-bit (when action-type 3317 (action-bit (when action-type
3288 (ash 1 (1- action-type))))) 3318 (ash 1 (1- action-type)))))
3289 (cond 3319 (cond
3290 ((and (memq action '(created changed deleted)) 3320 ((and (memq action '(created changed deleted))
3291 (cl-loop for (glob . kind-bitmask) in globs 3321 (cl-loop for (glob . kind-bitmask) in globs
3292 thereis (and (> (logand kind-bitmask action-bit) 0) 3322 thereis (and (> (logand kind-bitmask action-bit) 0)
3293 (funcall glob file)))) 3323 (funcall glob file))))
3294 (jsonrpc-notify 3324 (jsonrpc-notify
3295 server :workspace/didChangeWatchedFiles 3325 server :workspace/didChangeWatchedFiles
3296 `(:changes ,(vector `(:uri ,(eglot--path-to-uri file) 3326 `(:changes ,(vector `(:uri ,(eglot--path-to-uri file)
3297 :type ,action-type))))) 3327 :type ,action-type)))))
3298 ((eq action 'renamed) 3328 ((eq action 'renamed)
3299 (handle-event `(,desc 'deleted ,file)) 3329 (handle-event `(,desc 'deleted ,file))
3300 (handle-event `(,desc 'created ,file1))))))) 3330 (handle-event `(,desc 'created ,file1)))))))
3301 (unwind-protect 3331 (unwind-protect
3302 (progn 3332 (progn
3303 (dolist (dir dirs-to-watch) 3333 (dolist (dir dirs-to-watch)
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index adb984c3e59..a4a8cd84050 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -54,9 +54,8 @@
54;; (question mark) if no backends were even configured. 54;; (question mark) if no backends were even configured.
55;; 55;;
56;; For programmers interested in writing a new Flymake backend, the 56;; For programmers interested in writing a new Flymake backend, the
57;; docstring of `flymake-diagnostic-functions', the Flymake manual, 57;; docstring of `flymake-diagnostic-functions', the Flymake manual, and the
58;; and the code of existing backends are probably a good starting 58;; code of existing backends are probably good starting points.
59;; point.
60;; 59;;
61;; The user wishing to customize the appearance of error types should 60;; The user wishing to customize the appearance of error types should
62;; set properties on the symbols associated with each diagnostic type. 61;; set properties on the symbols associated with each diagnostic type.
diff --git a/lisp/replace.el b/lisp/replace.el
index c7ae77d128b..6f59166e352 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1101,7 +1101,10 @@ Hence, a match starting on the same line at which another match
1101ended is ignored. 1101ended is ignored.
1102 1102
1103Return the number of killed matching lines. When called 1103Return the number of killed matching lines. When called
1104interactively, also print the number." 1104interactively, also print the number.
1105
1106If you merely want to delete the lines, without adding them to
1107the kill ring, the \\[flush-lines] command is faster."
1105 (interactive 1108 (interactive
1106 (progn 1109 (progn
1107 (barf-if-buffer-read-only) 1110 (barf-if-buffer-read-only)
diff --git a/lisp/textmodes/emacs-news-mode.el b/lisp/textmodes/emacs-news-mode.el
index ebb31da9cf4..26f8f610eff 100644
--- a/lisp/textmodes/emacs-news-mode.el
+++ b/lisp/textmodes/emacs-news-mode.el
@@ -226,7 +226,7 @@ untagged NEWS entry."
226 ;; Do manual references. 226 ;; Do manual references.
227 (goto-char (point-min)) 227 (goto-char (point-min))
228 (search-forward "\f" nil t) 228 (search-forward "\f" nil t)
229 (while (re-search-forward "\"\\(([a-z0-9]+)[ \n][^\"]\\{1,80\\}\\)\"" 229 (while (re-search-forward "\"\\(([a-z0-9-]+)[ \n][^\"]\\{1,80\\}\\)\""
230 nil t) 230 nil t)
231 (buttonize-region (match-beginning 1) (match-end 1) 231 (buttonize-region (match-beginning 1) (match-end 1)
232 (lambda (node) (info node)) 232 (lambda (node) (info node))
diff --git a/lisp/use-package/bind-key.el b/lisp/use-package/bind-key.el
index 95685410b82..0d4c3de5d11 100644
--- a/lisp/use-package/bind-key.el
+++ b/lisp/use-package/bind-key.el
@@ -282,7 +282,7 @@ Accepts keyword arguments:
282 key in the repeat map, but will not set the 282 key in the repeat map, but will not set the
283 `repeat-map' property of the bound command. 283 `repeat-map' property of the bound command.
284:continue BINDINGS - Within the scope of `:repeat-map' forces the 284:continue BINDINGS - Within the scope of `:repeat-map' forces the
285 same behaviour as if no special keyword had 285 same behavior as if no special keyword had
286 been used (that is, the command is bound, and 286 been used (that is, the command is bound, and
287 it's `repeat-map' property set) 287 it's `repeat-map' property set)
288:filter FORM - optional form to determine when bindings apply 288:filter FORM - optional form to determine when bindings apply
@@ -429,7 +429,7 @@ Accepts keyword arguments:
429 key in the repeat map, but will not set the 429 key in the repeat map, but will not set the
430 `repeat-map' property of the bound command. 430 `repeat-map' property of the bound command.
431:continue BINDINGS - Within the scope of `:repeat-map' forces the 431:continue BINDINGS - Within the scope of `:repeat-map' forces the
432 same behaviour as if no special keyword had 432 same behavior as if no special keyword had
433 been used (that is, the command is bound, and 433 been used (that is, the command is bound, and
434 it's `repeat-map' property set) 434 it's `repeat-map' property set)
435:filter FORM - optional form to determine when bindings apply 435:filter FORM - optional form to determine when bindings apply
diff --git a/lisp/use-package/use-package-bind-key.el b/lisp/use-package/use-package-bind-key.el
index 44242c9e01d..4ebf54825c6 100644
--- a/lisp/use-package/use-package-bind-key.el
+++ b/lisp/use-package/use-package-bind-key.el
@@ -38,15 +38,14 @@
38 38
39;;;###autoload 39;;;###autoload
40(defun use-package-autoload-keymap (keymap-symbol package override) 40(defun use-package-autoload-keymap (keymap-symbol package override)
41 "Loads PACKAGE and then binds the key sequence used to invoke 41 "Load PACKAGE and bind key sequence invoking this function to KEYMAP-SYMBOL.
42this function to KEYMAP-SYMBOL. It then simulates pressing the 42Then simulate pressing the same key sequence a again, so that the
43same key sequence a again, so that the next key pressed is routed 43next key pressed is routed to the newly loaded keymap.
44to the newly loaded keymap.
45 44
46This function supports use-package's :bind-keymap keyword. It 45This function supports use-package's :bind-keymap keyword. It
47works by binding the given key sequence to an invocation of this 46works by binding the given key sequence to an invocation of this
48function for a particular keymap. The keymap is expected to be 47function for a particular keymap. The keymap is expected to be
49defined by the package. In this way, loading the package is 48defined by the package. In this way, loading the package is
50deferred until the prefix key sequence is pressed." 49deferred until the prefix key sequence is pressed."
51 (if (not (require package nil t)) 50 (if (not (require package nil t))
52 (use-package-error (format "Cannot load package.el: %s" package)) 51 (use-package-error (format "Cannot load package.el: %s" package))
diff --git a/src/itree.c b/src/itree.c
index 04fa9e827a2..975f3a8e4fb 100644
--- a/src/itree.c
+++ b/src/itree.c
@@ -15,7 +15,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details. 15GNU General Public License for more details.
16 16
17You should have received a copy of the GNU General Public License 17You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 18along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
19 19
20#include <config.h> 20#include <config.h>
21#include <math.h> 21#include <math.h>
diff --git a/src/itree.h b/src/itree.h
index 248ea9b84d2..f1e2bf3bfde 100644
--- a/src/itree.h
+++ b/src/itree.h
@@ -15,7 +15,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details. 15GNU General Public License for more details.
16 16
17You should have received a copy of the GNU General Public License 17You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 18along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
19 19
20#ifndef ITREE_H 20#ifndef ITREE_H
21#define ITREE_H 21#define ITREE_H