elisp: Add and use 'guix-file-name'
Various Guix (Guile) procedures are sensitive to "non-expanded" file names and to trailing slashes in directory names, so 'directory-file-name' and 'expand-file-name' are called here and there. Make a single function to fix it once and for all. * elisp/guix-utils.el (guix-file-name): New function. * elisp/guix-hash.el (guix-hash): Use it. * elisp/guix-profiles.el (guix-profile): Use it. * elisp/guix-misc.el (guix-apply-manifest): Use it. * elisp/guix-repl.el (guix-repl-guile-args): Use it. * elisp/guix-ui.el (guix-ui-buffer-name-short): Use it. * elisp/guix-ui-profile.el (guix-profiles): Use it. * elisp/guix-ui-generation.el (guix-generation-packages-buffer-name-default): Use it.
This commit is contained in:
parent
6ac7b47fa1
commit
0111d16547
|
@ -48,7 +48,7 @@ See also Info node `(guix) Invoking guix hash'."
|
|||
(list (guix-read-file-name-maybe)
|
||||
(and current-prefix-arg
|
||||
(guix-read-hash-format))))
|
||||
(let* ((file (expand-file-name file))
|
||||
(let* ((file (guix-file-name file))
|
||||
(args (list :format (or format guix-default-hash-format)))
|
||||
(args (if (file-directory-p file)
|
||||
(append '(:recursive? t) args)
|
||||
|
@ -58,7 +58,7 @@ See also Info node `(guix) Invoking guix hash'."
|
|||
'file-hash file args))))
|
||||
(kill-new hash)
|
||||
(message "Hash of \"%s\" (%s) has been added to the kill ring."
|
||||
(file-name-nondirectory (directory-file-name file))
|
||||
(file-name-nondirectory file)
|
||||
hash)))
|
||||
|
||||
(provide 'guix-hash)
|
||||
|
|
|
@ -183,8 +183,8 @@ FILE. With a prefix argument, also prompt for PROFILE."
|
|||
(guix-make-guile-expression
|
||||
'guix-command
|
||||
"package"
|
||||
(concat "--profile=" (expand-file-name profile))
|
||||
(concat "--manifest=" (expand-file-name file)))
|
||||
(concat "--profile=" (guix-file-name profile))
|
||||
(concat "--manifest=" (guix-file-name file)))
|
||||
operation-buffer)))
|
||||
|
||||
(defcustom guix-search-paths-buffer-name "*Guix Search Paths*"
|
||||
|
|
|
@ -112,7 +112,7 @@ have a trailing slash and it is `guix-default-profile' if PROFILE
|
|||
is `guix-user-profile'. `guix-user-profile' is special because
|
||||
it is actually a symlink to a real user profile, and the HOME
|
||||
directory does not contain profile generations."
|
||||
(let ((profile (directory-file-name (expand-file-name profile))))
|
||||
(let ((profile (guix-file-name profile)))
|
||||
(if (string= profile guix-user-profile)
|
||||
guix-default-profile
|
||||
profile)))
|
||||
|
|
|
@ -225,8 +225,8 @@ See `guix-emacs-activate-after-operation' for details."
|
|||
(lcp (if guix-load-compiled-path
|
||||
(guix-list-maybe guix-load-compiled-path)
|
||||
lp)))
|
||||
(append (--mapcat (list "-L" (expand-file-name it)) lp)
|
||||
(--mapcat (list "-C" (expand-file-name it)) lcp))))
|
||||
(append (--mapcat (list "-L" (guix-file-name it)) lp)
|
||||
(--mapcat (list "-C" (guix-file-name it)) lcp))))
|
||||
"-L" ,guix-scheme-directory
|
||||
,@(and guix-config-scheme-compiled-directory
|
||||
(list "-C" guix-config-scheme-compiled-directory))
|
||||
|
|
|
@ -491,7 +491,7 @@ and its store file name."
|
|||
(defun guix-generation-packages-buffer-name-default (profile generation)
|
||||
"Return name of a buffer for displaying GENERATION's package outputs.
|
||||
Use base name of PROFILE file name."
|
||||
(let ((profile-name (file-name-base (directory-file-name profile))))
|
||||
(let ((profile-name (file-name-base (guix-file-name profile))))
|
||||
(format "*Guix %s: generation %s*"
|
||||
profile-name generation)))
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
guix-system-profile
|
||||
guix-pulled-profile
|
||||
(--when-let (getenv "GUIX_PROFILE")
|
||||
(expand-file-name it)))))
|
||||
(guix-file-name it)))))
|
||||
"List of profiles displayed by '\\[guix-profiles]' command."
|
||||
:type '(repeat file)
|
||||
:group 'guix-profile)
|
||||
|
|
|
@ -109,7 +109,7 @@ The function is called with 2 arguments: BASE-NAME and PROFILE."
|
|||
(defun guix-ui-buffer-name-short (base-name profile)
|
||||
"Return buffer name by appending BASE-NAME and PROFILE's base file name."
|
||||
(guix-compose-buffer-name base-name
|
||||
(file-name-base (directory-file-name profile))))
|
||||
(file-name-base (guix-file-name profile))))
|
||||
|
||||
(defun guix-ui-buffer-name-full (base-name profile)
|
||||
"Return buffer name by appending BASE-NAME and PROFILE's full name."
|
||||
|
|
|
@ -289,6 +289,10 @@ If nil, always prompt for a file name."
|
|||
:type 'boolean
|
||||
:group 'guix)
|
||||
|
||||
(defun guix-file-name (file-name)
|
||||
"Expand FILE-NAME and remove trailing slash if needed."
|
||||
(directory-file-name (expand-file-name file-name)))
|
||||
|
||||
(defun guix-read-file-name (&optional prompt dir default-filename
|
||||
mustmatch initial predicate)
|
||||
"Read file name.
|
||||
|
|
Loading…
Reference in New Issue