Browse Source

Remove Emacs interface.

* emacs/guix-about.el: Remove file.
* emacs/guix-backend.el: Likewise.
* emacs/guix-base.el: Likewise.
* emacs/guix-buffer.el: Likewise.
* emacs/guix-build-log.el: Likewise.
* emacs/guix-command.el: Likewise.
* emacs/guix-config.el.in: Likewise.
* emacs/guix-devel.el: Likewise.
* emacs/guix-entry.el: Likewise.
* emacs/guix-external.el: Likewise.
* emacs/guix-geiser.el: Likewise.
* emacs/guix-guile.el: Likewise.
* emacs/guix-help-vars.el: Likewise.
* emacs/guix-helper.scm.in: Likewise.
* emacs/guix-history.el: Likewise.
* emacs/guix-hydra-build.el: Likewise.
* emacs/guix-hydra-jobset.el: Likewise.
* emacs/guix-hydra.el: Likewise.
* emacs/guix-info.el: Likewise.
* emacs/guix-init.el: Likewise.
* emacs/guix-license.el: Likewise.
* emacs/guix-list.el: Likewise.
* emacs/guix-location.el: Likewise.
* emacs/guix-main.scm: Likewise.
* emacs/guix-messages.el: Likewise.
* emacs/guix-pcomplete.el: Likewise.
* emacs/guix-popup.el: Likewise.
* emacs/guix-prettify.el: Likewise.
* emacs/guix-profiles.el: Likewise.
* emacs/guix-read.el: Likewise.
* emacs/guix-ui-generation.el: Likewise.
* emacs/guix-ui-license.el: Likewise.
* emacs/guix-ui-location.el: Likewise.
* emacs/guix-ui-package.el: Likewise.
* emacs/guix-ui-system-generation.el: Likewise.
* emacs/guix-ui.el: Likewise.
* emacs/guix-utils.el: Likewise.
* emacs/local.mk: Likewise.
* doc/emacs.texi: Likewise.
* doc/guix.texi: Remove cross-references to Emacs nodes.
(Package Management): Mention 'emacs-guix' package.
* doc/contributing.texi (The Perfect Setup): Remove the reference.
* doc/htmlxref.cnf: Add 'emacs-guix' URL.
* Makefile.am: Remove Emacs stuff.
* configure.ac: Likewise.
* gnu/packages/package-management.scm (guix-0.12.0)[native-inputs]:
Remove "emacs".
[propagated-inputs]: Remove "geiser" and "emacs-magit-popup".

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
gn-latest-20200428
Alex Kost 3 years ago
parent
commit
deb6276dda
No known key found for this signature in database GPG Key ID: 82460C082A0EE98F
45 changed files with 14 additions and 12012 deletions
  1. +0
    -8
      Makefile.am
  2. +0
    -10
      configure.ac
  3. +0
    -3
      doc/contributing.texi
  4. +0
    -881
      doc/emacs.texi
  5. +11
    -40
      doc/guix.texi
  6. +2
    -0
      doc/htmlxref.cnf
  7. +0
    -37
      emacs/guix-about.el
  8. +0
    -393
      emacs/guix-backend.el
  9. +0
    -377
      emacs/guix-base.el
  10. +0
    -624
      emacs/guix-buffer.el
  11. +0
    -381
      emacs/guix-build-log.el
  12. +0
    -830
      emacs/guix-command.el
  13. +0
    -44
      emacs/guix-config.el.in
  14. +0
    -382
      emacs/guix-devel.el
  15. +0
    -59
      emacs/guix-entry.el
  16. +0
    -88
      emacs/guix-external.el
  17. +0
    -126
      emacs/guix-geiser.el
  18. +0
    -98
      emacs/guix-guile.el
  19. +0
    -108
      emacs/guix-help-vars.el
  20. +0
    -65
      emacs/guix-helper.scm.in
  21. +0
    -92
      emacs/guix-history.el
  22. +0
    -362
      emacs/guix-hydra-build.el
  23. +0
    -162
      emacs/guix-hydra-jobset.el
  24. +0
    -367
      emacs/guix-hydra.el
  25. +0
    -482
      emacs/guix-info.el
  26. +0
    -3
      emacs/guix-init.el
  27. +0
    -65
      emacs/guix-license.el
  28. +0
    -585
      emacs/guix-list.el
  29. +0
    -79
      emacs/guix-location.el
  30. +0
    -1163
      emacs/guix-main.scm
  31. +0
    -247
      emacs/guix-messages.el
  32. +0
    -370
      emacs/guix-pcomplete.el
  33. +0
    -48
      emacs/guix-popup.el
  34. +0
    -210
      emacs/guix-prettify.el
  35. +0
    -77
      emacs/guix-profiles.el
  36. +0
    -147
      emacs/guix-read.el
  37. +0
    -456
      emacs/guix-ui-generation.el
  38. +0
    -150
      emacs/guix-ui-license.el
  39. +0
    -83
      emacs/guix-ui-location.el
  40. +0
    -1191
      emacs/guix-ui-package.el
  41. +0
    -105
      emacs/guix-ui-system-generation.el
  42. +0
    -323
      emacs/guix-ui.el
  43. +0
    -609
      emacs/guix-utils.el
  44. +0
    -77
      emacs/local.mk
  45. +1
    -5
      gnu/packages/package-management.scm

+ 0
- 8
Makefile.am View File

@@ -465,10 +465,6 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \
--with-nix-prefix="$(NIX_PREFIX)" \
--enable-daemon

dist_emacsui_DATA = emacs/guix-main.scm
nodist_emacsui_DATA = emacs/guix-helper.scm
include emacs/local.mk

# The self-contained tarball.
guix-binary.%.tar.xz:
$(AM_V_GEN)GUIX_PACKAGE_PATH= \
@@ -548,10 +544,6 @@ AM_V_DOT = $(AM_V_DOT_$(V))
AM_V_DOT_ = $(AM_V_DOT_$(AM_DEFAULT_VERBOSITY))
AM_V_DOT_0 = @echo " DOT " $@;

AM_V_EMACS = $(AM_V_EMACS_$(V))
AM_V_EMACS_ = $(AM_V_EMACS_$(AM_DEFAULT_VERBOSITY))
AM_V_EMACS_0 = @echo " EMACS " $@;

AM_V_HELP2MAN = $(AM_V_HELP2MAN_$(V))
AM_V_HELP2MAN_ = $(AM_V_HELP2MAN_$(AM_DEFAULT_VERBOSITY))
AM_V_HELP2MAN_0 = @echo " HELP2MAN" $@;

+ 0
- 10
configure.ac View File

@@ -237,14 +237,4 @@ AC_CONFIG_FILES([test-env:build-aux/test-env.in], [chmod +x test-env])
AC_CONFIG_FILES([pre-inst-env:build-aux/pre-inst-env.in],
[chmod +x pre-inst-env])

dnl Emacs interface.
AC_PATH_PROG([DOT_USER_PROGRAM], [dot], [dot])
AM_PATH_LISPDIR
AM_CONDITIONAL([HAVE_EMACS], [test "x$EMACS" != "xno"])

emacsuidir="${guilemoduledir}/guix/emacs"
AC_SUBST([emacsuidir])
AC_CONFIG_FILES([emacs/guix-config.el
emacs/guix-helper.scm])

AC_OUTPUT

+ 0
- 3
doc/contributing.texi View File

@@ -187,9 +187,6 @@ facilities to directly operate on the syntax tree, such as raising an
s-expression or wrapping it, swallowing or rejecting the following
s-expression, etc.

GNU Guix also comes with a minor mode that provides some additional
functionality for Scheme buffers (@pxref{Emacs Development}).


@node Coding Style
@section Coding Style


+ 0
- 881
doc/emacs.texi View File

@@ -1,881 +0,0 @@
@node Emacs Interface
@chapter Emacs Interface

@cindex Emacs
GNU Guix comes with several useful modules (known as ``guix.el'') for
GNU@tie{}Emacs which are intended to make an Emacs user interaction with
Guix convenient and fun.

@menu
* Initial Setup: Emacs Initial Setup. Preparing @file{~/.emacs}.
* Package Management: Emacs Package Management. Managing packages and generations.
* Licenses: Emacs Licenses. Interface for licenses of Guix packages.
* Package Source Locations: Emacs Package Locations. Interface for package location files.
* Popup Interface: Emacs Popup Interface. Magit-like interface for guix commands.
* Prettify Mode: Emacs Prettify. Abbreviating @file{/gnu/store/@dots{}} file names.
* Build Log Mode: Emacs Build Log. Highlighting Guix build logs.
* Completions: Emacs Completions. Completing @command{guix} shell command.
* Development: Emacs Development. Tools for Guix developers.
* Hydra: Emacs Hydra. Interface for Guix build farm.
@end menu


@node Emacs Initial Setup
@section Initial Setup

On the Guix System Distribution (@pxref{GNU Distribution}), ``guix.el''
is ready to use, provided Guix is installed system-wide, which is the
case by default. So if that is what you're using, you can happily skip
this section and read about the fun stuff.

If you're not yet a happy user of GuixSD, a little bit of setup is needed.
To be able to use ``guix.el'', you need to install the following
packages:

@itemize
@item
@uref{http://www.gnu.org/software/emacs/, GNU Emacs}, version 24.3 or
later;

@item
@uref{http://nongnu.org/geiser/, Geiser}, version 0.3 or later: it is
used for interacting with the Guile process.

@item
@uref{https://github.com/magit/magit/, magit-popup library}. You
already have this library if you use Magit 2.1.0 or later. This library
is an optional dependency---it is required only for @kbd{M-x@tie{}guix}
command (@pxref{Emacs Popup Interface}).

@end itemize

When it is done, ``guix.el'' may be configured by requiring
@code{guix-autoloads} file. If you install Guix in your user profile,
this auto-loading is done automatically by our Emacs package
(@pxref{Application Setup}), so a universal recipe for configuring
``guix.el'' is: @command{guix package -i guix}. If you do this, there
is no need to read further.

For the manual installation, you need to add the following code into
your init file (@pxref{Init File,,, emacs, The GNU Emacs Manual}):

@example
(add-to-list 'load-path "/path/to/directory-with-guix.el")
(require 'guix-autoloads nil t)
@end example

So the only thing you need to figure out is where the directory with
elisp files for Guix is placed. It depends on how you installed Guix:

@itemize
@item
If it was installed by a package manager of your distribution or by a
usual @code{./configure && make && make install} command sequence, then
elisp files are placed in a standard directory with Emacs packages
(usually it is @file{/usr/share/emacs/site-lisp/}), which is already in
@code{load-path}, so there is no need to add that directory there. Note
that if you don't update this installation periodically, you may get an
outdated Emacs code which does not work with the current Guile code of
Guix.

@item
If you used a binary installation method (@pxref{Binary Installation}),
then Guix is installed somewhere in the store, so the elisp files are
placed in @file{/gnu/store/@dots{}-guix-0.8.2/share/emacs/site-lisp/} or
alike. However it is not recommended to refer directly to a store
directory, as it may be garbage-collected one day. So a better choice
would be to install Guix using Guix itself with @command{guix package -i
guix}.

@item
If you did not install Guix at all and prefer a hacking way
(@pxref{Running Guix Before It Is Installed}), along with augmenting
@code{load-path} you need to set @code{guix-load-path} variable to the
same directory, so your final configuration will look like this:

@example
(let ((dir "/path/to/your-guix-git-tree/emacs"))
(add-to-list 'load-path dir)
(setq guix-load-path dir))
(require 'guix-autoloads nil t)
@end example
@end itemize


@node Emacs Package Management
@section Package Management

Once ``guix.el'' has been successfully configured, you should be able to
use a visual interface for routine package management tasks, pretty much
like the @command{guix package} command (@pxref{Invoking guix package}).
Specifically, it makes it easy to:

@itemize
@item browse and display packages and generations;
@item search, install, upgrade and remove packages;
@item display packages from previous generations;
@item do some other useful things.
@end itemize

@menu
* Commands: Emacs Commands. @kbd{M-x guix-@dots{}}
* General information: Emacs General info. Common for both interfaces.
* ``List'' buffer: Emacs List buffer. List-like interface.
* ``Info'' buffer: Emacs Info buffer. Help-like interface.
* Configuration: Emacs Configuration. Configuring the interface.
@end menu

@node Emacs Commands
@subsection Commands

All commands for displaying packages and generations use the current
profile, which can be changed with
@kbd{M-x@tie{}guix-set-current-profile}. Alternatively, if you call any
of these commands with prefix argument (@kbd{C-u}), you will be prompted
for a profile just for that command.

Commands for displaying packages:

@table @kbd

@item M-x guix-all-available-packages
@itemx M-x guix-newest-available-packages
Display all/newest available packages.

@item M-x guix-installed-packages
@itemx M-x guix-installed-user-packages
@itemx M-x guix-installed-system-packages
Display installed packages. As described above, @kbd{M-x
guix-installed-packages} uses an arbitrary profile that you can specify,
while the other commands display packages installed in 2 special
profiles: @file{~/.guix-profile} and @file{/run/current-system/profile}
(only on GuixSD).

@item M-x guix-obsolete-packages
Display obsolete packages (the packages that are installed in a profile
but cannot be found among available packages).

@item M-x guix-packages-by-name
Display package(s) with the specified name.

@item M-x guix-packages-by-license
Display package(s) with the specified license.

@item M-x guix-packages-by-location
Display package(s) located in the specified file. These files usually
have the following form: @file{gnu/packages/emacs.scm}, but don't type
them manually! Press @key{TAB} to complete the file name.

@item M-x guix-package-from-file
Display package that the code within the specified file evaluates to.
@xref{Invoking guix package, @code{--install-from-file}}, for an example
of what such a file may look like.

@item M-x guix-search-by-regexp
Search for packages by a specified regexp. By default ``name'',
``synopsis'' and ``description'' of the packages will be searched. This
can be changed by modifying @code{guix-package-search-params} variable.

@item M-x guix-search-by-name
Search for packages with names matching a specified regexp. This
command is the same as @code{guix-search-by-regexp}, except only a
package ``name'' is searched.

@end table

By default, these commands display each output on a separate line. If
you prefer to see a list of packages---i.e., a list with a package per
line, use the following setting:

@example
(setq guix-package-list-type 'package)
@end example

Commands for displaying generations:

@table @kbd

@item M-x guix-generations
List all the generations.

@item M-x guix-last-generations
List the @var{N} last generations. You will be prompted for the number
of generations.

@item M-x guix-generations-by-time
List generations matching time period. You will be prompted for the
period using Org mode time prompt based on Emacs calendar (@pxref{The
date/time prompt,,, org, The Org Manual}).

@end table

Analogously on GuixSD you can also display system generations:

@table @kbd
@item M-x guix-system-generations
@item M-x guix-last-system-generations
@item M-x guix-system-generations-by-time
@end table

You can also invoke the @command{guix pull} command (@pxref{Invoking
guix pull}) from Emacs using:

@table @kbd
@item M-x guix-pull
With @kbd{C-u}, make it verbose.
@end table

Once @command{guix pull} has succeeded, the Guix REPL is restarted. This
allows you to keep using the Emacs interface with the updated Guix.


@node Emacs General info
@subsection General information

The following keys are available for both ``list'' and ``info'' types of
buffers:

@table @kbd
@item l
@itemx r
Go backward/forward by the history of the displayed results (this
history is similar to the history of the Emacs @code{help-mode} or
@code{Info-mode}).

@item g
Revert current buffer: update information about the displayed
packages/generations and redisplay it.

@item R
Redisplay current buffer (without updating information).

@item M
Apply manifest to the current profile or to a specified profile, if
prefix argument is used. This has the same meaning as @code{--manifest}
option (@pxref{Invoking guix package}).

@item C-c C-z
@cindex REPL
@cindex read-eval-print loop
Go to the Guix REPL (@pxref{The REPL,,, geiser, Geiser User Manual}).

@item h
@itemx ?
Describe current mode to see all available bindings.

@end table

@emph{Hint:} If you need several ``list'' or ``info'' buffers, you can
simply @kbd{M-x clone-buffer} them, and each buffer will have its own
history.

@emph{Warning:} Name/version pairs cannot be used to identify packages
(because a name is not necessarily unique), so ``guix.el'' uses special
identifiers that live only during a guile session, so if the Guix REPL
was restarted, you may want to revert ``list'' buffer (by pressing
@kbd{g}).

@node Emacs List buffer
@subsection ``List'' buffer

An interface of a ``list'' buffer is similar to the interface provided
by ``package.el'' (@pxref{Package Menu,,, emacs, The GNU Emacs Manual}).

Default key bindings available for both ``package-list'' and
``generation-list'' buffers:

@table @kbd
@item m
Mark the current entry (with prefix, mark all entries).
@item u
Unmark the current entry (with prefix, unmark all entries).
@item @key{DEL}
Unmark backward.
@item S
Sort entries by a specified column.
@end table

A ``package-list'' buffer additionally provides the following bindings:

@table @kbd
@item @key{RET}
Describe marked packages (display available information in a
``package-info'' buffer).
@item i
Mark the current package for installation.
@item d
Mark the current package for deletion.
@item U
Mark the current package for upgrading.
@item ^
Mark all obsolete packages for upgrading.
@item e
Edit the definition of the current package (go to its location). This is
similar to @command{guix edit} command (@pxref{Invoking guix edit}), but
for opening a package recipe in the current Emacs instance.
@item x
Execute actions on the marked packages.
@item B
Display latest builds of the current package (@pxref{Emacs Hydra}).
@end table

A ``generation-list'' buffer additionally provides the following
bindings:

@table @kbd
@item @key{RET}
List packages installed in the current generation.
@item i
Describe marked generations (display available information in a
``generation-info'' buffer).
@item s
Switch profile to the current generation.
@item d
Mark the current generation for deletion (with prefix, mark all
generations).
@item x
Execute actions on the marked generations---i.e., delete generations.
@item e
Run Ediff (@pxref{Top,,, ediff, The Ediff Manual}) on package outputs
installed in the 2 marked generations. With prefix argument, run Ediff
on manifests of the marked generations.
@item D
@itemx =
Run Diff (@pxref{Diff Mode,,, emacs, The GNU Emacs Manual}) on package
outputs installed in the 2 marked generations. With prefix argument,
run Diff on manifests of the marked generations.
@item +
List package outputs added to the latest marked generation comparing
with another marked generation.
@item -
List package outputs removed from the latest marked generation comparing
with another marked generation.
@end table

@node Emacs Info buffer
@subsection ``Info'' buffer

The interface of an ``info'' buffer is similar to the interface of
@code{help-mode} (@pxref{Help Mode,,, emacs, The GNU Emacs Manual}).

``Info'' buffer contains some buttons (as usual you may use @key{TAB} /
@kbd{S-@key{TAB}} to move between buttons---@pxref{Mouse References,,,
emacs, The GNU Emacs Manual}) which can be used to:

@itemize @bullet
@item (in a ``package-info'' buffer)

@itemize @minus
@item install/remove a package;
@item jump to a package location;
@item browse home page of a package;
@item browse license URL;
@item describe packages from ``Inputs'' fields.
@end itemize

@item (in a ``generation-info'' buffer)

@itemize @minus
@item remove a generation;
@item switch to a generation;
@item list packages installed in a generation;
@item jump to a generation directory.
@end itemize

@end itemize

It is also possible to copy a button label (a link to an URL or a file)
by pressing @kbd{c} on a button.


@node Emacs Configuration
@subsection Configuration

There are many variables you can modify to change the appearance or
behavior of Emacs user interface. Some of these variables are described
in this section. Also you can use Custom Interface (@pxref{Easy
Customization,,, emacs, The GNU Emacs Manual}) to explore/set variables
(not all) and faces.

@menu
* Guile and Build Options: Emacs Build Options. Specifying how packages are built.
* Buffer Names: Emacs Buffer Names. Names of Guix buffers.
* Keymaps: Emacs Keymaps. Configuring key bindings.
* Appearance: Emacs Appearance. Settings for visual appearance.
@end menu

@node Emacs Build Options
@subsubsection Guile and Build Options

@table @code
@item guix-guile-program
If you have some special needs for starting a Guile process, you may set
this variable, for example:

@example
(setq guix-guile-program '("/bin/guile" "--no-auto-compile"))
@end example

@item guix-use-substitutes
If nil, has the same meaning as @code{--no-substitutes} option
(@pxref{Invoking guix build}).

@item guix-dry-run
If non-nil, has the same meaning as @code{--dry-run} option
(@pxref{Invoking guix build}).

@end table

@node Emacs Buffer Names
@subsubsection Buffer Names

Default names of ``guix.el'' buffers (``*Guix@tie{}@dots{}*'') may be
changed with the following variables:

@table @code
@item guix-package-list-buffer-name
@item guix-output-list-buffer-name
@item guix-generation-list-buffer-name
@item guix-package-info-buffer-name
@item guix-output-info-buffer-name
@item guix-generation-info-buffer-name
@item guix-repl-buffer-name
@item guix-internal-repl-buffer-name
@end table

By default, the name of a profile is also displayed in a ``list'' or
``info'' buffer name. To change this behavior, use
@code{guix-ui-buffer-name-function} variable.

For example, if you want to display all types of results in a single
buffer (in such case you will probably use a history (@kbd{l}/@kbd{r})
extensively), you may do it like this:

@example
(let ((name "Guix Universal"))
(setq
guix-package-list-buffer-name name
guix-output-list-buffer-name name
guix-generation-list-buffer-name name
guix-package-info-buffer-name name
guix-output-info-buffer-name name
guix-generation-info-buffer-name name))
@end example

@node Emacs Keymaps
@subsubsection Keymaps

If you want to change default key bindings, use the following keymaps
(@pxref{Init Rebinding,,, emacs, The GNU Emacs Manual}):

@table @code
@item guix-buffer-map
Parent keymap with general keys for any buffer type.

@item guix-ui-map
Parent keymap with general keys for buffers used for Guix package
management (for packages, outputs and generations).

@item guix-list-mode-map
Parent keymap with general keys for ``list'' buffers.

@item guix-package-list-mode-map
Keymap with specific keys for ``package-list'' buffers.

@item guix-output-list-mode-map
Keymap with specific keys for ``output-list'' buffers.

@item guix-generation-list-mode-map
Keymap with specific keys for ``generation-list'' buffers.

@item guix-info-mode-map
Parent keymap with general keys for ``info'' buffers.

@item guix-package-info-mode-map
Keymap with specific keys for ``package-info'' buffers.

@item guix-output-info-mode-map
Keymap with specific keys for ``output-info'' buffers.

@item guix-generation-info-mode-map
Keymap with specific keys for ``generation-info'' buffers.

@item guix-info-button-map
Keymap with keys available when a point is placed on a button.

@end table

@node Emacs Appearance
@subsubsection Appearance

You can change almost any aspect of ``list'' / ``info'' buffers using
the following variables (@dfn{ENTRY-TYPE} means @code{package},
@code{output} or @code{generation}):

@table @code
@item guix-ENTRY-TYPE-list-format
@itemx guix-ENTRY-TYPE-list-titles
Specify the columns, their names, what and how is displayed in ``list''
buffers.

@item guix-ENTRY-TYPE-info-format
@itemx guix-ENTRY-TYPE-info-titles
@itemx guix-info-ignore-empty-values
@itemx guix-info-param-title-format
@itemx guix-info-multiline-prefix
@itemx guix-info-indent
@itemx guix-info-fill
@itemx guix-info-delimiter
Various settings for ``info'' buffers.

@end table


@node Emacs Licenses
@section Licenses

If you want to browse the URL of a particular license, or to look at a
list of licenses, you may use the following commands:

@table @kbd

@item M-x guix-browse-license-url
Choose a license from a completion list to browse its URL using
@code{browse-url} function (@pxref{Browse-URL,,, emacs, The GNU Emacs
Manual}).

@item M-x guix-licenses
Display a list of available licenses. You can press @kbd{@key{RET}}
there to display packages with this license in the same way as @kbd{M-x
guix-packages-by-license} would do (@pxref{Emacs Commands}).

@item M-x guix-find-license-definition
Open @file{@dots{}/guix/licenses.scm} and move to the specified license.

@end table


@node Emacs Package Locations
@section Package Source Locations

As you know, package definitions are placed in Guile files, also known
as @dfn{package locations}. The following commands should help you not
get lost in these locations:

@table @kbd

@item M-x guix-locations
Display a list of package locations. You can press @key{RET} there to
display packages placed in the current location in the same way as
@kbd{M-x guix-packages-by-location} would do (@pxref{Emacs Commands}).
Note that when the point is on a location button, @key{RET} will open
this location file.

@item M-x guix-find-location
Open the given package definition source file (press @key{TAB} to choose
a location from a completion list).

@item M-x guix-edit
Find location of a specified package. This is an Emacs analog of
@command{guix edit} command (@pxref{Invoking guix edit}). As with
@kbd{M-x guix-packages-by-name}, you can press @key{TAB} to complete a
package name.

@end table

If you are contributing to Guix, you may find it useful for @kbd{M-x
guix-find-location} and @kbd{M-x guix-edit} to open locations from your
Git checkout. This can be done by setting @code{guix-directory}
variable. For example, after this:

@example
(setq guix-directory "~/src/guix")
@end example

@kbd{M-x guix-edit guix} opens
@file{~/src/guix/gnu/packages/package-management.scm} file.

Also you can use @kbd{C-u} prefix argument to specify a directory just
for the current @kbd{M-x guix-find-location} or @kbd{M-x guix-edit}
command.


@node Emacs Popup Interface
@section Popup Interface

If you ever used Magit, you know what ``popup interface'' is
(@pxref{Top,,, magit-popup, Magit-Popup User Manual}). Even if you are
not acquainted with Magit, there should be no worries as it is very
intuitive.

So @kbd{M-x@tie{}guix} command provides a top-level popup interface for
all available guix commands. When you select an option, you'll be
prompted for a value in the minibuffer. Many values have completions,
so don't hesitate to press @key{TAB} key. Multiple values (for example,
packages or lint checkers) should be separated by commas.

After specifying all options and switches for a command, you may choose
one of the available actions. The following default actions are
available for all commands:

@itemize

@item
Run the command in the Guix REPL. It is faster than running
@code{guix@tie{}@dots{}} command directly in shell, as there is no
need to run another guile process and to load required modules there.

@item
Run the command in a shell buffer. You can set
@code{guix-run-in-shell-function} variable to fine tune the shell buffer
you want to use.

@item
Add the command line to the kill ring (@pxref{Kill Ring,,, emacs, The
GNU Emacs Manual}).

@end itemize

Several commands (@command{guix graph}, @command{guix system shepherd-graph}
and @command{guix system extension-graph}) also have a ``View graph''
action, which allows you to view a generated graph using @command{dot}
command (specified by @code{guix-dot-program} variable). By default a
PNG file will be saved in @file{/tmp} directory and will be opened
directly in Emacs. This behavior may be changed with the following
variables:

@table @code

@item guix-find-file-function
Function used to open a generated graph. If you want to open a graph in
an external program, you can do it by modifying this variable---for
example, you can use a functionality provided by the Org Mode
(@pxref{Top,,, org, The Org Manual}):

@example
(setq guix-find-file-function 'org-open-file)
(add-to-list 'org-file-apps '("\\.png\\'" . "sxiv %s"))
@end example

@item guix-dot-default-arguments
Command line arguments to run @command{dot} command. If you change an
output format (for example, into @code{-Tpdf}), you also need to change
the next variable.

@item guix-dot-file-name-function
Function used to define a name of the generated graph file. Default
name is @file{/tmp/guix-emacs-graph-XXXXXX.png}.

@end table

So, for example, if you want to generate and open a PDF file in your
Emacs, you may change the settings like this:

@example
(defun my-guix-pdf-graph ()
"/tmp/my-current-guix-graph.pdf")

(setq guix-dot-default-arguments '("-Tpdf")
guix-dot-file-name-function 'my-guix-pdf-graph)
@end example


@node Emacs Prettify
@section Guix Prettify Mode

GNU@tie{}Guix also comes with ``guix-prettify.el''. It provides a minor
mode for abbreviating store file names by replacing hash sequences of
symbols with ``@dots{}'':

@example
/gnu/store/72f54nfp6g1hz873w8z3gfcah0h4nl9p-foo-0.1
@result{} /gnu/store/…-foo-0.1
@end example

Once you set up ``guix.el'' (@pxref{Emacs Initial Setup}), the following
commands become available:

@table @kbd

@item M-x guix-prettify-mode
Enable/disable prettifying for the current buffer.

@item M-x global-guix-prettify-mode
Enable/disable prettifying globally.

@end table

To automatically enable @code{guix-prettify-mode} globally on Emacs
start, add the following line to your init file:

@example
(global-guix-prettify-mode)
@end example

If you want to enable it only for specific major modes, add it to the
mode hooks (@pxref{Hooks,,, emacs, The GNU Emacs Manual}), for example:

@example
(add-hook 'shell-mode-hook 'guix-prettify-mode)
(add-hook 'dired-mode-hook 'guix-prettify-mode)
@end example


@node Emacs Build Log
@section Build Log Mode

GNU@tie{}Guix provides major and minor modes for highlighting build
logs. So when you have a file with a package build output---for
example, a file returned by @command{guix build --log-file @dots{}}
command (@pxref{Invoking guix build}), you may call @kbd{M-x
guix-build-log-mode} command in the buffer with this file. This major
mode highlights some lines specific to build output and provides the
following key bindings:

@table @kbd

@item M-n
Move to the next build phase.

@item M-p
Move to the previous build phase.

@item @key{TAB}
Toggle (show/hide) the body of the current build phase.

@item S-@key{TAB}
Toggle (show/hide) the bodies of all build phases.

@end table

There is also @kbd{M-x guix-build-log-minor-mode} which also provides
the same highlighting and the same key bindings as the major mode, but
prefixed with @kbd{C-c}. By default, this minor mode is enabled in
shell buffers (@pxref{Interactive Shell,,, emacs, The GNU Emacs
Manual}). If you don't like it, set
@code{guix-build-log-minor-mode-activate} to nil.


@node Emacs Completions
@section Shell Completions

Another feature that becomes available after configuring Emacs interface
(@pxref{Emacs Initial Setup}) is completing of @command{guix}
subcommands, options, packages and other things in @code{shell}
(@pxref{Interactive Shell,,, emacs, The GNU Emacs Manual}) and
@code{eshell} (@pxref{Top,,, eshell, Eshell: The Emacs Shell}).

It works the same way as other completions do. Just press @key{TAB}
when your intuition tells you.

And here are some examples, where pressing @key{TAB} may complete
something:

@itemize @w{}

@item @code{guix pa}@key{TAB}
@item @code{guix package -}@key{TAB}
@item @code{guix package --}@key{TAB}
@item @code{guix package -i gei}@key{TAB}
@item @code{guix build -L/tm}@key{TAB}
@item @code{guix build --sy}@key{TAB}
@item @code{guix build --system=i}@key{TAB}
@item @code{guix system rec}@key{TAB}
@item @code{guix lint --checkers=sy}@key{TAB}
@item @code{guix lint --checkers=synopsis,des}@key{TAB}

@end itemize


@node Emacs Development
@section Development

By default, when you open a Scheme file, @code{guix-devel-mode} will be
activated (if you don't want it, set @code{guix-devel-activate-mode} to
nil). This minor mode provides the following key bindings:

@table @kbd

@item C-c . k
Copy the name of the current Guile module into kill ring
(@code{guix-devel-copy-module-as-kill}).

@item C-c . u
Use the current Guile module. Often after opening a Scheme file, you
want to use a module it defines, so you switch to the Geiser REPL and
write @code{,use (some module)} there. You may just use this command
instead (@code{guix-devel-use-module}).

@item C-c . b
Build a package defined by the current variable definition. The
building process is run in the current Geiser REPL. If you modified the
current package definition, don't forget to reevaluate it before calling
this command---for example, with @kbd{C-M-x} (@pxref{To eval or not to
eval,,, geiser, Geiser User Manual})
(@code{guix-devel-build-package-definition}).

@item C-c . s
Build a source derivation of the package defined by the current variable
definition. This command has the same meaning as @code{guix build -S}
shell command (@pxref{Invoking guix build})
(@code{guix-devel-build-package-source}).

@item C-c . l
Lint (check) a package defined by the current variable definition
(@pxref{Invoking guix lint}) (@code{guix-devel-lint-package}).

@end table

Unluckily, there is a limitation related to long-running REPL commands.
When there is a running process in a Geiser REPL, you are not supposed
to evaluate anything in a scheme buffer, because this will ``freeze''
the REPL: it will stop producing any output (however, the evaluating
process will continue---you will just not see any progress anymore). Be
aware: even moving the point in a scheme buffer may ``break'' the REPL
if Autodoc (@pxref{Autodoc and friends,,, geiser, Geiser User Manual})
is enabled (which is the default).

So you have to postpone editing your scheme buffers until the running
evaluation will be finished in the REPL.

Alternatively, to avoid this limitation, you may just run another Geiser
REPL, and while something is being evaluated in the previous REPL, you
can continue editing a scheme file with the help of the current one.


@node Emacs Hydra
@section Hydra

The continuous integration server at @code{hydra.gnu.org} builds all
the distribution packages on the supported architectures and serves
them as substitutes (@pxref{Substitutes}). Continuous integration is
currently orchestrated by @uref{https://nixos.org/hydra/, Hydra}.

This section describes an Emacs interface to query Hydra to know the
build status of specific packages, discover recent and ongoing builds,
view build logs, and so on. This interface is mostly the same as the
``list''/``info'' interface for displaying packages and generations
(@pxref{Emacs Package Management}).

The following commands are available:

@table @kbd

@item M-x guix-hydra-latest-builds
Display latest failed or successful builds (you will be prompted for a
number of builds). With @kbd{C-u}, you will also be prompted for other
parameters (project, jobset, job and system).

@item M-x guix-hydra-queued-builds
Display scheduled or currently running builds (you will be prompted for
a number of builds).

@item M-x guix-hydra-jobsets
Display available jobsets (you will be prompted for a project).

@end table

In a list of builds you can press @kbd{L} key to display a build log of
the current build. Also both a list of builds and a list of jobsets
provide @kbd{B} key to display latest builds of the current job or
jobset (don't forget about @kbd{C-u}).

+ 11
- 40
doc/guix.texi View File

@@ -54,12 +54,6 @@ Documentation License''.
* guix environment: (guix)Invoking guix environment. Building development environments with Guix.
@end direntry

@dircategory Emacs
@direntry
* Guix user interface: (guix)Emacs Interface. Package management from the comfort of Emacs.
@end direntry


@titlepage
@title GNU Guix Reference Manual
@subtitle Using the GNU Guix Functional Package Manager
@@ -86,7 +80,6 @@ package management tool written for the GNU system.
* Introduction:: What is Guix about?
* Installation:: Installing Guix.
* Package Management:: Package installation, upgrade, etc.
* Emacs Interface:: Using Guix from Emacs.
* Programming Interface:: Using Guix in Scheme.
* Utilities:: Package management commands.
* GNU Distribution:: Software for your friendly GNU system.
@@ -124,19 +117,6 @@ Package Management
* Invoking guix pull:: Fetching the latest Guix and distribution.
* Invoking guix archive:: Exporting and importing store files.

Emacs Interface

* Initial Setup: Emacs Initial Setup. Preparing @file{~/.emacs}.
* Package Management: Emacs Package Management. Managing packages and generations.
* Licenses: Emacs Licenses. Interface for licenses of Guix packages.
* Package Source Locations: Emacs Package Locations. Interface for package location files.
* Popup Interface: Emacs Popup Interface. Magit-like interface for guix commands.
* Prettify Mode: Emacs Prettify. Abbreviating @file{/gnu/store/@dots{}} file names.
* Build Log Mode: Emacs Build Log. Highlighting Guix build logs.
* Completions: Emacs Completions. Completing @command{guix} shell command.
* Development: Emacs Development. Tools for Guix developers.
* Hydra: Emacs Hydra. Interface for Guix build farm.

Programming Interface

* Defining Packages:: Defining new packages.
@@ -278,8 +258,7 @@ assists with the creation and maintenance of software environments.
@cindex user interfaces
Guix provides a command-line package management interface
(@pxref{Invoking guix package}), a set of command-line utilities
(@pxref{Utilities}), a visual user interface in Emacs (@pxref{Emacs
Interface}), as well as Scheme programming interfaces
(@pxref{Utilities}), as well as Scheme programming interfaces
(@pxref{Programming Interface}).
@cindex build daemon
Its @dfn{build daemon} is responsible for building packages on behalf of
@@ -1414,10 +1393,14 @@ procedures or dependencies. Guix also goes beyond this obvious set of
features.

This chapter describes the main features of Guix, as well as the package
management tools it provides. Two user interfaces are provided for
routine package management tasks: A command-line interface described below
(@pxref{Invoking guix package, @code{guix package}}), as well as a visual user
interface in Emacs described in a subsequent chapter (@pxref{Emacs Interface}).
management tools it provides. Along with the command-line interface
described below (@pxref{Invoking guix package, @code{guix package}}),
you may also use Emacs Interface, after installing @code{emacs-guix}
package (run @kbd{M-x guix-help} command to start with it):

@example
guix package -i emacs-guix
@end example

@menu
* Features:: How Guix will make your life brighter.
@@ -1434,9 +1417,7 @@ interface in Emacs described in a subsequent chapter (@pxref{Emacs Interface}).

When using Guix, each package ends up in the @dfn{package store}, in its
own directory---something that resembles
@file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string
(note that Guix comes with an Emacs extension to shorten those file
names, @pxref{Emacs Prettify}.)
@file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.

Instead of referring to these directories, users have their own
@dfn{profile}, which points to the packages that they actually want to
@@ -1982,9 +1963,7 @@ also result from derivation builds, can be available as substitutes.

The @code{hydra.gnu.org} server is a front-end to a build farm that
builds packages from the GNU distribution continuously for some
architectures, and makes them available as substitutes (@pxref{Emacs
Hydra}, for information on how to query the continuous integration
server). This is the
architectures, and makes them available as substitutes. This is the
default source of substitutes; it can be overridden by passing the
@option{--substitute-urls} option either to @command{guix-daemon}
(@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
@@ -2509,9 +2488,6 @@ archive contents coming from possibly untrusted substitute servers.

@end table

@c *********************************************************************
@include emacs.texi

@c *********************************************************************
@node Programming Interface
@chapter Programming Interface
@@ -4923,11 +4899,6 @@ have created your own packages on @code{GUIX_PACKAGE_PATH}
recipes. Otherwise, you will be able to examine the read-only recipes
for packages currently in the store.

If you are using Emacs, note that the Emacs user interface provides the
@kbd{M-x guix-edit} command and a similar functionality in the ``package
info'' and ``package list'' buffers created by the @kbd{M-x
guix-search-by-name} and similar commands (@pxref{Emacs Commands}).


@node Invoking guix download
@section Invoking @command{guix download}


+ 2
- 0
doc/htmlxref.cnf View File

@@ -219,6 +219,8 @@ emacs node ${EMACS}/html_node/emacs/
easejs mono ${GS}/easejs/manual/easejs.html
easejs node ${GS}/easejs/manual/

emacs-guix mono https://notabug.org/alezost/emacs-guix

emacs-muse node ${GS}/emacs-muse/manual/muse.html
emacs-muse node ${GS}/emacs-muse/manual/html_node/



+ 0
- 37
emacs/guix-about.el View File

@@ -1,37 +0,0 @@
;;; guix-about.el --- Various info about Guix

;; Copyright © 2016 Alex Kost <alezost@gmail.com>

;; This file is part of GNU Guix.

;; GNU Guix is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public Location as published by
;; the Free Software Foundation, either version 3 of the Location, or
;; (at your option) any later version.

;; GNU Guix is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public Location for more details.

;; You should have received a copy of the GNU General Public Location
;; along with this program. If not, see <http://www.gnu.org/locations/>.

;;; Commentary:

;; This file provides the code to display various info about Guix (e.g., its
;; version).

;;; Code:

(require 'guix-config)

;;;###autoload
(defun guix-version ()
"Display Guix version in the echo area."
(interactive)
(message "%s %s" guix-config-name guix-config-version))

(provide 'guix-about)

;;; guix-about.el ends here

+ 0
- 393
emacs/guix-backend.el View File

@@ -1,393 +0,0 @@
;;; guix-backend.el --- Making and using Guix REPL

;; Copyright © 2014, 2015, 2016 Alex Kost <alezost@gmail.com>

;; This file is part of GNU Guix.

;; GNU Guix is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Guix is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; This file provides the code for interacting with Guile using Guix REPL
;; (Geiser REPL with some guix-specific additions).

;; By default (if `guix-use-guile-server' is non-nil) 2 Guix REPLs are
;; started. The main one (with "guile --listen" process) is used for
;; "interacting" with a user - for showing a progress of
;; installing/deleting Guix packages. The second (internal) REPL is
;; used for synchronous evaluating, e.g. when information about
;; packages/generations should be received for a list/info buffer.
;;
;; This "2 REPLs concept" makes it possible to have a running process of
;; installing/deleting packages and to continue to search/list/get info
;; about other packages at the same time. If you prefer to use a single
;; Guix REPL, do not try to receive any information while there is a
;; running code in the REPL (see
;; <https://github.com/jaor/geiser/issues/28>).
;;
;; Guix REPLs (unlike the usual Geiser REPLs) are not added to
;; `geiser-repl--repls' variable, and thus cannot be used for evaluating
;; while editing scm-files. The only purpose of Guix REPLs is to be an
;; intermediate between "Guix/Guile level" and "Emacs interface level".
;; That being said you can still want to use a Guix REPL while hacking
;; auxiliary scheme-files for "guix.el". You can just use
;; `geiser-connect-local' command with `guix-repl-current-socket' to
;; have a usual Geiser REPL with all stuff defined by "guix.el" package.

;;; Code:

(require 'geiser-mode)
(require 'geiser-guile)
(require 'guix-geiser)
(require 'guix-config)
(require 'guix-external)
(require 'guix-emacs)
(require 'guix-profiles)

(defvar guix-load-path guix-config-emacs-interface-directory
"Directory with scheme files for \"guix.el\" package.")

(defvar guix-helper-file
(expand-file-name "guix-helper.scm" guix-load-path)
"Auxiliary scheme file for loading.")

;;; REPL

(defgroup guix-repl nil
"Settings for Guix REPLs."
:prefix "guix-repl-"
:group 'guix)

(defcustom guix-repl-startup-time 30000
"Time, in milliseconds, to wait for Guix REPL to startup.
Same as `geiser-repl-startup-time' but is used for Guix REPL.
If you have a slow system, try to increase this time."
:type 'integer
:group 'guix-repl)

(defcustom guix-repl-buffer-name "*Guix REPL*"
"Default name of a Geiser REPL buffer used for Guix."
:type 'string
:group 'guix-repl)

(defcustom guix-after-start-repl-hook '(guix-set-directory)
"Hook called after Guix REPL is started."
:type 'hook
:group 'guix-repl)

(defcustom guix-use-guile-server t
"If non-nil, start guile with '--listen' argument.
This allows to receive information about packages using an additional
REPL while some packages are being installed/removed in the main REPL."
:type 'boolean
:group 'guix-repl)

(defcustom guix-repl-socket-file-name-function
#'guix-repl-socket-file-name
"Function used to define a socket file name used by Guix REPL.
The function is called without arguments."
:type '(choice (function-item guix-repl-socket-file-name)
(function :tag "Other function"))
:group 'guix-repl)

(defcustom guix-emacs-activate-after-operation t
"Activate Emacs packages after installing.
If nil, do not load autoloads of the Emacs packages after
they are successfully installed."
:type 'boolean
:group 'guix-repl)

(defvar guix-repl-current-socket nil
"Name of a socket file used by the current Guix REPL.")

(defvar guix-repl-buffer nil
"Main Geiser REPL buffer used for communicating with Guix.
This REPL is used for processing package actions and for
receiving information if `guix-use-guile-server' is nil.")

(defvar guix-internal-repl-buffer nil
"Additional Geiser REPL buffer used for communicating with Guix.
This REPL is used for receiving information only if
`guix-use-guile-server' is non-nil.")

(defvar guix-internal-repl-buffer-name "*Guix Internal REPL*"
"Default name of an internal Guix REPL buffer.")

(defvar guix-before-repl-operation-hook nil
"Hook run before executing an operation in Guix REPL.")

(defvar guix-after-repl-operation-hook
'(guix-repl-autoload-emacs-packages-maybe
guix-repl-operation-success-message)
"Hook run after executing successful operation in Guix REPL.")

(defvar guix-repl-operation-p nil
"Non-nil, if current operation is performed by `guix-eval-in-repl'.
This internal variable is used to distinguish Guix operations
from operations performed in Guix REPL by a user.")

(defvar guix-repl-operation-type nil
"Type of the current operation performed by `guix-eval-in-repl'.
This internal variable is used to define what actions should be
executed after the current operation succeeds.
See `guix-eval-in-repl' for details.")

(defun guix-repl-autoload-emacs-packages-maybe ()
"Load autoloads for Emacs packages if needed.
See `guix-emacs-activate-after-operation' for details."
(and guix-emacs-activate-after-operation
;; FIXME Since a user can work with a non-current profile (using
;; C-u before `guix-search-by-name' and other commands), emacs
;; packages can be installed to another profile, and the
;; following code will not work (i.e., the autoloads for this
;; profile will not be loaded).
(guix-emacs-autoload-packages guix-current-profile)))

(defun guix-repl-operation-success-message ()
"Message telling about successful Guix operation."
(message "Guix operation has been performed."))

(defun guix-get-guile-program (&optional socket)
"Return a value suitable for `geiser-guile-binary'."
(if (null socket)
guix-guile-program
(append (if (listp guix-guile-program)
guix-guile-program
(list guix-guile-program))
(list (concat "--listen=" socket)))))

(defun guix-repl-socket-file-name ()
"Return a name of a socket file used by Guix REPL."
(make-temp-name
(concat (file-name-as-directory temporary-file-directory)
"guix-repl-")))

(defun guix-repl-delete-socket-maybe ()
"Delete `guix-repl-current-socket' file if it exists."
(and guix-repl-current-socket
(file-exists-p guix-repl-current-socket)
(delete-file guix-repl-current-socket)))

(add-hook 'kill-emacs-hook 'guix-repl-delete-socket-maybe)

(defun guix-start-process-maybe (&optional start-msg end-msg)
"Start Geiser REPL configured for Guix if needed.
START-MSG and END-MSG are strings displayed in the minibuffer in
the beginning and in the end of the starting process. If nil,
display default messages."
(guix-start-repl-maybe nil
(or start-msg "Starting Guix REPL ...")
(or end-msg "Guix REPL has been started."))
(if guix-use-guile-server
(guix-start-repl-maybe 'internal)
(setq guix-internal-repl-buffer guix-repl-buffer)))

(defun guix-start-repl-maybe (&optional internal start-msg end-msg)
"Start Guix REPL if needed.
If INTERNAL is non-nil, start an internal REPL.

START-MSG and END-MSG are strings displayed in the minibuffer in
the beginning and in the end of the process. If nil, do not
display messages."
(let* ((repl-var (guix-get-repl-buffer-variable internal))
(repl (symbol-value repl-var)))
(unless (and (buffer-live-p repl)
(get-buffer-process repl))
(and start-msg (message start-msg))
(setq guix-repl-operation-p nil)
(unless internal
;; Guile leaves socket file after exit, so remove it if it
;; exists (after the REPL restart).
(guix-repl-delete-socket-maybe)
(setq guix-repl-current-socket
(and guix-use-guile-server
(or guix-repl-current-socket
(funcall guix-repl-socket-file-name-function)))))
(let ((geiser-guile-binary (guix-get-guile-program
(unless internal
guix-repl-current-socket)))
(geiser-guile-init-file (unless internal guix-helper-file))
(repl (get-buffer-create
(guix-get-repl-buffer-name internal))))
(guix-start-repl repl (and internal guix-repl-current-socket))
(set repl-var repl)
(and end-msg (message end-msg))
(unless internal
(run-hooks 'guix-after-start-repl-hook))))))

(defun guix-start-repl (buffer &optional address)
"Start Guix REPL in BUFFER.
If ADDRESS is non-nil, connect to a remote guile process using
this address (it should be defined by
`geiser-repl--read-address')."
;; A mix of the code from `geiser-repl--start-repl' and
;; `geiser-repl--to-repl-buffer'.
(let ((impl 'guile)
(geiser-guile-load-path (cons (expand-file-name guix-load-path)
geiser-guile-load-path))
(geiser-repl-startup-time guix-repl-startup-time))
(with-current-buffer buffer
(geiser-repl-mode)
(geiser-impl--set-buffer-implementation impl)
(geiser-repl--autodoc-mode -1)
(goto-char (point-max))
(let ((prompt (geiser-con--combined-prompt
geiser-guile--prompt-regexp
geiser-guile--debugger-prompt-regexp)))
(geiser-repl--save-remote-data address)
(geiser-repl--start-scheme impl address prompt)
(geiser-repl--quit-setup)
(geiser-repl--history-setup)
(setq-local geiser-repl--repls (list buffer))
(geiser-repl--set-this-buffer-repl buffer)
(setq geiser-repl--connection
(geiser-con--make-connection
(get-buffer-process (current-buffer))
geiser-guile--prompt-regexp
geiser-guile--debugger-prompt-regexp))
(geiser-repl--startup impl address)
(geiser-repl--autodoc-mode 1)
(geiser-company--setup geiser-repl-company-p)
(add-hook 'comint-output-filter-functions
'guix-repl-output-filter
nil t)
(set-process-query-on-exit-flag
(get-buffer-process (current-buffer))
geiser-repl-query-on-kill-p)))))

(defun guix-repl-output-filter (str)
"Filter function suitable for `comint-output-filter-functions'.
This is a replacement for `geiser-repl--output-filter'."
(cond
((string-match-p geiser-guile--prompt-regexp str)
(geiser-autodoc--disinhibit-autodoc)
(when guix-repl-operation-p
(setq guix-repl-operation-p nil)
(run-hooks 'guix-after-repl-operation-hook)
;; Run hooks specific to the current operation type.
(when guix-repl-operation-type
(let ((type-hook (intern
(concat "guix-after-"
(symbol-name guix-repl-operation-type)
"-hook"))))
(setq guix-repl-operation-type nil)
(and (boundp type-hook)
(run-hooks type-hook))))))
((string-match geiser-guile--debugger-prompt-regexp str)
(setq guix-repl-operation-p nil)
(geiser-con--connection-set-debugging geiser-repl--connection
(match-beginning 0))
(geiser-autodoc--disinhibit-autodoc))))

(defun guix-repl-exit (&optional internal no-wait)
"Exit the current Guix REPL.
If INTERNAL is non-nil, exit the internal REPL.
If NO-WAIT is non-nil, do not wait for the REPL process to exit:
send a kill signal to it and return immediately."
(let ((repl (symbol-value (guix-get-repl-buffer-variable internal))))
(when (get-buffer-process repl)
(with-current-buffer repl
(geiser-con--connection-deactivate geiser-repl--connection t)
(comint-kill-subjob)
(unless no-wait
(while (get-buffer-process repl)
(sleep-for 0.1)))))))

(defun guix-get-repl-buffer (&optional internal)
"Return Guix REPL buffer; start REPL if needed.
If INTERNAL is non-nil, return an additional internal REPL."
(guix-start-process-maybe)
(let ((repl (symbol-value (guix-get-repl-buffer-variable internal))))
;; If a new Geiser REPL is started, `geiser-repl--repl' variable may
;; be set to the new value in a Guix REPL, so set it back to a
;; proper value here.
(with-current-buffer repl
(geiser-repl--set-this-buffer-repl repl))
repl))

(defun guix-get-repl-buffer-variable (&optional internal)
"Return the name of a variable with a REPL buffer."
(if internal
'guix-internal-repl-buffer
'guix-repl-buffer))

(defun guix-get-repl-buffer-name (&optional internal)
"Return the name of a REPL buffer."
(if internal
guix-internal-repl-buffer-name
guix-repl-buffer-name))

(defun guix-switch-to-repl (&optional internal)
"Switch to Guix REPL.
If INTERNAL is non-nil (interactively with prefix), switch to the
additional internal REPL if it exists."
(interactive "P")
(geiser-repl--switch-to-buffer (guix-get-repl-buffer internal)))

;;; Guix directory

(defvar guix-directory nil
"Default directory with Guix source.
If it is not set by a user, it is set after starting Guile REPL.
This directory is used to define package locations.")

(defun guix-read-directory ()
"Return `guix-directory' or prompt for it.
This function is intended for using in `interactive' forms."
(if current-prefix-arg
(read-directory-name "Directory with Guix modules: "
guix-directory)
guix-directory))

(defun guix-set-directory ()
"Set `guix-directory' if needed."
(or guix-directory
(setq guix-directory
(guix-eval-read "%guix-dir"))))

;;; Evaluating expressions

(defvar guix-operation-buffer nil
"Buffer from which the latest Guix operation was performed.")

(defun guix-eval (str)
"Evaluate STR with guile expression using Guix REPL.
See `guix-geiser-eval' for details."
(guix-geiser-eval str (guix-get-repl-buffer 'internal)))

(defun guix-eval-read (str)
"Evaluate STR with guile expression using Guix REPL.
See `guix-geiser-eval-read' for details."
(guix-geiser-eval-read str (guix-get-repl-buffer 'internal)))

(defun guix-eval-in-repl (str &optional operation-buffer operation-type)
"Switch to Guix REPL and evaluate STR with guile expression there.
If OPERATION-BUFFER is non-nil, it should be a buffer from which
the current operation was performed.

If OPERATION-TYPE is non-nil, it should be a symbol. After
successful executing of the current operation,
`guix-after-OPERATION-TYPE-hook' is called."
(run-hooks 'guix-before-repl-operation-hook)
(setq guix-repl-operation-p t
guix-repl-operation-type operation-type
guix-operation-buffer operation-buffer)
(guix-geiser-eval-in-repl str (guix-get-repl-buffer)))

(provide 'guix-backend)

;;; guix-backend.el ends here

+ 0
- 377
emacs/guix-base.el View File

@@ -1,377 +0,0 @@
;;; guix-base.el --- Common definitions -*- lexical-binding: t -*-

;; Copyright © 2014, 2015, 2016 Alex Kost <alezost@gmail.com>

;; This file is part of GNU Guix.

;; GNU Guix is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Guix is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; This file provides some base and common definitions for guix.el
;; package.

;;; Code:

(require 'cl-lib)
(require 'guix-backend)
(require 'guix-guile)
(require 'guix-read)
(require 'guix-utils)
(require 'guix-ui)
(require 'guix-profiles)

(defgroup guix nil
"Settings for Guix package manager and friends."
:prefix "guix-"
:group 'external)

(defgroup guix-faces nil
"Guix faces."
:group 'guix
:group 'faces)

(defun guix-package-name-specification (name version &optional output)
"Return Guix package specification by its NAME, VERSION and OUTPUT."
(concat name "@" version
(when output (concat ":" output))))

;;; Location of profiles and manifests

(defun guix-generation-file (profile generation)
"Return the file name of a PROFILE's GENERATION."
(format "%s-%s-link" profile generation))

(defun guix-packages-profile (profile &optional generation system?)
"Return a directory where packages are installed for the
PROFILE's GENERATION.

If SYSTEM? is non-nil, then PROFILE is considered to be a system
profile. Unlike usual profiles, for a system profile, packages
are placed in 'profile' subdirectory."
(let ((profile (if generation
(guix-generation-file profile generation)
profile)))
(if system?
(expand-file-name "profile" profile)
profile)))

(defun guix-manifest-file (profile &optional generation system?)
"Return the file name of a PROFILE's manifest.
See `guix-packages-profile'."
(expand-file-name "manifest"
(guix-packages-profile profile generation system?)))

;;; Actions on packages and generations

(defface guix-operation-option-key
'((t :inherit font-lock-warning-face))
"Face used for the keys of operation options."
:group 'guix-faces)

(defcustom guix-operation-confirm t
"If nil, do not prompt to confirm an operation."
:type 'boolean
:group 'guix)

(defcustom guix-use-substitutes t
"If non-nil, use substitutes for the Guix packages."
:type 'boolean
:group 'guix)

(defvar guix-dry-run nil
"If non-nil, do not perform the real actions, just simulate.")

(defvar guix-temp-buffer-name " *Guix temp*"
"Name of a buffer used for displaying info before executing operation.")

(defvar guix-operation-option-true-string "yes"
"String displayed in the mode-line when operation option is t.")

(defvar guix-operation-option-false-string "no "
"String displayed in the mode-line when operation option is nil.")

(defvar guix-operation-option-separator " | "
"String used in the mode-line to separate operation options.")

(defvar guix-operation-options
'((?s "substitutes" guix-use-substitutes)
(?d "dry-run" guix-dry-run))
"List of available operation options.
Each element of the list has a form:

(KEY NAME VARIABLE)

KEY is a character that may be pressed during confirmation to
toggle the option.
NAME is a string displayed in the mode-line.
VARIABLE is a name of an option variable.")

(defun guix-operation-option-by-key (key)
"Return operation option by KEY (character)."
(assq key guix-operation-options))

(defun guix-operation-option-key (option)
"Return key (character) of the operation OPTION."
(car option))

(defun guix-operation-option-name (option)
"Return name of the operation OPTION."
(nth 1 option))

(defun guix-operation-option-variable (option)
"Return name of the variable of the operation OPTION."
(nth 2 option))

(defun guix-operation-option-value (option)
"Return boolean value of the operation OPTION."
(symbol-value (guix-operation-option-variable option)))

(defun guix-operation-option-string-value (option)
"Convert boolean value of the operation OPTION to string and return it."
(if (guix-operation-option-value option)
guix-operation-option-true-string
guix-operation-option-false-string))

(defun guix-operation-prompt (&optional prompt)
"Prompt a user for continuing the current operation.
Return non-nil, if the operation should be continued; nil otherwise.
Ask a user with PROMPT for continuing an operation."
(let* ((option-keys (mapcar #'guix-operation-option-key
guix-operation-options))
(keys (append '(?y ?n) option-keys))
(prompt (concat (propertize (or prompt "Continue operation?")
'face 'minibuffer-prompt)
" ("
(mapconcat
(lambda (key)
(propertize (string key)
'face 'guix-operation-option-key))
keys
", ")
") ")))
(let ((mode-line mode-line-format))
(prog1 (guix-operation-prompt-1 prompt keys)
(setq mode-line-format mode-line)
;; Clear the minibuffer after prompting.
(message "")))))

(defun guix-operation-prompt-1 (prompt keys)
"This function is internal for `guix-operation-prompt'."
(guix-operation-set-mode-line)
(let ((key (read-char-choice prompt (cons ?\C-g keys) t)))
(cl-case key
(?y t)
((?n ?\C-g) nil)
(t (let* ((option (guix-operation-option-by-key key))
(var (guix-operation-option-variable option)))
(set var (not (symbol-value var)))
(guix-operation-prompt-1 prompt keys))))))

(defun guix-operation-set-mode-line ()
"Display operation options in the mode-line of the current buffer."
(setq mode-line-format
(concat (propertize " Options: "
'face 'mode-line-buffer-id)
(mapconcat
(lambda (option)
(let ((key (guix-operation-option-key option))
(name (guix-operation-option-name option))
(val (guix-operation-option-string-value option)))
(concat name
" ("
(propertize (string key)
'face 'guix-operation-option-key)
"): " val)))
guix-operation-options
guix-operation-option-separator)))
(force-mode-line-update))

(defun guix-package-source-path (package-id)
"Return a store file path to a source of a package PACKAGE-ID."
(message "Calculating the source derivation ...")
(guix-eval-read
(guix-make-guile-expression
'package-source-path package-id)))

(defun guix-package-store-path (package-id)
"Return a list of store directories of outputs of package PACKAGE-ID."
(message "Calculating the package derivation ...")
(guix-eval-read
(guix-make-guile-expression
'package-store-path package-id)))

(defvar guix-after-source-download-hook nil
"Hook run after successful performing a 'source-download' operation.")

(defun guix-package-source-build-derivation (package-id &optional prompt)
"Build source derivation of a package PACKAGE-ID.
Ask a user with PROMPT for continuing an operation."
(when (or (not guix-operation-confirm)
(guix-operation-prompt (or prompt
"Build the source derivation?")))
(guix-eval-in-repl
(guix-make-guile-expression
'package-source-build-derivation
package-id
:use-substitutes? (or guix-use-substitutes 'f)
:dry-run? (or guix-dry-run 'f))
nil 'source-download)))

(defun guix-build-package (package-id &optional prompt)
"Build package with PACKAGE-ID.
Ask a user with PROMPT for continuing the build operation."
(when (or (not guix-operation-confirm)
(guix-operation-prompt (or prompt "Build package?")))
(guix-eval-in-repl
(format (concat ",run-in-store "
"(build-package (package-by-id %d)"
" #:use-substitutes? %s"
" #:dry-run? %s)")
package-id
(guix-guile-boolean guix-use-substitutes)
(guix-guile-boolean guix-dry-run)))))

;;;###autoload
(defun guix-apply-manifest (profile file &optional operation-buffer)
"Apply manifest from FILE to PROFILE.
This function has the same meaning as 'guix package --manifest' command.
See Info node `(guix) Invoking guix package' for details.

Interactively, use the current profile and prompt for manifest
FILE. With a prefix argument, also prompt for PROFILE."
(interactive
(let* ((current-profile (guix-ui-current-profile))
(profile (if current-prefix-arg
(guix-profile-prompt)
(or current-profile guix-current-profile)))
(file (read-file-name "File with manifest: "))
(buffer (and current-profile (current-buffer))))
(list profile file buffer)))
(when (or (not guix-operation-confirm)
(y-or-n-p (format "Apply manifest from '%s' to profile '%s'? "
file profile)))
(guix-eval-in-repl
(guix-make-guile-expression
'guix-command
"package"
(concat "--profile=" (expand-file-name profile))
(concat "--manifest=" (expand-file-name file)))
operation-buffer)))

;;; Executing guix commands

(defcustom guix-run-in-shell-function #'guix-run-in-shell
"Function used to run guix command.
The function is called with a single argument - a command line string."
:type '(choice (function-item guix-run-in-shell)
(function-item guix-run-in-eshell)
(function :tag "Other function"))
:group 'guix)

(defcustom guix-shell-buffer-name "*shell*"
"Default name of a shell buffer used for running guix commands."
:type 'string
:group 'guix)

(declare-function comint-send-input "comint" t)

(defun guix-run-in-shell (string)
"Run command line STRING in `guix-shell-buffer-name' buffer."
(shell guix-shell-buffer-name)
(goto-char (point-max))
(insert string)
(comint-send-input))

(declare-function eshell-send-input "esh-mode" t)

(defun guix-run-in-eshell (string)
"Run command line STRING in eshell buffer."
(eshell)
(goto-char (point-max))
(insert string)
(eshell-send-input))

(defun guix-run-command-in-shell (args)
"Execute 'guix ARGS ...' command in a shell buffer."
(funcall guix-run-in-shell-function
(guix-command-string args)))

(defun guix-run-command-in-repl (args)
"Execute 'guix ARGS ...' command in Guix REPL."
(guix-eval-in-repl
(apply #'guix-make-guile-expression
'guix-command args)))

(defun guix-command-output (args)
"Return string with 'guix ARGS ...' output."
(cl-multiple-value-bind (output error)
(guix-eval (apply #'guix-make-guile-expression
'guix-command-output args))
;; Remove trailing new space from the error string.
(message (replace-regexp-in-string "\n\\'" "" (read error)))
(read output)))

(defun guix-help-string (&optional commands)
"Return string with 'guix COMMANDS ... --help' output."
(guix-eval-read
(apply #'guix-make-guile-expression
'help-string commands)))

;;; Pull

(defcustom guix-update-after-pull t
"If non-nil, update Guix buffers after performing \\[guix-pull]."
:type 'boolean
:group 'guix)

(defvar guix-after-pull-hook
'(guix-restart-repl-after-pull guix-update-buffers-maybe-after-pull)
"Hook run after successful performing `guix-pull' operation.")

(defun guix-restart-repl-after-pull ()
"Restart Guix REPL after `guix-pull' operation."
(guix-repl-exit)
(guix-start-process-maybe
"Restarting Guix REPL after pull operation ..."))

(defun guix-update-buffers-maybe-after-pull ()
"Update buffers depending on `guix-update-after-pull'."
(when guix-update-after-pull
(mapc #'guix-ui-update-buffer
;; No need to update "generation" buffers.
(guix-ui-buffers '(guix-package-list-mode
guix-package-info-mode
guix-output-list-mode
guix-output-info-mode)))
(message "Guix buffers have been updated.")))

;;;###autoload
(defun guix-pull (&optional verbose)
"Run Guix pull operation.
If VERBOSE is non-nil (with prefix argument), produce verbose output."
(interactive "P")
(let ((args (and verbose '("--verbose"))))
(guix-eval-in-repl
(apply #'guix-make-guile-expression
'guix-command "pull" args)
nil 'pull)))

(provide 'guix-base)

;;; guix-base.el ends here

+ 0
- 624
emacs/guix-buffer.el View File

@@ -1,624 +0,0 @@
;;; guix-buffer.el --- Buffer interface for displaying data -*- lexical-binding: t -*-

;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>

;; This file is part of GNU Guix.

;; GNU Guix is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Guix is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; This file provides a general 'buffer' interface for displaying an
;; arbitrary data.

;;; Code:

(require 'cl-lib)
(require 'guix-history)
(require 'guix-utils)

(defvar guix-buffer-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "l") 'guix-history-back)
(define-key map (kbd "r") 'guix-history-forward)
(define-key map (kbd "g") 'revert-buffer)
(define-key map (kbd "R") 'guix-buffer-redisplay)
map)
"Parent keymap for Guix buffer modes.")

;;; Buffer item

(cl-defstruct (guix-buffer-item
(:constructor nil)
(:constructor guix-buffer-make-item
(entries buffer-type entry-type args))
(:copier nil))
entries buffer-type entry-type args)

(defvar-local guix-buffer-item nil
"Data (structure) for the current Guix buffer.
The structure consists of the following elements:

- `entries': list of the currently displayed entries.

Each element of the list is an alist with an entry data of the
following form:

((PARAM . VAL) ...)

PARAM is a name of the entry parameter.
VAL is a value of this parameter.

- `entry-type': type of the currently displayed entries.

- `buffer-type': type of the current buffer.

- `args': search arguments used to get the current entries.")
(put 'guix-buffer-item 'permanent-local t)

(defmacro guix-buffer-with-item (item &rest body)
"Evaluate BODY using buffer ITEM.
The following local variables are available inside BODY:
`%entries', `%buffer-type', `%entry-type', `%args'.
See `guix-buffer-item' for details."
(declare (indent 1) (debug t))
(let ((item-var (make-symbol "item")))
`(let ((,item-var ,item))
(let ((%entries (guix-buffer-item-entries ,item-var))
(%buffer-type (guix-buffer-item-buffer-type ,item-var))
(%entry-type (guix-buffer-item-entry-type ,item-var))
(%args (guix-buffer-item-args ,item-var)))
,@body))))

(defmacro guix-buffer-with-current-item (&rest body)
"Evaluate BODY using `guix-buffer-item'.
See `guix-buffer-with-item' for details."
(declare (indent 0) (debug t))
`(guix-buffer-with-item guix-buffer-item
,@body))

(defmacro guix-buffer-define-current-item-accessor (name)
"Define `guix-buffer-current-NAME' function to access NAME
element of `guix-buffer-item' structure.
NAME should be a symbol."
(let* ((name-str (symbol-name name))
(accessor (intern (concat "guix-buffer-item-" name-str)))
(fun-name (intern (concat "guix-buffer-current-" name-str)))
(doc (format "\
Return '%s' of the current Guix buffer.
See `guix-buffer-item' for details."
name-str)))
`(defun ,fun-name ()
,doc
(and guix-buffer-item
(,accessor guix-buffer-item)))))

(defmacro guix-buffer-define-current-item-accessors (&rest names)
"Define `guix-buffer-current-NAME' functions for NAMES.
See `guix-buffer-define-current-item-accessor' for details."
`(progn
,@(mapcar (lambda (name)
`(guix-buffer-define-current-item-accessor ,name))
names)))

(guix-buffer-define-current-item-accessors
entries entry-type buffer-type args)

(defmacro guix-buffer-define-current-args-accessor (n prefix name)
"Define `PREFIX-NAME' function to access Nth element of 'args'
field of `guix-buffer-item' structure.
PREFIX and NAME should be strings."
(let ((fun-name (intern (concat prefix "-" name)))
(doc (format "\
Return '%s' of the current Guix buffer.
'%s' is the element number %d in 'args' of `guix-buffer-item'."
name name n)))
`(defun ,fun-name ()
,doc
(nth ,n (guix-buffer-current-args)))))

(defmacro guix-buffer-define-current-args-accessors (prefix &rest names)
"Define `PREFIX-NAME' functions for NAMES.
See `guix-buffer-define-current-args-accessor' for details."
`(progn
,@(cl-loop for name in names
for i from 0
collect `(guix-buffer-define-current-args-accessor
,i ,prefix ,name))))

;;; Wrappers for defined variables

(defvar guix-buffer-data nil
"Alist with 'buffer' data.
This alist is filled by `guix-buffer-define-interface' macro.")

(defun guix-buffer-value (buffer-type entry-type symbol)
"Return SYMBOL's value for BUFFER-TYPE/ENTRY-TYPE from `guix-buffer-data'."
(symbol-value
(guix-assq-value guix-buffer-data buffer-type entry-type symbol)))

(defun guix-buffer-get-entries (buffer-type entry-type args)
"Return ENTRY-TYPE entries.
Call an appropriate 'get-entries' function from `guix-buffer'
using ARGS as its arguments."
(apply (guix-buffer-value buffer-type entry-type 'get-entries)
args))

(defun guix-buffer-mode-enable (buffer-type entry-type)
"Turn on major mode to display ENTRY-TYPE ENTRIES in BUFFER-TYPE buffer."
(funcall (guix-buffer-value buffer-type entry-type 'mode)))

(defun guix-buffer-mode-initialize (buffer-type entry-type)
"Set up the current BUFFER-TYPE buffer to display ENTRY-TYPE entries."
(let ((fun (guix-buffer-value buffer-type entry-type 'mode-init)))
(when fun
(funcall fun))))