emacs: Deprecate "guix-init.el".
[jackhill/guix/guix.git] / doc / emacs.texi
CommitLineData
457f60fa 1@node Emacs Interface
c554de89 2@chapter Emacs Interface
457f60fa 3
bd53d327 4@cindex Emacs
c554de89
AK
5GNU Guix comes with several useful modules (known as ``guix.el'') for
6GNU@tie{}Emacs which are intended to make an Emacs user interaction with
7Guix convenient and fun.
457f60fa
AK
8
9@menu
bd53d327 10* Initial Setup: Emacs Initial Setup. Preparing @file{~/.emacs}.
c554de89 11* Package Management: Emacs Package Management. Managing packages and generations.
687c9bc0 12* Licenses: Emacs Licenses. Interface for licenses of Guix packages.
9b0afb0d 13* Popup Interface: Emacs Popup Interface. Magit-like interface for guix commands.
9a130e19 14* Prettify Mode: Emacs Prettify. Abbreviating @file{/gnu/store/@dots{}} file names.
34850cd5 15* Build Log Mode: Emacs Build Log. Highlighting Guix build logs.
187f80c6
AK
16* Completions: Emacs Completions. Completing @command{guix} shell command.
17* Development: Emacs Development. Tools for Guix developers.
32950fc8 18* Hydra: Emacs Hydra. Interface for Guix build farm.
457f60fa
AK
19@end menu
20
c554de89 21
bd53d327 22@node Emacs Initial Setup
c554de89 23@section Initial Setup
457f60fa 24
80ae897f
LC
25On the Guix System Distribution (@pxref{GNU Distribution}), ``guix.el''
26is ready to use, provided Guix is installed system-wide, which is the
27case by default. So if that is what you're using, you can happily skip
28this section and read about the fun stuff.
29
ba3bcec9 30If you're not yet a happy user of GuixSD, a little bit of setup is needed.
457f60fa
AK
31To be able to use ``guix.el'', you need to install the following
32packages:
33
34@itemize
35@item
36@uref{http://www.gnu.org/software/emacs/, GNU Emacs}, version 24.3 or
37later;
38
39@item
40@uref{http://nongnu.org/geiser/, Geiser}, version 0.3 or later: it is
41used for interacting with the Guile process.
42
9b0afb0d
AK
43@item
44@uref{https://github.com/magit/magit/, magit-popup library}. You
45already have this library if you use Magit 2.1.0 or later. This library
46is an optional dependency---it is required only for @kbd{M-x@tie{}guix}
47command (@pxref{Emacs Popup Interface}).
48
457f60fa
AK
49@end itemize
50
ff4455e6
AK
51When it is done, ``guix.el'' may be configured by requiring
52@code{guix-autoloads} file---i.e., by adding the following code into
53your init file (@pxref{Init File,,, emacs, The GNU Emacs Manual}):
457f60fa
AK
54
55@example
a72f18a5 56(add-to-list 'load-path "/path/to/directory-with-guix.el")
ff4455e6 57(require 'guix-autoloads nil t)
457f60fa
AK
58@end example
59
a72f18a5
AK
60So the only thing you need to figure out is where the directory with
61elisp files for Guix is placed. It depends on how you installed Guix:
62
63@itemize
64@item
65If it was installed by a package manager of your distribution or by a
66usual @code{./configure && make && make install} command sequence, then
67elisp files are placed in a standard directory with Emacs packages
68(usually it is @file{/usr/share/emacs/site-lisp/}), which is already in
69@code{load-path}, so there is no need to add that directory there.
70
71@item
72If you used a binary installation method (@pxref{Binary Installation}),
73then Guix is installed somewhere in the store, so the elisp files are
74placed in @file{/gnu/store/@dots{}-guix-0.8.2/share/emacs/site-lisp/} or
75alike. However it is not recommended to refer directly to a store
76directory. Instead you can install Guix using Guix itself with
ff4455e6
AK
77@command{guix package -i guix} command (@pxref{Invoking guix package}).
78No further actions are needed in this case, as @code{guix-autoloads}
79file will automatically be loaded by Emacs (if it is installed with
80Guix, of course) (@pxref{Application Setup}).
a72f18a5
AK
81
82@item
83If you did not install Guix at all and prefer a hacking way
84(@pxref{Running Guix Before It Is Installed}), along with augmenting
85@code{load-path} you need to set @code{guix-load-path} variable to the
86same directory, so your final configuration will look like this:
457f60fa
AK
87
88@example
a72f18a5
AK
89(let ((dir "/path/to/your-guix-git-tree/emacs"))
90 (add-to-list 'load-path dir)
91 (setq guix-load-path dir))
ff4455e6 92(require 'guix-autoloads nil t)
457f60fa 93@end example
a72f18a5 94@end itemize
457f60fa 95
c554de89
AK
96
97@node Emacs Package Management
98@section Package Management
457f60fa
AK
99
100Once ``guix.el'' has been successfully configured, you should be able to
c554de89
AK
101use a visual interface for routine package management tasks, pretty much
102like the @command{guix package} command (@pxref{Invoking guix package}).
103Specifically, it makes it easy to:
104
105@itemize
106@item browse and display packages and generations;
107@item search, install, upgrade and remove packages;
108@item display packages from previous generations;
109@item do some other useful things.
110@end itemize
457f60fa
AK
111
112@menu
bd53d327
AK
113* Commands: Emacs Commands. @kbd{M-x guix-@dots{}}
114* General information: Emacs General info. Common for both interfaces.
115* ``List'' buffer: Emacs List buffer. List-like interface.
116* ``Info'' buffer: Emacs Info buffer. Help-like interface.
c554de89 117* Configuration: Emacs Configuration. Configuring the interface.
457f60fa
AK
118@end menu
119
bd53d327 120@node Emacs Commands
c554de89 121@subsection Commands
457f60fa 122
23459fa5
AK
123All commands for displaying packages and generations use the current
124profile, which can be changed with
125@kbd{M-x@tie{}guix-set-current-profile}. Alternatively, if you call any
126of these commands with prefix argument (@kbd{C-u}), you will be prompted
127for a profile just for that command.
128
129Commands for displaying packages:
457f60fa
AK
130
131@table @kbd
23459fa5 132
457f60fa
AK
133@item M-x guix-all-available-packages
134@itemx M-x guix-newest-available-packages
135Display all/newest available packages.
136
137@item M-x guix-installed-packages
cfb1c62a
AK
138@itemx M-x guix-installed-user-packages
139@itemx M-x guix-installed-system-packages
140Display installed packages. As described above, @kbd{M-x
141guix-installed-packages} uses an arbitrary profile that you can specify,
142while the other commands display packages installed in 2 special
143profiles: @file{~/.guix-profile} and @file{/run/current-system/profile}
144(only on GuixSD).
457f60fa
AK
145
146@item M-x guix-obsolete-packages
23459fa5
AK
147Display obsolete packages (the packages that are installed in a profile
148but cannot be found among available packages).
457f60fa 149
e119ba90 150@item M-x guix-packages-by-name
457f60fa
AK
151Display package(s) with the specified name.
152
83aab70b
AK
153@item M-x guix-packages-by-license
154Display package(s) with the specified license.
155
457f60fa
AK
156@item M-x guix-search-by-regexp
157Search for packages by a specified regexp. By default ``name'',
158``synopsis'' and ``description'' of the packages will be searched. This
c80ce104 159can be changed by modifying @code{guix-package-search-params} variable.
457f60fa 160
27a2e483
AK
161@item M-x guix-search-by-name
162Search for packages with names matching a specified regexp. This
163command is the same as @code{guix-search-by-regexp}, except only a
164package ``name'' is searched.
165
457f60fa
AK
166@end table
167
23459fa5
AK
168By default, these commands display each output on a separate line. If
169you prefer to see a list of packages---i.e., a list with a package per
170line, use the following setting:
a54a237b
AK
171
172@example
173(setq guix-package-list-type 'package)
174@end example
175
23459fa5
AK
176Commands for displaying generations:
177
178@table @kbd
179
180@item M-x guix-generations
181List all the generations.
182
183@item M-x guix-last-generations
184List the @var{N} last generations. You will be prompted for the number
185of generations.
186
187@item M-x guix-generations-by-time
188List generations matching time period. You will be prompted for the
189period using Org mode time prompt based on Emacs calendar (@pxref{The
773bab64 190date/time prompt,,, org, The Org Manual}).
23459fa5
AK
191
192@end table
457f60fa 193
67cedc4b
AK
194Analogously on GuixSD you can also display system generations:
195
196@table @kbd
197@item M-x guix-system-generations
198@item M-x guix-last-system-generations
199@item M-x guix-system-generations-by-time
200@end table
201
2d7bf949
AK
202You can also invoke the @command{guix pull} command (@pxref{Invoking
203guix pull}) from Emacs using:
204
205@table @kbd
206@item M-x guix-pull
207With @kbd{C-u}, make it verbose.
208@end table
209
210Once @command{guix pull} has succeeded, the Guix REPL is restared. This
211allows you to keep using the Emacs interface with the updated Guix.
212
7c1b1ae2
AK
213Finally, there is an Emacs variant of @command{guix edit} command
214(@pxref{Invoking guix edit}):
215
216@table @kbd
217@item M-x guix-edit
218As with @kbd{M-x guix-packages-by-name}, you can press @key{TAB} to
219complete a package name.
220@end table
221
222If you are contributing to Guix, you may find it useful for @kbd{M-x
223guix-edit} to open package files from your git directory. This can be
224done by setting @code{guix-directory} variable. For example, after
225this:
226
227@example
228(setq guix-directory "~/src/guix")
229@end example
230
231@kbd{M-x guix-edit guix} opens
232@file{~/src/guix/gnu/packages/package-management.scm} file.
233
2c04e2ee
AK
234Also you can use @kbd{C-u} prefix argument to specify a directory just
235for the current @kbd{M-x guix-edit} command.
236
7c1b1ae2 237
bd53d327 238@node Emacs General info
c554de89 239@subsection General information
457f60fa
AK
240
241The following keys are available for both ``list'' and ``info'' types of
242buffers:
243
244@table @kbd
245@item l
246@itemx r
247Go backward/forward by the history of the displayed results (this
248history is similar to the history of the Emacs @code{help-mode} or
249@code{Info-mode}).
250
251@item g
252Revert current buffer: update information about the displayed
253packages/generations and redisplay it.
254
255@item R
256Redisplay current buffer (without updating information).
257
5a727cdf
AK
258@item M
259Apply manifest to the current profile or to a specified profile, if
260prefix argument is used. This has the same meaning as @code{--manifest}
261option (@pxref{Invoking guix package}).
262
457f60fa 263@item C-c C-z
96856613
LC
264@cindex REPL
265@cindex read-eval-print loop
457f60fa
AK
266Go to the Guix REPL (@pxref{The REPL,,, geiser, Geiser User Manual}).
267
268@item h
269@itemx ?
270Describe current mode to see all available bindings.
271
272@end table
273
274@emph{Hint:} If you need several ``list'' or ``info'' buffers, you can
275simlpy @kbd{M-x clone-buffer} them, and each buffer will have its own
276history.
277
278@emph{Warning:} Name/version pairs cannot be used to identify packages
279(because a name is not necessarily unique), so ``guix.el'' uses special
280identifiers that live only during a guile session, so if the Guix REPL
281was restarted, you may want to revert ``list'' buffer (by pressing
282@kbd{g}).
283
bd53d327 284@node Emacs List buffer
c554de89 285@subsection ``List'' buffer
457f60fa
AK
286
287An interface of a ``list'' buffer is similar to the interface provided
773bab64 288by ``package.el'' (@pxref{Package Menu,,, emacs, The GNU Emacs Manual}).
457f60fa
AK
289
290Default key bindings available for both ``package-list'' and
291``generation-list'' buffers:
292
293@table @kbd
294@item m
578b98da 295Mark the current entry (with prefix, mark all entries).
457f60fa 296@item u
91cc37a1 297Unmark the current entry (with prefix, unmark all entries).
457f60fa
AK
298@item @key{DEL}
299Unmark backward.
457f60fa
AK
300@item S
301Sort entries by a specified column.
302@end table
303
304A ``package-list'' buffer additionally provides the following bindings:
305
306@table @kbd
307@item @key{RET}
308Describe marked packages (display available information in a
309``package-info'' buffer).
310@item i
a54a237b 311Mark the current package for installation.
457f60fa 312@item d
a54a237b 313Mark the current package for deletion.
91cc37a1 314@item U
a54a237b 315Mark the current package for upgrading.
457f60fa 316@item ^
91cc37a1 317Mark all obsolete packages for upgrading.
6248e326
AK
318@item e
319Edit the definition of the curent package (go to its location). This is
320similar to @command{guix edit} command (@pxref{Invoking guix edit}), but
321for opening a package recipe in the current Emacs instance.
457f60fa 322@item x
a54a237b 323Execute actions on the marked packages.
5c8994d9
AK
324@item B
325Display latest builds of the current package (@pxref{Emacs Hydra}).
457f60fa
AK
326@end table
327
328A ``generation-list'' buffer additionally provides the following
329bindings:
330
331@table @kbd
332@item @key{RET}
333List packages installed in the current generation.
334@item i
335Describe marked generations (display available information in a
336``generation-info'' buffer).
af874238
AK
337@item s
338Switch profile to the current generation.
cb6a5c71
AK
339@item d
340Mark the current generation for deletion (with prefix, mark all
341generations).
342@item x
343Execute actions on the marked generations---i.e., delete generations.
d38bd08c
AK
344@item e
345Run Ediff (@pxref{Top,,, ediff, The Ediff Manual}) on package outputs
346installed in the 2 marked generations. With prefix argument, run Ediff
347on manifests of the marked generations.
348@item D
349@itemx =
350Run Diff (@pxref{Diff Mode,,, emacs, The GNU Emacs Manual}) on package
351outputs installed in the 2 marked generations. With prefix argument,
352run Diff on manifests of the marked generations.
353@item +
354List package outputs added to the latest marked generation comparing
355with another marked generation.
356@item -
357List package outputs removed from the latest marked generation comparing
358with another marked generation.
457f60fa
AK
359@end table
360
bd53d327 361@node Emacs Info buffer
c554de89 362@subsection ``Info'' buffer
457f60fa
AK
363
364The interface of an ``info'' buffer is similar to the interface of
773bab64 365@code{help-mode} (@pxref{Help Mode,,, emacs, The GNU Emacs Manual}).
457f60fa
AK
366
367``Info'' buffer contains some buttons (as usual you may use @key{TAB} /
368@kbd{S-@key{TAB}} to move between buttons---@pxref{Mouse References,,,
773bab64 369emacs, The GNU Emacs Manual}) which can be used to:
457f60fa
AK
370
371@itemize @bullet
372@item (in a ``package-info'' buffer)
373
374@itemize @minus
375@item install/remove a package;
376@item jump to a package location;
377@item browse home page of a package;
cefb7aea 378@item browse license URL;
457f60fa
AK
379@item describe packages from ``Inputs'' fields.
380@end itemize
381
382@item (in a ``generation-info'' buffer)
383
384@itemize @minus
385@item remove a generation;
af874238 386@item switch to a generation;
457f60fa
AK
387@item list packages installed in a generation;
388@item jump to a generation directory.
389@end itemize
390
391@end itemize
392
56149217
AK
393It is also possible to copy a button label (a link to an URL or a file)
394by pressing @kbd{c} on a button.
395
457f60fa 396
bd53d327 397@node Emacs Configuration
457f60fa
AK
398@subsection Configuration
399
400There are many variables you can modify to change the appearance or
401behavior of Emacs user interface. Some of these variables are described
402in this section. Also you can use Custom Interface (@pxref{Easy
773bab64
AK
403Customization,,, emacs, The GNU Emacs Manual}) to explore/set variables
404(not all) and faces.
457f60fa
AK
405
406@menu
bd53d327
AK
407* Guile and Build Options: Emacs Build Options. Specifying how packages are built.
408* Buffer Names: Emacs Buffer Names. Names of Guix buffers.
409* Keymaps: Emacs Keymaps. Configuring key bindings.
410* Appearance: Emacs Appearance. Settings for visual appearance.
457f60fa
AK
411@end menu
412
bd53d327 413@node Emacs Build Options
457f60fa
AK
414@subsubsection Guile and Build Options
415
416@table @code
417@item guix-guile-program
418If you have some special needs for starting a Guile process, you may set
419this variable, for example:
420
421@example
422(setq guix-guile-program '("/bin/guile" "--no-auto-compile"))
423@end example
424
425@item guix-use-substitutes
426Has the same meaning as @code{--no-substitutes} option (@pxref{Invoking
427guix build}).
428
429@item guix-dry-run
430Has the same meaning as @code{--dry-run} option (@pxref{Invoking guix
431build}).
432
433@end table
434
bd53d327 435@node Emacs Buffer Names
a54a237b
AK
436@subsubsection Buffer Names
437
438Default names of ``guix.el'' buffers (``*Guix@tie{}@dots{}*'') may be
439changed with the following variables:
440
441@table @code
442@item guix-package-list-buffer-name
443@item guix-output-list-buffer-name
444@item guix-generation-list-buffer-name
445@item guix-package-info-buffer-name
446@item guix-output-info-buffer-name
447@item guix-generation-info-buffer-name
448@item guix-repl-buffer-name
449@item guix-internal-repl-buffer-name
a54a237b
AK
450@end table
451
23459fa5
AK
452By default, the name of a profile is also displayed in a ``list'' or
453``info'' buffer name. To change this behavior, use
8bff0c79 454@code{guix-ui-buffer-name-function} variable.
23459fa5
AK
455
456For example, if you want to display all types of results in a single
a54a237b
AK
457buffer (in such case you will probably use a history (@kbd{l}/@kbd{r})
458extensively), you may do it like this:
459
460@example
461(let ((name "Guix Universal"))
462 (setq
463 guix-package-list-buffer-name name
464 guix-output-list-buffer-name name
465 guix-generation-list-buffer-name name
466 guix-package-info-buffer-name name
467 guix-output-info-buffer-name name
8bff0c79 468 guix-generation-info-buffer-name name))
a54a237b
AK
469@end example
470
bd53d327 471@node Emacs Keymaps
457f60fa
AK
472@subsubsection Keymaps
473
474If you want to change default key bindings, use the following keymaps
773bab64 475(@pxref{Init Rebinding,,, emacs, The GNU Emacs Manual}):
457f60fa
AK
476
477@table @code
e40b3c33
AK
478@item guix-buffer-map
479Parent keymap with general keys for any buffer type.
480
481@item guix-ui-map
482Parent keymap with general keys for buffers used for Guix package
483management (for packages, outputs and generations).
74cc6737 484
457f60fa
AK
485@item guix-list-mode-map
486Parent keymap with general keys for ``list'' buffers.
487
488@item guix-package-list-mode-map
489Keymap with specific keys for ``package-list'' buffers.
490
a54a237b
AK
491@item guix-output-list-mode-map
492Keymap with specific keys for ``output-list'' buffers.
493
457f60fa
AK
494@item guix-generation-list-mode-map
495Keymap with specific keys for ``generation-list'' buffers.
496
497@item guix-info-mode-map
498Parent keymap with general keys for ``info'' buffers.
499
500@item guix-package-info-mode-map
501Keymap with specific keys for ``package-info'' buffers.
502
a54a237b
AK
503@item guix-output-info-mode-map
504Keymap with specific keys for ``output-info'' buffers.
505
457f60fa
AK
506@item guix-generation-info-mode-map
507Keymap with specific keys for ``generation-info'' buffers.
508
56149217
AK
509@item guix-info-button-map
510Keymap with keys available when a point is placed on a button.
511
457f60fa
AK
512@end table
513
bd53d327 514@node Emacs Appearance
457f60fa
AK
515@subsubsection Appearance
516
517You can change almost any aspect of ``list'' / ``info'' buffers using
cf910cef
AK
518the following variables (@dfn{ENTRY-TYPE} means @code{package},
519@code{output} or @code{generation}):
457f60fa
AK
520
521@table @code
cf910cef 522@item guix-ENTRY-TYPE-list-format
574f6727 523@itemx guix-ENTRY-TYPE-list-titles
457f60fa
AK
524Specify the columns, their names, what and how is displayed in ``list''
525buffers.
526
9193fb7c 527@item guix-ENTRY-TYPE-info-format
574f6727 528@itemx guix-ENTRY-TYPE-info-titles
2c7ed388 529@itemx guix-info-ignore-empty-values
457f60fa
AK
530@itemx guix-info-param-title-format
531@itemx guix-info-multiline-prefix
532@itemx guix-info-indent
2c7ed388 533@itemx guix-info-fill
457f60fa
AK
534@itemx guix-info-delimiter
535Various settings for ``info'' buffers.
536
537@end table
9a130e19
AK
538
539
687c9bc0
AK
540@node Emacs Licenses
541@section Licenses
542
543If you want to browse the URL of a particular license, or to look at a
544list of licenses, you may use the following commands:
545
546@table @kbd
547
548@item M-x guix-browse-license-url
549Choose a license from a completion list to browse its URL using
550@code{browse-url} function (@pxref{Browse-URL,,, emacs, The GNU Emacs
551Manual}).
552
553@item M-x guix-licenses
554Display a list of available licenses. You can press @kbd{@key{RET}}
555there to display packages with this license in the same way as @kbd{M-x
556guix-packages-by-license} would do (@pxref{Emacs Commands}).
557
558@end table
559
560
9b0afb0d
AK
561@node Emacs Popup Interface
562@section Popup Interface
563
564If you ever used Magit, you know what ``popup interface'' is
565(@pxref{Top,,, magit-popup, Magit-Popup User Manual}). Even if you are
566not acquainted with Magit, there should be no worries as it is very
567intuitive.
568
569So @kbd{M-x@tie{}guix} command provides a top-level popup interface for
570all available guix commands. When you select an option, you'll be
571prompted for a value in the minibuffer. Many values have completions,
572so don't hesitate to press @key{TAB} key. Multiple values (for example,
573packages or lint checkers) should be separated by commas.
574
575After specifying all options and switches for a command, you may choose
576one of the available actions. The following default actions are
577available for all commands:
578
579@itemize
580
581@item
582Run the command in the Guix REPL. It is faster than running
583@code{guix@tie{}@dots{}} command directly in shell, as there is no
584need to run another guile process and to load required modules there.
585
586@item
587Run the command in a shell buffer. You can set
588@code{guix-run-in-shell-function} variable to fine tune the shell buffer
589you want to use.
590
591@item
592Add the command line to the kill ring (@pxref{Kill Ring,,, emacs, The
593GNU Emacs Manual}).
594
595@end itemize
596
710fa231 597Several commands (@command{guix graph}, @command{guix system shepherd-graph}
5e2b761e
AK
598and @command{guix system extension-graph}) also have a ``View graph''
599action, which allows you to view a generated graph using @command{dot}
600command (specified by @code{guix-dot-program} variable). By default a
601PNG file will be saved in @file{/tmp} directory and will be opened
602directly in Emacs. This behavior may be changed with the following
603variables:
604
605@table @code
606
607@item guix-find-file-function
608Function used to open a generated graph. If you want to open a graph in
609an external program, you can do it by modifying this variable---for
610example, you can use a functionality provided by the Org Mode
611(@pxref{Top,,, org, The Org Manual}):
612
613@example
614(setq guix-find-file-function 'org-open-file)
615(add-to-list 'org-file-apps '("\\.png\\'" . "sxiv %s"))
616@end example
617
618@item guix-dot-default-arguments
619Command line arguments to run @command{dot} command. If you change an
620output format (for example, into @code{-Tpdf}), you also need to change
621the next variable.
622
623@item guix-dot-file-name-function
624Function used to define a name of the generated graph file. Default
625name is @file{/tmp/guix-emacs-graph-XXXXXX.png}.
626
627@end table
628
629So, for example, if you want to generate and open a PDF file in your
630Emacs, you may change the settings like this:
631
632@example
633(defun my-guix-pdf-graph ()
634 "/tmp/my-current-guix-graph.pdf")
635
636(setq guix-dot-default-arguments '("-Tpdf")
637 guix-dot-file-name-function 'my-guix-pdf-graph)
638@end example
639
9b0afb0d 640
9a130e19 641@node Emacs Prettify
c554de89 642@section Guix Prettify Mode
9a130e19 643
c554de89
AK
644GNU@tie{}Guix also comes with ``guix-prettify.el''. It provides a minor
645mode for abbreviating store file names by replacing hash sequences of
646symbols with ``@dots{}'':
9a130e19
AK
647
648@example
649/gnu/store/72f54nfp6g1hz873w8z3gfcah0h4nl9p-foo-0.1
650@result{} /gnu/store/…-foo-0.1
651@end example
652
653Once you set up ``guix.el'' (@pxref{Emacs Initial Setup}), the following
654commands become available:
655
656@table @kbd
657
658@item M-x guix-prettify-mode
659Enable/disable prettifying for the current buffer.
660
661@item M-x global-guix-prettify-mode
662Enable/disable prettifying globally.
663
664@end table
665
666To automatically enable @code{guix-prettify-mode} globally on Emacs
667start, add the following line to your init file:
668
669@example
670(global-guix-prettify-mode)
671@end example
672
673If you want to enable it only for specific major modes, add it to the
674mode hooks (@pxref{Hooks,,, emacs, The GNU Emacs Manual}), for example:
675
676@example
677(add-hook 'shell-mode-hook 'guix-prettify-mode)
678(add-hook 'dired-mode-hook 'guix-prettify-mode)
679@end example
00a8dae2
AK
680
681
34850cd5
AK
682@node Emacs Build Log
683@section Build Log Mode
684
685GNU@tie{}Guix provides major and minor modes for highlighting build
686logs. So when you have a file with a package build output---for
687example, a file returned by @command{guix build --log-file @dots{}}
688command (@pxref{Invoking guix build}), you may call @kbd{M-x
689guix-build-log-mode} command in the buffer with this file. This major
690mode highlights some lines specific to build output and provides the
691following key bindings:
692
693@table @kbd
694
695@item M-n
696Move to the next build phase.
697
698@item M-p
699Move to the previous build phase.
700
eda1cc8b
AK
701@item @key{TAB}
702Toggle (show/hide) the body of the current build phase.
703
704@item S-@key{TAB}
705Toggle (show/hide) the bodies of all build phases.
706
34850cd5
AK
707@end table
708
709There is also @kbd{M-x guix-build-log-minor-mode} which also provides
f4044b58
AK
710the same highlighting and the same key bindings as the major mode, but
711prefixed with @kbd{C-c}. By default, this minor mode is enabled in
712shell buffers (@pxref{Interactive Shell,,, emacs, The GNU Emacs
713Manual}). If you don't like it, set
714@code{guix-build-log-minor-mode-activate} to nil.
34850cd5
AK
715
716
00a8dae2 717@node Emacs Completions
c554de89 718@section Shell Completions
00a8dae2
AK
719
720Another feature that becomes available after configuring Emacs interface
721(@pxref{Emacs Initial Setup}) is completing of @command{guix}
722subcommands, options, packages and other things in @code{shell}
723(@pxref{Interactive Shell,,, emacs, The GNU Emacs Manual}) and
724@code{eshell} (@pxref{Top,,, eshell, Eshell: The Emacs Shell}).
725
726It works the same way as other completions do. Just press @key{TAB}
727when your intuition tells you.
728
729And here are some examples, where pressing @key{TAB} may complete
730something:
731
732@itemize @w{}
733
734@item @code{guix pa}@key{TAB}
735@item @code{guix package -}@key{TAB}
736@item @code{guix package --}@key{TAB}
737@item @code{guix package -i gei}@key{TAB}
738@item @code{guix build -L/tm}@key{TAB}
739@item @code{guix build --sy}@key{TAB}
740@item @code{guix build --system=i}@key{TAB}
741@item @code{guix system rec}@key{TAB}
742@item @code{guix lint --checkers=sy}@key{TAB}
743@item @code{guix lint --checkers=synopsis,des}@key{TAB}
744
745@end itemize
187f80c6
AK
746
747
748@node Emacs Development
749@section Development
750
751By default, when you open a Scheme file, @code{guix-devel-mode} will be
752activated (if you don't want it, set @code{guix-devel-activate-mode} to
753nil). This minor mode provides the following key bindings:
754
755@table @kbd
756
757@item C-c . k
758Copy the name of the current Guile module into kill ring
759(@code{guix-devel-copy-module-as-kill}).
760
761@item C-c . u
762Use the current Guile module. Often after opening a Scheme file, you
763want to use a module it defines, so you switch to the Geiser REPL and
764write @code{,use (some module)} there. You may just use this command
765instead (@code{guix-devel-use-module}).
766
1a6c4c2f
AK
767@item C-c . b
768Build a package defined by the current variable definition. The
769building process is run in the current Geiser REPL. If you modified the
770current package definition, don't forget to reevaluate it before calling
771this command---for example, with @kbd{C-M-x} (@pxref{To eval or not to
772eval,,, geiser, Geiser User Manual})
773(@code{guix-devel-build-package-definition}).
774
ad8b83bd
AK
775@item C-c . s
776Build a source derivation of the package defined by the current variable
777definition. This command has the same meaning as @code{guix build -S}
778shell command (@pxref{Invoking guix build})
779(@code{guix-devel-build-package-source}).
780
b94ef11a
AK
781@item C-c . l
782Lint (check) a package defined by the current variable definition
783(@pxref{Invoking guix lint}) (@code{guix-devel-lint-package}).
784
187f80c6 785@end table
1a6c4c2f
AK
786
787Unluckily, there is a limitation related to long-running REPL commands.
788When there is a running process in a Geiser REPL, you are not supposed
789to evaluate anything in a scheme buffer, because this will ``freeze''
790the REPL: it will stop producing any output (however, the evaluating
791process will continue---you will just not see any progress anymore). Be
792aware: even moving the point in a scheme buffer may ``break'' the REPL
793if Autodoc (@pxref{Autodoc and friends,,, geiser, Geiser User Manual})
794is enabled (which is the default).
795
796So you have to postpone editing your scheme buffers until the running
797evaluation will be finished in the REPL.
798
799Alternatively, to avoid this limitation, you may just run another Geiser
800REPL, and while something is being evaluated in the previous REPL, you
801can continue editing a scheme file with the help of the current one.
32950fc8
AK
802
803
804@node Emacs Hydra
805@section Hydra
806
807The continuous integration server at @code{hydra.gnu.org} builds all
808the distribution packages on the supported architectures and serves
809them as substitutes (@pxref{Substitutes}). Continuous integration is
810currently orchestrated by @uref{https://nixos.org/hydra/, Hydra}.
811
812This section describes an Emacs interface to query Hydra to know the
813build status of specific packages, discover recent and ongoing builds,
814view build logs, and so on. This interface is mostly the same as the
815``list''/``info'' interface for displaying packages and generations
816(@pxref{Emacs Package Management}).
817
818The following commands are available:
819
820@table @kbd
821
822@item M-x guix-hydra-latest-builds
823Display latest failed or successful builds (you will be prompted for a
824number of builds). With @kbd{C-u}, you will also be prompted for other
825parameters (project, jobset, job and system).
826
827@item M-x guix-hydra-queued-builds
828Display scheduled or currently running builds (you will be prompted for
829a number of builds).
830
831@item M-x guix-hydra-jobsets
832Display available jobsets (you will be prompted for a project).
833
834@end table
835
836In a list of builds you can press @kbd{L} key to display a build log of
837the current build. Also both a list of builds and a list of jobsets
838provide @kbd{B} key to display latest builds of the current job or
839jobset (don't forget about @kbd{C-u}).