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