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

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

[elpa] externals/repology f25a612: repology: Add faces.


From: Nicolas Goaziou
Subject: [elpa] externals/repology f25a612: repology: Add faces.
Date: Fri, 22 Jan 2021 14:42:10 -0500 (EST)

branch: externals/repology
commit f25a612d5070846ea5b661ca8cfecfc0320b2dfd
Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Commit: Nicolas Goaziou <mail@nicolasgoaziou.fr>

    repology: Add faces.
    
    * repology.el (repology-status-faces): Remove variable.
    (repology-free):
    (repology-non-free):
    (repology-unknown):
    (repology-devel-status):
    (repology-ignored-status):
    (repology-incorrect-status):
    (repology-legacy-status):
    (repology-newest-status):
    (repology-noscheme-status):
    (repology-outdated-status): New faces.
    (repology--check-freedom-at-point): Make use of new faces.
    (repology--package-status-face): Move...
    * repology-utils.el (repology--package-status-face): ... here.  Make
    use of new faces.
---
 repology-utils.el | 13 ++++++--
 repology.el       | 91 +++++++++++++++++++++++++++++++++----------------------
 2 files changed, 65 insertions(+), 39 deletions(-)

diff --git a/repology-utils.el b/repology-utils.el
index 7370f70..b56e3bc 100644
--- a/repology-utils.el
+++ b/repology-utils.el
@@ -104,6 +104,16 @@ Return PACKAGE's repository internal name if the full name 
is unknown."
     (or (ignore-errors (repology-repository-full-name repo))
         repo)))
 
+(defun repology--package-status-face (package)
+  "Return face associated to status from PACKAGE."
+  (let ((status (repology-package-field package 'status)))
+    (if (member status repology-package-all-status)
+        (intern (format "repology-%s-status" status))
+      ;; If package status list is not up-to-date, fall back to
+      ;; `default' face.
+      (warn "Repology: Unknown package status: %S; Using `default' face" other)
+      'default)))
+
 (defun repology-package-colorized-status (package)
   "Return colorized status string for PACKAGE.
 The version string is emphasized according to PACKAGE's status.
@@ -114,8 +124,7 @@ Return nil if PACKAGE has no status field."
 
 (defun repology-package-colorized-version (package)
   "Return colorized version string for PACKAGE.
-The version string is emphasized according to PACKAGE's status.
-See `repology-status-faces'."
+The version string is emphasized according to PACKAGE's status."
   (propertize (repology-package-field package 'version)
               'face
               (repology--package-status-face package)))
diff --git a/repology.el b/repology.el
index 643db28..7657ff5 100644
--- a/repology.el
+++ b/repology.el
@@ -47,12 +47,12 @@
 ;; You can also decide to display (a subset of) results in a tabulated
 ;; list.  See `repology-display-package', `repology-display-packages',
 ;; `repology-display-projects' and `repology-display-problems'.  You
-;; can control various aspects of the display, like the colors used
-;; (see `repology-status-faces'), or the columns shown (see
-;; `repology-display-packages-columns',`repology-display-projects-columns',
-;; and `repology-display-problems-columns').  When projects or packages
-;; are displayed, pressing <RET> gives you more information about the item
-;; at point, whereas pressing <F> reports their "freedom" status.
+;; can control various aspects of the display, like the faces used
+;; or the columns shown (see `repology-display-packages-columns',
+;; `repology-display-projects-columns' and 
`repology-display-problems-columns').
+;; When projects or packages are displayed, pressing <RET> gives you more
+;; information about the item at point, whereas pressing <F> reports their
+;; freedom status.
 
 ;; For example, the following expression displays all outdated projects
 ;; named after "emacs" and containing a package in GNU Guix repository
@@ -152,29 +152,6 @@ See `repology-check-freedom' for more information."
           (const :tag "Free and unknown projects" include-unknown)
           (const :tag "Every project" nil)))
 
-(defcustom repology-status-faces
-  '(("incorrect" . error)
-    ("newest" . highlight)
-    ("outdated" . warning)
-    ("noscheme" . shadow)
-    ("untrusted" . shadow)
-    ("ignored" . shadow))
-  "Association list of status values and faces.
-
-Each entry is a construct like (STATUS . FACE) where STATUS is
-a possible package status value, as detailed in `repology-package-field',
-and FACE is the face to be applied by `repology-package-colorize-status'
-and `repology-package-colorize-version'.
-
-Un-handled status values are associated to the `default' face."
-  :type
-  `(repeat
-    (cons :tag "Association"
-          (choice :tag "Status"
-                  ,@(mapcar (lambda (status) `(const ,status))
-                            repology-package-all-status))
-          face)))
-
 (defcustom repology-display-problems-columns
   `(("Project" effname 20 t)
     ("Package name" visiblename 20 t)
@@ -272,6 +249,51 @@ You may also want to look into comparison functions 
suitable for SORT, such as
           (function :tag "Function describing columns")))
 
 
+;;; Faces
+(defgroup repology-faces nil
+  "Faces for Repology"
+  :group 'repology)
+
+(defface repology-free '((t :inherit success))
+  "Face for free packages or projects.")
+
+(defface repology-non-free '((t :inherit warning))
+  "Face for non-free packages or projects.")
+
+(defface repology-unknown '((t :inherit default))
+  "Face for packages or projects with unknown freedom status.")
+
+(defface repology-devel-status '((t :inherit italic))
+  "Face for \"devel\" status.")
+
+(defface repology-ignored-status '((t :inherit shadow))
+  "Face for \"ignored\" status.")
+
+(defface repology-incorrect-status '((t :inherit error))
+  "Face for \"incorrect\" status.")
+
+(defface repology-legacy-status '((t :inherit default))
+  "Face for \"legacy\" status.")
+
+(defface repology-newest-status '((t :inherit success))
+  "Face for \"newest\" status.")
+
+(defface repology-noscheme-status '((t :inherit shadow))
+  "Face for \"noscheme\" status.")
+
+(defface repology-outdated-status '((t :inherit warning))
+  "Face for \"outdated\" status.")
+
+(defface repology-rolling-status '((t :inherit italic))
+  "Face for \"rolling\" status.")
+
+(defface repology-unique-status '((t :inherit default))
+  "Face for \"unique\" status.")
+
+(defface repology-untrusted-status '((t :inherit shadow))
+  "Face for \"untrusted\" status.")
+
+
 ;;; Global Internal Variables
 (defconst repology-project-filters-parameters
   `((:search          "Name search (e.g. emacs): " nil)
@@ -544,9 +566,9 @@ REPOSITORY is a string.  Return a list of problems."
   (interactive)
   (message "Freedom status: %s"
            (pcase (repology-check-freedom (tabulated-list-get-id))
-             ('unknown (propertize "Unknown" 'face 'shadow))
-             ('nil (propertize "Non-Free" 'face 'warning))
-             (_ (propertize "Free" 'face 'highlight)))))
+             ('unknown (propertize "Unknown" 'face 'repology-unknown))
+             ('nil (propertize "Non-Free" 'face 'repology-non-free))
+             (_ (propertize "Free" 'face 'repology-free)))))
 
 (defun repology--show-current-project ()
   "Display packages associated to project at point."
@@ -596,11 +618,6 @@ REPOSITORY is a string.  Return a list of problems."
     (_
      (format "%s" value))))
 
-(defun repology--package-status-face (package)
-  "Return face associated to status from PACKAGE."
-  (let ((status (repology-package-field package 'status)))
-    (alist-get status repology-status-faces 'default nil #'equal)))
-
 (defun repology--make-display (data buffer-name mode format-descriptors)
   "Display DATA in a buffer named after BUFFER-NAME string.
 DATA is displayed in a major mode derived from `tabulated-list-mode', and set



reply via email to

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