gnu: emacs: Add autoloads for Emacs packages.
[jackhill/guix/guix.git] / doc / emacs.texi
CommitLineData
457f60fa
AK
1@node Emacs Interface
2@section Emacs Interface
3
bd53d327 4@cindex Emacs
457f60fa
AK
5GNU Guix comes with a visual user interface for GNU@tie{}Emacs, known
6as ``guix.el''. It can be used for routine package management tasks,
7pretty much like the @command{guix package} command (@pxref{Invoking
8guix package}). Specifically, ``guix.el'' makes it easy to:
9
10@itemize
11@item browse and display packages and generations;
12@item search, install, upgrade and remove packages;
13@item display packages from previous generations;
14@item do some other useful things.
15@end itemize
16
17@menu
bd53d327
AK
18* Initial Setup: Emacs Initial Setup. Preparing @file{~/.emacs}.
19* Usage: Emacs Usage. Using the interface.
20* Configuration: Emacs Configuration. Configuring the interface.
9a130e19 21* Prettify Mode: Emacs Prettify. Abbreviating @file{/gnu/store/@dots{}} file names.
457f60fa
AK
22@end menu
23
bd53d327 24@node Emacs Initial Setup
457f60fa
AK
25@subsection Initial Setup
26
27To be able to use ``guix.el'', you need to install the following
28packages:
29
30@itemize
31@item
32@uref{http://www.gnu.org/software/emacs/, GNU Emacs}, version 24.3 or
33later;
34
35@item
36@uref{http://nongnu.org/geiser/, Geiser}, version 0.3 or later: it is
37used for interacting with the Guile process.
38
39@end itemize
40
41When it is done, add the following into your init file (@pxref{Init
773bab64 42File,,, emacs, The GNU Emacs Manual}):
457f60fa
AK
43
44@example
45(require 'guix-init nil t)
46@end example
47
48However there is a chance that @code{load-path} of your Emacs does not
49contain a directory with ``guix.el'' (usually it is
50@file{/usr/share/emacs/site-lisp/}). In that case you need to add it
773bab64
AK
51before requiring (@pxref{Lisp Libraries,,, emacs, The GNU Emacs
52Manual}):
457f60fa
AK
53
54@example
55(add-to-list 'load-path "/path/to/directory-with-guix.el")
56(require 'guix-init)
57@end example
58
59Do not worry about the efficiency of that @code{require} thing. It will
60not load the whole ``guix.el'' package, it will just autoload the main
773bab64
AK
61interactive commands (@pxref{Autoload,,, elisp, The GNU Emacs Lisp
62Reference Manual}).
457f60fa
AK
63
64
bd53d327 65@node Emacs Usage
457f60fa
AK
66@subsection Usage
67
68Once ``guix.el'' has been successfully configured, you should be able to
69use commands for displaying packages and generations. This information
70can be displayed in a ``list'' or ``info'' buffer.
71
72@menu
bd53d327
AK
73* Commands: Emacs Commands. @kbd{M-x guix-@dots{}}
74* General information: Emacs General info. Common for both interfaces.
75* ``List'' buffer: Emacs List buffer. List-like interface.
76* ``Info'' buffer: Emacs Info buffer. Help-like interface.
457f60fa
AK
77@end menu
78
bd53d327 79@node Emacs Commands
457f60fa
AK
80@subsubsection Commands
81
23459fa5
AK
82All commands for displaying packages and generations use the current
83profile, which can be changed with
84@kbd{M-x@tie{}guix-set-current-profile}. Alternatively, if you call any
85of these commands with prefix argument (@kbd{C-u}), you will be prompted
86for a profile just for that command.
87
88Commands for displaying packages:
457f60fa
AK
89
90@table @kbd
23459fa5 91
457f60fa
AK
92@item M-x guix-all-available-packages
93@itemx M-x guix-newest-available-packages
94Display all/newest available packages.
95
96@item M-x guix-installed-packages
23459fa5 97Display all installed packages.
457f60fa
AK
98
99@item M-x guix-obsolete-packages
23459fa5
AK
100Display obsolete packages (the packages that are installed in a profile
101but cannot be found among available packages).
457f60fa
AK
102
103@item M-x guix-search-by-name
104Display package(s) with the specified name.
105
106@item M-x guix-search-by-regexp
107Search for packages by a specified regexp. By default ``name'',
108``synopsis'' and ``description'' of the packages will be searched. This
109can be changed by modifying @code{guix-search-params} variable.
110
457f60fa
AK
111@end table
112
23459fa5
AK
113By default, these commands display each output on a separate line. If
114you prefer to see a list of packages---i.e., a list with a package per
115line, use the following setting:
a54a237b
AK
116
117@example
118(setq guix-package-list-type 'package)
119@end example
120
23459fa5
AK
121Commands for displaying generations:
122
123@table @kbd
124
125@item M-x guix-generations
126List all the generations.
127
128@item M-x guix-last-generations
129List the @var{N} last generations. You will be prompted for the number
130of generations.
131
132@item M-x guix-generations-by-time
133List generations matching time period. You will be prompted for the
134period using Org mode time prompt based on Emacs calendar (@pxref{The
773bab64 135date/time prompt,,, org, The Org Manual}).
23459fa5
AK
136
137@end table
457f60fa 138
2d7bf949
AK
139You can also invoke the @command{guix pull} command (@pxref{Invoking
140guix pull}) from Emacs using:
141
142@table @kbd
143@item M-x guix-pull
144With @kbd{C-u}, make it verbose.
145@end table
146
147Once @command{guix pull} has succeeded, the Guix REPL is restared. This
148allows you to keep using the Emacs interface with the updated Guix.
149
bd53d327 150@node Emacs General info
457f60fa
AK
151@subsubsection General information
152
153The following keys are available for both ``list'' and ``info'' types of
154buffers:
155
156@table @kbd
157@item l
158@itemx r
159Go backward/forward by the history of the displayed results (this
160history is similar to the history of the Emacs @code{help-mode} or
161@code{Info-mode}).
162
163@item g
164Revert current buffer: update information about the displayed
165packages/generations and redisplay it.
166
167@item R
168Redisplay current buffer (without updating information).
169
170@item C-c C-z
171Go to the Guix REPL (@pxref{The REPL,,, geiser, Geiser User Manual}).
172
173@item h
174@itemx ?
175Describe current mode to see all available bindings.
176
177@end table
178
179@emph{Hint:} If you need several ``list'' or ``info'' buffers, you can
180simlpy @kbd{M-x clone-buffer} them, and each buffer will have its own
181history.
182
183@emph{Warning:} Name/version pairs cannot be used to identify packages
184(because a name is not necessarily unique), so ``guix.el'' uses special
185identifiers that live only during a guile session, so if the Guix REPL
186was restarted, you may want to revert ``list'' buffer (by pressing
187@kbd{g}).
188
bd53d327 189@node Emacs List buffer
457f60fa
AK
190@subsubsection ``List'' buffer
191
192An interface of a ``list'' buffer is similar to the interface provided
773bab64 193by ``package.el'' (@pxref{Package Menu,,, emacs, The GNU Emacs Manual}).
457f60fa
AK
194
195Default key bindings available for both ``package-list'' and
196``generation-list'' buffers:
197
198@table @kbd
199@item m
200Mark the current entry.
201@item M
202Mark all entries.
203@item u
91cc37a1 204Unmark the current entry (with prefix, unmark all entries).
457f60fa
AK
205@item @key{DEL}
206Unmark backward.
457f60fa
AK
207@item S
208Sort entries by a specified column.
209@end table
210
211A ``package-list'' buffer additionally provides the following bindings:
212
213@table @kbd
214@item @key{RET}
215Describe marked packages (display available information in a
216``package-info'' buffer).
217@item i
a54a237b 218Mark the current package for installation.
457f60fa 219@item d
a54a237b 220Mark the current package for deletion.
91cc37a1 221@item U
a54a237b 222Mark the current package for upgrading.
457f60fa 223@item ^
91cc37a1 224Mark all obsolete packages for upgrading.
457f60fa 225@item x
a54a237b 226Execute actions on the marked packages.
457f60fa
AK
227@end table
228
229A ``generation-list'' buffer additionally provides the following
230bindings:
231
232@table @kbd
233@item @key{RET}
234List packages installed in the current generation.
235@item i
236Describe marked generations (display available information in a
237``generation-info'' buffer).
af874238
AK
238@item s
239Switch profile to the current generation.
cb6a5c71
AK
240@item d
241Mark the current generation for deletion (with prefix, mark all
242generations).
243@item x
244Execute actions on the marked generations---i.e., delete generations.
d38bd08c
AK
245@item e
246Run Ediff (@pxref{Top,,, ediff, The Ediff Manual}) on package outputs
247installed in the 2 marked generations. With prefix argument, run Ediff
248on manifests of the marked generations.
249@item D
250@itemx =
251Run Diff (@pxref{Diff Mode,,, emacs, The GNU Emacs Manual}) on package
252outputs installed in the 2 marked generations. With prefix argument,
253run Diff on manifests of the marked generations.
254@item +
255List package outputs added to the latest marked generation comparing
256with another marked generation.
257@item -
258List package outputs removed from the latest marked generation comparing
259with another marked generation.
457f60fa
AK
260@end table
261
bd53d327 262@node Emacs Info buffer
457f60fa
AK
263@subsubsection ``Info'' buffer
264
265The interface of an ``info'' buffer is similar to the interface of
773bab64 266@code{help-mode} (@pxref{Help Mode,,, emacs, The GNU Emacs Manual}).
457f60fa
AK
267
268``Info'' buffer contains some buttons (as usual you may use @key{TAB} /
269@kbd{S-@key{TAB}} to move between buttons---@pxref{Mouse References,,,
773bab64 270emacs, The GNU Emacs Manual}) which can be used to:
457f60fa
AK
271
272@itemize @bullet
273@item (in a ``package-info'' buffer)
274
275@itemize @minus
276@item install/remove a package;
277@item jump to a package location;
278@item browse home page of a package;
279@item describe packages from ``Inputs'' fields.
280@end itemize
281
282@item (in a ``generation-info'' buffer)
283
284@itemize @minus
285@item remove a generation;
af874238 286@item switch to a generation;
457f60fa
AK
287@item list packages installed in a generation;
288@item jump to a generation directory.
289@end itemize
290
291@end itemize
292
56149217
AK
293It is also possible to copy a button label (a link to an URL or a file)
294by pressing @kbd{c} on a button.
295
457f60fa 296
bd53d327 297@node Emacs Configuration
457f60fa
AK
298@subsection Configuration
299
300There are many variables you can modify to change the appearance or
301behavior of Emacs user interface. Some of these variables are described
302in this section. Also you can use Custom Interface (@pxref{Easy
773bab64
AK
303Customization,,, emacs, The GNU Emacs Manual}) to explore/set variables
304(not all) and faces.
457f60fa
AK
305
306@menu
bd53d327
AK
307* Guile and Build Options: Emacs Build Options. Specifying how packages are built.
308* Buffer Names: Emacs Buffer Names. Names of Guix buffers.
309* Keymaps: Emacs Keymaps. Configuring key bindings.
310* Appearance: Emacs Appearance. Settings for visual appearance.
457f60fa
AK
311@end menu
312
bd53d327 313@node Emacs Build Options
457f60fa
AK
314@subsubsection Guile and Build Options
315
316@table @code
317@item guix-guile-program
318If you have some special needs for starting a Guile process, you may set
319this variable, for example:
320
321@example
322(setq guix-guile-program '("/bin/guile" "--no-auto-compile"))
323@end example
324
325@item guix-use-substitutes
326Has the same meaning as @code{--no-substitutes} option (@pxref{Invoking
327guix build}).
328
329@item guix-dry-run
330Has the same meaning as @code{--dry-run} option (@pxref{Invoking guix
331build}).
332
333@end table
334
bd53d327 335@node Emacs Buffer Names
a54a237b
AK
336@subsubsection Buffer Names
337
338Default names of ``guix.el'' buffers (``*Guix@tie{}@dots{}*'') may be
339changed with the following variables:
340
341@table @code
342@item guix-package-list-buffer-name
343@item guix-output-list-buffer-name
344@item guix-generation-list-buffer-name
345@item guix-package-info-buffer-name
346@item guix-output-info-buffer-name
347@item guix-generation-info-buffer-name
348@item guix-repl-buffer-name
349@item guix-internal-repl-buffer-name
a54a237b
AK
350@end table
351
23459fa5
AK
352By default, the name of a profile is also displayed in a ``list'' or
353``info'' buffer name. To change this behavior, use
354@code{guix-buffer-name-function} variable.
355
356For example, if you want to display all types of results in a single
a54a237b
AK
357buffer (in such case you will probably use a history (@kbd{l}/@kbd{r})
358extensively), you may do it like this:
359
360@example
361(let ((name "Guix Universal"))
362 (setq
363 guix-package-list-buffer-name name
364 guix-output-list-buffer-name name
365 guix-generation-list-buffer-name name
366 guix-package-info-buffer-name name
367 guix-output-info-buffer-name name
23459fa5
AK
368 guix-generation-info-buffer-name name
369 guix-buffer-name-function #'guix-buffer-name-simple))
a54a237b
AK
370@end example
371
bd53d327 372@node Emacs Keymaps
457f60fa
AK
373@subsubsection Keymaps
374
375If you want to change default key bindings, use the following keymaps
773bab64 376(@pxref{Init Rebinding,,, emacs, The GNU Emacs Manual}):
457f60fa
AK
377
378@table @code
379@item guix-list-mode-map
380Parent keymap with general keys for ``list'' buffers.
381
382@item guix-package-list-mode-map
383Keymap with specific keys for ``package-list'' buffers.
384
a54a237b
AK
385@item guix-output-list-mode-map
386Keymap with specific keys for ``output-list'' buffers.
387
457f60fa
AK
388@item guix-generation-list-mode-map
389Keymap with specific keys for ``generation-list'' buffers.
390
391@item guix-info-mode-map
392Parent keymap with general keys for ``info'' buffers.
393
394@item guix-package-info-mode-map
395Keymap with specific keys for ``package-info'' buffers.
396
a54a237b
AK
397@item guix-output-info-mode-map
398Keymap with specific keys for ``output-info'' buffers.
399
457f60fa
AK
400@item guix-generation-info-mode-map
401Keymap with specific keys for ``generation-info'' buffers.
402
56149217
AK
403@item guix-info-button-map
404Keymap with keys available when a point is placed on a button.
405
457f60fa
AK
406@end table
407
bd53d327 408@node Emacs Appearance
457f60fa
AK
409@subsubsection Appearance
410
411You can change almost any aspect of ``list'' / ``info'' buffers using
412the following variables:
413
414@table @code
415@item guix-list-column-format
416@itemx guix-list-column-titles
417@itemx guix-list-column-value-methods
418Specify the columns, their names, what and how is displayed in ``list''
419buffers.
420
421@item guix-info-displayed-params
422@itemx guix-info-insert-methods
423@itemx guix-info-ignore-empty-vals
424@itemx guix-info-param-title-format
425@itemx guix-info-multiline-prefix
426@itemx guix-info-indent
427@itemx guix-info-fill-column
428@itemx guix-info-delimiter
429Various settings for ``info'' buffers.
430
431@end table
9a130e19
AK
432
433
434@node Emacs Prettify
435@subsection Guix Prettify Mode
436
437Along with ``guix.el'', GNU@tie{}Guix comes with ``guix-prettify.el''.
438It provides a minor mode for abbreviating store file names by replacing
439hash sequences of symbols with ``@dots{}'':
440
441@example
442/gnu/store/72f54nfp6g1hz873w8z3gfcah0h4nl9p-foo-0.1
443@result{} /gnu/store/…-foo-0.1
444@end example
445
446Once you set up ``guix.el'' (@pxref{Emacs Initial Setup}), the following
447commands become available:
448
449@table @kbd
450
451@item M-x guix-prettify-mode
452Enable/disable prettifying for the current buffer.
453
454@item M-x global-guix-prettify-mode
455Enable/disable prettifying globally.
456
457@end table
458
459To automatically enable @code{guix-prettify-mode} globally on Emacs
460start, add the following line to your init file:
461
462@example
463(global-guix-prettify-mode)
464@end example
465
466If you want to enable it only for specific major modes, add it to the
467mode hooks (@pxref{Hooks,,, emacs, The GNU Emacs Manual}), for example:
468
469@example
470(add-hook 'shell-mode-hook 'guix-prettify-mode)
471(add-hook 'dired-mode-hook 'guix-prettify-mode)
472@end example