<commit_before>;;; hydrangea.el --- Theme building framework for Emacs  -*- lexical-binding: t -*-

;; Copyright (C) 2015  <NAME>

;; Author: <NAME> <<EMAIL>>
;; Keywords: theme, framework
;; Version: 0.1.0

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; 

;;; Code:

(require 'cl-lib)
(require 'pcase)

(defun hydrangea-unwrap-unquote (x)
  (if (and (listp x) (eq (car x) '\,))
      (cadr x)
    x))

(defun hydrangea-eval-for (palette i x)
  (pcase x
    (`(lighten    ,percent ,color) `(,'\, (color-lighten-name    ,(hydrangea-unwrap-unquote (hydrangea-eval-for palette i color)) ,percent)))
    (`(darken     ,percent ,color) `(,'\, (color-darken-name     ,(hydrangea-unwrap-unquote (hydrangea-eval-for palette i color)) ,percent)))
    (`(saturate   ,percent ,color) `(,'\, (color-saturate-name   ,(hydrangea-unwrap-unquote (hydrangea-eval-for palette i color)) ,percent)))
    (`(desaturate ,percent ,color) `(,'\, (color-desaturate-name ,(hydrangea-unwrap-unquote (hydrangea-eval-for palette i color)) ,percent)))
    ((pred symbolp)
     (let ((j 0)
           (found nil))
       (while (and (not found) (< j (length palette)))
         (when (eq x (car (elt palette j)))
           (setq found j))
         (cl-incf j))
       (if found
           `(,'\, (elt (elt palette ,found) ,(+ 1 i)))
         x)))
    ((pred listp)
     (mapcar (lambda (y) (hydrangea-eval-for palette i y)) x))
    (_ x)))

(defun hydrangea-mkspec (palette spec)
  `((((min-colors 65536)) ,@(hydrangea-eval-for palette 0 spec))
    (t                    ,@(hydrangea-eval-for palette 1 spec))))

(defmacro hydrangea-define-theme (theme doc palette face-defs &rest body)
  ""
  (declare (indent defun) (debug t))
  `(progn
     (deftheme ,theme ,doc)

     (require 'color)

     (defgroup ,(intern (concat (symbol-name theme) "-theme")) nil
       ""
       :group 'customize)
     (defcustom ,(intern (concat (symbol-name theme) "-theme-tune-hue")) 0
       "Percentage of hue by which accent colors in the palette will be adjusted.
Both a positive value and a negative value are accepted."
       :type 'number
       :group ',(intern (concat (symbol-name theme) "-theme")))

     (defcustom ,(intern (concat (symbol-name theme) "-theme-tune-saturation")) 0
       "Percentage of saturation by which accent colors in the palette will be adjusted.
Both a positive value and a negative value are accepted.
This value will be passed to the `color-saturate-name' function."
       :type 'number
       :group ',(intern (concat (symbol-name theme) "-theme")))

     (defcustom ,(intern (concat (symbol-name theme) "-theme-tune-lightness")) 0
       "Percentage of lightness by which accent colors in the palette will be adjusted.
Both a positive value and a negative value are accepted.
This value will be passed to the `color-lighten-name' function."
       :type 'number
       :group ',(intern (concat (symbol-name theme) "-theme")))<commit_msg>Put a blank line between definitions<commit_after>;;; hydrangea.el --- Theme building framework for Emacs  -*- lexical-binding: t -*-

;; Copyright (C) 2015  <NAME>

;; Author: <NAME> <<EMAIL>>
;; Keywords: theme, framework
;; Version: 0.1.0

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; 

;;; Code:

(require 'cl-lib)
(require 'pcase)

(defun hydrangea-unwrap-unquote (x)
  (if (and (listp x) (eq (car x) '\,))
      (cadr x)
    x))

(defun hydrangea-eval-for (palette i x)
  (pcase x
    (`(lighten    ,percent ,color) `(,'\, (color-lighten-name    ,(hydrangea-unwrap-unquote (hydrangea-eval-for palette i color)) ,percent)))
    (`(darken     ,percent ,color) `(,'\, (color-darken-name     ,(hydrangea-unwrap-unquote (hydrangea-eval-for palette i color)) ,percent)))
    (`(saturate   ,percent ,color) `(,'\, (color-saturate-name   ,(hydrangea-unwrap-unquote (hydrangea-eval-for palette i color)) ,percent)))
    (`(desaturate ,percent ,color) `(,'\, (color-desaturate-name ,(hydrangea-unwrap-unquote (hydrangea-eval-for palette i color)) ,percent)))
    ((pred symbolp)
     (let ((j 0)
           (found nil))
       (while (and (not found) (< j (length palette)))
         (when (eq x (car (elt palette j)))
           (setq found j))
         (cl-incf j))
       (if found
           `(,'\, (elt (elt palette ,found) ,(+ 1 i)))
         x)))
    ((pred listp)
     (mapcar (lambda (y) (hydrangea-eval-for palette i y)) x))
    (_ x)))

(defun hydrangea-mkspec (palette spec)
  `((((min-colors 65536)) ,@(hydrangea-eval-for palette 0 spec))
    (t                    ,@(hydrangea-eval-for palette 1 spec))))

(defmacro hydrangea-define-theme (theme doc palette face-defs &rest body)
  ""
  (declare (indent defun) (debug t))
  `(progn
     (deftheme ,theme ,doc)

     (require 'color)

     (defgroup ,(intern (concat (symbol-name theme) "-theme")) nil
       ""
       :group 'customize)

     (defcustom ,(intern (concat (symbol-name theme) "-theme-tune-hue")) 0
       "Percentage of hue by which accent colors in the palette will be adjusted.
Both a positive value and a negative value are accepted."
       :type 'number
       :group ',(intern (concat (symbol-name theme) "-theme")))

     (defcustom ,(intern (concat (symbol-name theme) "-theme-tune-saturation")) 0
       "Percentage of saturation by which accent colors in the palette will be adjusted.
Both a positive value and a negative value are accepted.
This value will be passed to the `color-saturate-name' function."
       :type 'number
       :group ',(intern (concat (symbol-name theme) "-theme")))

     (defcustom ,(intern (concat (symbol-name theme) "-theme-tune-lightness")) 0
       "Percentage of lightness by which accent colors in the palette will be adjusted.
Both a positive value and a negative value are accepted.
This value will be passed to the `color-lighten-name' function."
       :type 'number
       :group ',(intern (concat (symbol-name theme) "-theme")))
{'fraction_non_alphanumeric': 0.13904494382022473, 'fraction_numerical': 0.0056179775280898875, 'mean_word_length': 3.206142941523922, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7076050', 'n_tokens_mistral': 2323, 'n_tokens_neox': 2193, 'n_words': 818}