aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2023-03-15 11:17:14 +0100
committerMiguel Ángel Moreno <mail@migalmoreno.com>2023-03-15 11:32:22 +0100
commita014028769f64f0a07b9c46cf26ab2a77760402a (patch)
treeafd4c3365906b4ad520370bcc471644d94cb5896
parent9a8574558924daaf8f8ae433ec14bd8afff7a3a4 (diff)
feat: Add customizable package entry format
-rw-r--r--fdroid.el28
1 files changed, 20 insertions, 8 deletions
diff --git a/fdroid.el b/fdroid.el
index 51e475d..3beb25b 100644
--- a/fdroid.el
+++ b/fdroid.el
@@ -45,6 +45,18 @@
:group 'fdroid
:type 'boolean)
+(defcustom fdroid-package-format "%a [%v]: %d"
+ "The format for each entry in the list of F-Droid packages.
+
+The following %-escapes will be expanded using `format-spec':
+
+%n The package name.
+%v The package version.
+%a The package appid.
+%d The package description."
+ :type 'string
+ :group 'fdroid)
+
(defcustom fdroid-sans-device nil
"If non-nil, `fdroid' commands should override the device connection check."
:group 'fdroid
@@ -128,14 +140,14 @@ Optionally, filter packages by KEYWORDS and return a list of matching results."
(defun fdroid--format-package (key value table)
"Embellish package entry with KEY and VALUE from TABLE for user completion."
- (let ((name (cl-getf value :name))
- (version (cl-getf value :version))
- (description (cl-getf value :description)))
- (if (not (string-empty-p name))
- (puthash (format "%s - %s (%s): %s" name version key description)
- key table)
- (puthash (format "%s - %s: %s" key version description)
- key table))))
+ (let* ((name (cl-getf value :name))
+ (version (cl-getf value :version))
+ (description (cl-getf value :description))
+ (spec `((?n . ,name)
+ (?v . ,version)
+ (?a . ,key)
+ (?d . ,description))))
+ (puthash (format-spec fdroid-package-format spec) key table)))
(defun fdroid--build-candidate-list (&optional keywords)
"Build candidate list with KEYWORDS to be leveraged on completion functions."