branch: externals/system-packages
commit 449dcdf4fe22874c9d91ee8d929ebb8a41b1bac6
Author: Štěpán Němec <[email protected]>
Commit: Štěpán Němec <[email protected]>
Replace '%p' in commands with the package name
Example 'system-packages-supported-package-managers' entry:
(change-log . "pacman -Qc %p; pacolog %p")
The '%p' syntax is in accordance with other package management tools,
e.g. aptitude or pcurses.
---
README.org | 6 +++++-
system-packages.el | 10 ++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/README.org b/README.org
index b65b410..7a1060c 100644
--- a/README.org
+++ b/README.org
@@ -86,7 +86,11 @@ the commands to =system-packages-supported-package-managers=
like so:
(noconfirm . "--noconfirm"))))
#+END_SRC
-You may then need to adjust =system-packages-package-manager= and
+Any occurrences of ~%p~ in a command will be replaced with the package
+name during execution, otherwise the package name is simply appended
+to the command.
+
+You may also need to adjust =system-packages-package-manager= and
=system-packages-use-sudo= accordingly:
#+BEGIN_SRC emacs-lisp
diff --git a/system-packages.el b/system-packages.el
index fee47fa..59d4b7e 100644
--- a/system-packages.el
+++ b/system-packages.el
@@ -298,7 +298,10 @@
(list-dependencies-of . "xbps-query -x")
(noconfirm . nil))))
"An alist of package manager commands.
-The key is the package manager and value (usually) the shell command to run.")
+The key is the package manager and value (usually) the shell command to run.
+Any occurrences of ~%p~ in the command will be replaced with the package
+name during execution, otherwise the package name is simply appended
+to the command.")
(put 'system-packages-supported-package-managers 'risky-local-variable t)
(define-obsolete-variable-alias 'system-packages-packagemanager
@@ -360,7 +363,10 @@ of passing additional arguments to the package manager."
system-packages-supported-package-managers)))))))
(unless command
(error (format "%S not supported in %S" action
system-packages-package-manager)))
- (setq command (mapconcat #'identity (list command pack) " "))
+ (setq command
+ (if (string-match-p "%p" command)
+ (replace-regexp-in-string "%p" pack command t t)
+ (concat command " " pack)))
(when noconfirm
(setq args (concat args (and pack " ") noconfirm)))
(concat command args)))