elisp: Set 'guix-directory' when needed
Before the previous commit (6476f612aa
),
'guix-directory' variable was blindly set to the latest "guix pull"
directory. But it is not good because a user may not have that pulled
directory. It is better to ask Guile where guix modules are placed and
just use this directory.
* elisp/guix-repl.el (guix-directory): New function that sets
'guix-directory' variable if needed.
(guix-read-directory): Use 'guix-directory' function instead of variable.
* elisp/guix-location.el (guix-find-location): Likewise.
* elisp/guix-license.el (guix-license-file): Likewise.
* doc/emacs-guix.texi (More Package Commands): Remove documentation of
'guix-directory'.
This commit is contained in:
parent
5abbfa04ec
commit
3e82c84de4
|
@ -501,24 +501,6 @@ complete a package name.
|
|||
|
||||
@end table
|
||||
|
||||
@vindex guix-directory
|
||||
If you are contributing to Guix, you may find it useful for
|
||||
@kbd{M-x@tie{}guix-find-package-location-file} and
|
||||
@kbd{M-x@tie{}guix-find-package-definition} 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@tie{}guix-find-package-location-file} or
|
||||
@kbd{M-x@tie{}guix-edit} command.
|
||||
|
||||
@vindex guix-read-package-name-function
|
||||
By default, when you should specify a package name (for example, after
|
||||
@kbd{M-x guix-edit}), you will be prompted for it in the minibuffer,
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
"Return name of the file with license definitions.
|
||||
DIRECTORY is a directory with Guix source (`guix-directory' by default)."
|
||||
(expand-file-name "guix/licenses.scm"
|
||||
(or directory guix-directory)))
|
||||
(or directory (guix-directory))))
|
||||
|
||||
(defun guix-lookup-license-url (license)
|
||||
"Return URL of a LICENSE."
|
||||
|
|
|
@ -64,7 +64,7 @@ DIRECTORY (if it is specified and exists)."
|
|||
(cl-multiple-value-bind (file line column)
|
||||
(split-string location ":")
|
||||
(let* ((file-name (expand-file-name file (or directory
|
||||
guix-directory)))
|
||||
(guix-directory))))
|
||||
(file-name (if (file-exists-p file-name)
|
||||
file-name
|
||||
(guix-eval-read
|
||||
|
|
|
@ -434,18 +434,30 @@ additional internal REPL if it exists."
|
|||
|
||||
(defvar guix-directory nil
|
||||
"Default directory with Guix source.
|
||||
If it is not set by a user, it is set after starting Guix REPL.
|
||||
|
||||
This directory is used to find packages and licenses by such
|
||||
commands as `guix-find-package-definition' or
|
||||
`guix-find-license-definition'.")
|
||||
`guix-find-license-definition'.
|
||||
|
||||
Most likely you don't need to set this variable because it is set
|
||||
automatically when needed. However, you can still set it if you
|
||||
really want; your value will not be overwritten.")
|
||||
|
||||
(defun guix-directory ()
|
||||
"Set if needed and return `guix-directory'."
|
||||
(or guix-directory
|
||||
(let* ((guix.scm (guix-eval-read "(%search-load-path \"guix\")"))
|
||||
(dir (and guix.scm
|
||||
(file-name-directory guix.scm))))
|
||||
(setq guix-directory dir))))
|
||||
|
||||
(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))
|
||||
(guix-directory))
|
||||
(guix-directory)))
|
||||
|
||||
;; XXX Remove `guix-latest-directory' in future: it exists for backward
|
||||
;; compatibility (in the past "guix pull" populated
|
||||
|
|
Loading…
Reference in New Issue