emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/system-packages 449dcdf 08/10: Replace '%p' in commands


From: Stefan Monnier
Subject: [elpa] externals/system-packages 449dcdf 08/10: Replace '%p' in commands with the package name
Date: Tue, 16 Mar 2021 09:44:28 -0400 (EDT)

branch: externals/system-packages
commit 449dcdf4fe22874c9d91ee8d929ebb8a41b1bac6
Author: Štěpán Němec <stepnem@gmail.com>
Commit: Štěpán Němec <stepnem@gmail.com>

    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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]