From 1a7867074edd6f956f9dd2c9580133ed8b26de21 Mon Sep 17 00:00:00 2001 From: Protesilaos Stavrou Date: Mon, 24 Nov 2025 13:48:16 +0200 Subject: [PATCH] Make modus-themes-generate-palette require at bg-main and fg-main --- modus-themes.el | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/modus-themes.el b/modus-themes.el index 2e55fc9..fc65072 100644 --- a/modus-themes.el +++ b/modus-themes.el @@ -7507,10 +7507,6 @@ defined command's symbol is FAMILY-SUFFIX, like `modus-themes-rotate'." ;;;; Generate a palette given the base colors -(defconst modus-themes-generate-palette-names - '(bg-main fg-main) - "The base named palette entries for `modus-themes-generate-palette'.") - (declare-function color-lighten-name "color" (name percent)) (declare-function color-darken-name "color" (name percent)) @@ -7571,10 +7567,12 @@ PREFERENCE has the same meaning as the fallback preference passed to ;;;###autoload (defun modus-themes-generate-palette (base-colors &optional cool-or-warm-preference core-palette mappings) "Generate a palette given the BASE-COLORS. -BASE-COLORS is consists of lists in the form (NAME VALUE). NAME is at -least one of `modus-themes-generate-palette-names', while VALUE is a -string representing a color either by name like in `list-colors-display' -or hexadecimal RGB of the form #123456. +BASE-COLORS consists of lists in the form (NAME VALUE). NAME is at +least a symbol of `bg-main' or `fg-main', plus any other arbitrary +symbol, while VALUE is a string representing a color either by name like +in `list-colors-display' or hexadecimal RGB of the form #123456. See +the value of a core Modus palette, like `modus-themes-operandi-palette' +for all current NAME symbols. BASE-COLORS is used to derived a palette. Any entry whose name is already present in BASE-COLORS is not derived but taken as-is. @@ -7599,15 +7597,13 @@ COOL-OR-WARM-PREFERENCE. With optional MAPPINGS use them instead of trying to derive new ones." (require 'color) - (let ((names (mapcar #'car base-colors))) - (unless (seq-every-p - (lambda (name) - (memq name modus-themes-generate-palette-names)) - names) - (error "All names must be members of `modus-themes-generate-palette-names'")) - (let* ((bg-main (car (alist-get 'bg-main base-colors))) + (let ((bg-main (alist-get 'bg-main base-colors)) + (fg-main (alist-get 'fg-main base-colors))) + (unless (and bg-main fg-main) + (error "The palette must define at least a bg-main and fg-main entry with their values")) + (let* ((bg-main (car bg-main)) (bg-main-dark-p (color-dark-p (color-name-to-rgb bg-main))) - (fg-main (car (alist-get 'fg-main base-colors))) + (fg-main (car fg-main)) (six-colors (seq-remove (lambda (name) (or (eq (car name) 'bg-main)