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