Commit | Line | Data |
---|---|---|
457f60fa AK |
1 | @node Emacs Interface |
2 | @section Emacs Interface | |
3 | ||
bd53d327 | 4 | @cindex Emacs |
457f60fa AK |
5 | GNU Guix comes with a visual user interface for GNU@tie{}Emacs, known |
6 | as ``guix.el''. It can be used for routine package management tasks, | |
7 | pretty much like the @command{guix package} command (@pxref{Invoking | |
8 | guix 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 | ||
27 | To be able to use ``guix.el'', you need to install the following | |
28 | packages: | |
29 | ||
30 | @itemize | |
31 | @item | |
32 | @uref{http://www.gnu.org/software/emacs/, GNU Emacs}, version 24.3 or | |
33 | later; | |
34 | ||
35 | @item | |
36 | @uref{http://nongnu.org/geiser/, Geiser}, version 0.3 or later: it is | |
37 | used for interacting with the Guile process. | |
38 | ||
39 | @end itemize | |
40 | ||
41 | When it is done, add the following into your init file (@pxref{Init | |
773bab64 | 42 | File,,, emacs, The GNU Emacs Manual}): |
457f60fa AK |
43 | |
44 | @example | |
45 | (require 'guix-init nil t) | |
46 | @end example | |
47 | ||
48 | However there is a chance that @code{load-path} of your Emacs does not | |
49 | contain 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 |
51 | before requiring (@pxref{Lisp Libraries,,, emacs, The GNU Emacs |
52 | Manual}): | |
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 | ||
59 | Do not worry about the efficiency of that @code{require} thing. It will | |
60 | not load the whole ``guix.el'' package, it will just autoload the main | |
773bab64 AK |
61 | interactive commands (@pxref{Autoload,,, elisp, The GNU Emacs Lisp |
62 | Reference Manual}). | |
457f60fa AK |
63 | |
64 | ||
bd53d327 | 65 | @node Emacs Usage |
457f60fa AK |
66 | @subsection Usage |
67 | ||
68 | Once ``guix.el'' has been successfully configured, you should be able to | |
69 | use commands for displaying packages and generations. This information | |
70 | can 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 |
82 | All commands for displaying packages and generations use the current |
83 | profile, which can be changed with | |
84 | @kbd{M-x@tie{}guix-set-current-profile}. Alternatively, if you call any | |
85 | of these commands with prefix argument (@kbd{C-u}), you will be prompted | |
86 | for a profile just for that command. | |
87 | ||
88 | Commands 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 | |
94 | Display all/newest available packages. | |
95 | ||
96 | @item M-x guix-installed-packages | |
23459fa5 | 97 | Display all installed packages. |
457f60fa AK |
98 | |
99 | @item M-x guix-obsolete-packages | |
23459fa5 AK |
100 | Display obsolete packages (the packages that are installed in a profile |
101 | but cannot be found among available packages). | |
457f60fa AK |
102 | |
103 | @item M-x guix-search-by-name | |
104 | Display package(s) with the specified name. | |
105 | ||
106 | @item M-x guix-search-by-regexp | |
107 | Search for packages by a specified regexp. By default ``name'', | |
108 | ``synopsis'' and ``description'' of the packages will be searched. This | |
109 | can be changed by modifying @code{guix-search-params} variable. | |
110 | ||
457f60fa AK |
111 | @end table |
112 | ||
23459fa5 AK |
113 | By default, these commands display each output on a separate line. If |
114 | you prefer to see a list of packages---i.e., a list with a package per | |
115 | line, use the following setting: | |
a54a237b AK |
116 | |
117 | @example | |
118 | (setq guix-package-list-type 'package) | |
119 | @end example | |
120 | ||
23459fa5 AK |
121 | Commands for displaying generations: |
122 | ||
123 | @table @kbd | |
124 | ||
125 | @item M-x guix-generations | |
126 | List all the generations. | |
127 | ||
128 | @item M-x guix-last-generations | |
129 | List the @var{N} last generations. You will be prompted for the number | |
130 | of generations. | |
131 | ||
132 | @item M-x guix-generations-by-time | |
133 | List generations matching time period. You will be prompted for the | |
134 | period using Org mode time prompt based on Emacs calendar (@pxref{The | |
773bab64 | 135 | date/time prompt,,, org, The Org Manual}). |
23459fa5 AK |
136 | |
137 | @end table | |
457f60fa | 138 | |
2d7bf949 AK |
139 | You can also invoke the @command{guix pull} command (@pxref{Invoking |
140 | guix pull}) from Emacs using: | |
141 | ||
142 | @table @kbd | |
143 | @item M-x guix-pull | |
144 | With @kbd{C-u}, make it verbose. | |
145 | @end table | |
146 | ||
147 | Once @command{guix pull} has succeeded, the Guix REPL is restared. This | |
148 | allows 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 | ||
153 | The following keys are available for both ``list'' and ``info'' types of | |
154 | buffers: | |
155 | ||
156 | @table @kbd | |
157 | @item l | |
158 | @itemx r | |
159 | Go backward/forward by the history of the displayed results (this | |
160 | history is similar to the history of the Emacs @code{help-mode} or | |
161 | @code{Info-mode}). | |
162 | ||
163 | @item g | |
164 | Revert current buffer: update information about the displayed | |
165 | packages/generations and redisplay it. | |
166 | ||
167 | @item R | |
168 | Redisplay current buffer (without updating information). | |
169 | ||
170 | @item C-c C-z | |
171 | Go to the Guix REPL (@pxref{The REPL,,, geiser, Geiser User Manual}). | |
172 | ||
173 | @item h | |
174 | @itemx ? | |
175 | Describe 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 | |
180 | simlpy @kbd{M-x clone-buffer} them, and each buffer will have its own | |
181 | history. | |
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 | |
185 | identifiers that live only during a guile session, so if the Guix REPL | |
186 | was 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 | ||
192 | An interface of a ``list'' buffer is similar to the interface provided | |
773bab64 | 193 | by ``package.el'' (@pxref{Package Menu,,, emacs, The GNU Emacs Manual}). |
457f60fa AK |
194 | |
195 | Default key bindings available for both ``package-list'' and | |
196 | ``generation-list'' buffers: | |
197 | ||
198 | @table @kbd | |
199 | @item m | |
200 | Mark the current entry. | |
201 | @item M | |
202 | Mark all entries. | |
203 | @item u | |
91cc37a1 | 204 | Unmark the current entry (with prefix, unmark all entries). |
457f60fa AK |
205 | @item @key{DEL} |
206 | Unmark backward. | |
457f60fa AK |
207 | @item S |
208 | Sort entries by a specified column. | |
209 | @end table | |
210 | ||
211 | A ``package-list'' buffer additionally provides the following bindings: | |
212 | ||
213 | @table @kbd | |
214 | @item @key{RET} | |
215 | Describe marked packages (display available information in a | |
216 | ``package-info'' buffer). | |
217 | @item i | |
a54a237b | 218 | Mark the current package for installation. |
457f60fa | 219 | @item d |
a54a237b | 220 | Mark the current package for deletion. |
91cc37a1 | 221 | @item U |
a54a237b | 222 | Mark the current package for upgrading. |
457f60fa | 223 | @item ^ |
91cc37a1 | 224 | Mark all obsolete packages for upgrading. |
457f60fa | 225 | @item x |
a54a237b | 226 | Execute actions on the marked packages. |
457f60fa AK |
227 | @end table |
228 | ||
229 | A ``generation-list'' buffer additionally provides the following | |
230 | bindings: | |
231 | ||
232 | @table @kbd | |
233 | @item @key{RET} | |
234 | List packages installed in the current generation. | |
235 | @item i | |
236 | Describe marked generations (display available information in a | |
237 | ``generation-info'' buffer). | |
af874238 AK |
238 | @item s |
239 | Switch profile to the current generation. | |
cb6a5c71 AK |
240 | @item d |
241 | Mark the current generation for deletion (with prefix, mark all | |
242 | generations). | |
243 | @item x | |
244 | Execute actions on the marked generations---i.e., delete generations. | |
d38bd08c AK |
245 | @item e |
246 | Run Ediff (@pxref{Top,,, ediff, The Ediff Manual}) on package outputs | |
247 | installed in the 2 marked generations. With prefix argument, run Ediff | |
248 | on manifests of the marked generations. | |
249 | @item D | |
250 | @itemx = | |
251 | Run Diff (@pxref{Diff Mode,,, emacs, The GNU Emacs Manual}) on package | |
252 | outputs installed in the 2 marked generations. With prefix argument, | |
253 | run Diff on manifests of the marked generations. | |
254 | @item + | |
255 | List package outputs added to the latest marked generation comparing | |
256 | with another marked generation. | |
257 | @item - | |
258 | List package outputs removed from the latest marked generation comparing | |
259 | with another marked generation. | |
457f60fa AK |
260 | @end table |
261 | ||
bd53d327 | 262 | @node Emacs Info buffer |
457f60fa AK |
263 | @subsubsection ``Info'' buffer |
264 | ||
265 | The 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 | 270 | emacs, 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 |
293 | It is also possible to copy a button label (a link to an URL or a file) |
294 | by pressing @kbd{c} on a button. | |
295 | ||
457f60fa | 296 | |
bd53d327 | 297 | @node Emacs Configuration |
457f60fa AK |
298 | @subsection Configuration |
299 | ||
300 | There are many variables you can modify to change the appearance or | |
301 | behavior of Emacs user interface. Some of these variables are described | |
302 | in this section. Also you can use Custom Interface (@pxref{Easy | |
773bab64 AK |
303 | Customization,,, 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 | |
318 | If you have some special needs for starting a Guile process, you may set | |
319 | this 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 | |
326 | Has the same meaning as @code{--no-substitutes} option (@pxref{Invoking | |
327 | guix build}). | |
328 | ||
329 | @item guix-dry-run | |
330 | Has the same meaning as @code{--dry-run} option (@pxref{Invoking guix | |
331 | build}). | |
332 | ||
333 | @end table | |
334 | ||
bd53d327 | 335 | @node Emacs Buffer Names |
a54a237b AK |
336 | @subsubsection Buffer Names |
337 | ||
338 | Default names of ``guix.el'' buffers (``*Guix@tie{}@dots{}*'') may be | |
339 | changed 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 |
352 | By 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 | ||
356 | For example, if you want to display all types of results in a single | |
a54a237b AK |
357 | buffer (in such case you will probably use a history (@kbd{l}/@kbd{r}) |
358 | extensively), 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 | ||
375 | If 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 | |
380 | Parent keymap with general keys for ``list'' buffers. | |
381 | ||
382 | @item guix-package-list-mode-map | |
383 | Keymap with specific keys for ``package-list'' buffers. | |
384 | ||
a54a237b AK |
385 | @item guix-output-list-mode-map |
386 | Keymap with specific keys for ``output-list'' buffers. | |
387 | ||
457f60fa AK |
388 | @item guix-generation-list-mode-map |
389 | Keymap with specific keys for ``generation-list'' buffers. | |
390 | ||
391 | @item guix-info-mode-map | |
392 | Parent keymap with general keys for ``info'' buffers. | |
393 | ||
394 | @item guix-package-info-mode-map | |
395 | Keymap with specific keys for ``package-info'' buffers. | |
396 | ||
a54a237b AK |
397 | @item guix-output-info-mode-map |
398 | Keymap with specific keys for ``output-info'' buffers. | |
399 | ||
457f60fa AK |
400 | @item guix-generation-info-mode-map |
401 | Keymap with specific keys for ``generation-info'' buffers. | |
402 | ||
56149217 AK |
403 | @item guix-info-button-map |
404 | Keymap 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 | ||
411 | You can change almost any aspect of ``list'' / ``info'' buffers using | |
412 | the 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 | |
418 | Specify the columns, their names, what and how is displayed in ``list'' | |
419 | buffers. | |
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 | |
429 | Various settings for ``info'' buffers. | |
430 | ||
431 | @end table | |
9a130e19 AK |
432 | |
433 | ||
434 | @node Emacs Prettify | |
435 | @subsection Guix Prettify Mode | |
436 | ||
437 | Along with ``guix.el'', GNU@tie{}Guix comes with ``guix-prettify.el''. | |
438 | It provides a minor mode for abbreviating store file names by replacing | |
439 | hash 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 | ||
446 | Once you set up ``guix.el'' (@pxref{Emacs Initial Setup}), the following | |
447 | commands become available: | |
448 | ||
449 | @table @kbd | |
450 | ||
451 | @item M-x guix-prettify-mode | |
452 | Enable/disable prettifying for the current buffer. | |
453 | ||
454 | @item M-x global-guix-prettify-mode | |
455 | Enable/disable prettifying globally. | |
456 | ||
457 | @end table | |
458 | ||
459 | To automatically enable @code{guix-prettify-mode} globally on Emacs | |
460 | start, add the following line to your init file: | |
461 | ||
462 | @example | |
463 | (global-guix-prettify-mode) | |
464 | @end example | |
465 | ||
466 | If you want to enable it only for specific major modes, add it to the | |
467 | mode 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 |