Skip to content

Commit

Permalink
elisp/ui-package: Add 'guix-package-use-name-at-point' variable
Browse files Browse the repository at this point in the history
* elisp/guix-ui-package.el (guix-package-use-name-at-point): New variable.
(guix-packages-by-name): Use it.
  • Loading branch information
alezost committed Jun 8, 2021
1 parent e5ff0e5 commit c9aef52
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions elisp/guix-ui-package.el
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ a separate line)."
(const :tag "List of outputs" output))
:group 'guix-package)

(defcustom guix-package-use-name-at-point t
"If non-nil, \\[guix-packages-by-name] uses symbol at point as default
if it is a package name.
If nil, then no default name is used."
:type 'boolean
:group 'guix-package)

(defun guix-package-list-type ()
"Return BUI list entry-type by `guix-package-list-type' variable."
(guix-make-symbol guix-package-list-type))
Expand Down Expand Up @@ -1512,12 +1519,13 @@ a version number. Examples: \"guile\", \"[email protected]\".
If PROFILE is nil, use `guix-current-profile'.
Interactively with prefix, prompt for PROFILE."
(interactive
(let ((at-point (thing-at-point 'symbol t))
default-pkg)
(when (stringp at-point)
(let ((at-point (car (split-string at-point "@"))))
(setq default-pkg (and (member at-point (guix-package-names))
at-point))))
(let (default-pkg)
(when guix-package-use-name-at-point
(let ((at-point (thing-at-point 'symbol t)))
(when (stringp at-point)
(let ((at-point (car (split-string at-point "@"))))
(setq default-pkg (and (member at-point (guix-package-names))
at-point))))))
(list (guix-read-package-name "Package: " default-pkg)
(guix-ui-read-package-profile))))
(guix-package-get-display profile 'name name))
Expand Down

0 comments on commit c9aef52

Please sign in to comment.