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