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