Code Monkey home page Code Monkey logo

autothemer's Introduction

Readme

Autothemer provides a thin layer on top of deftheme and custom-theme-set-faces that creates a new custom color theme, based on a set of simplified face specifications and a user-supplied color palette. As an example, the following snippet creates a new custom theme that modifies the two faces error and button:

(autothemer-deftheme some-new-theme "This is a rather pointless theme"
    ;; the first line of the color palette lists display types, ordered from
    ;; most to least capable
    ((((class color) (min-colors 32000)) ((class color) (min-colors 90)) t)
    ;; all following lines list color specifications, starting with the color's name,
    ;; then containing the color values corresponding to each display type. Nil values
    ;; are automatically replaced by their most recent non-nil precursor (i.e., the nil
    ;; below is replaced by "#dd6611")
    (reddish "#dd6611" nil "#FF0000")
    ;; missing values at the end are automatically replaced by the last non-nil entry,
    ;; in this case "#FFFF00"
    (yellowish "#dddd22" "#FFFF00")
    ;; the macro internally creates let* blocks, so these color definitions may contain
    ;; both arbitrary functions and references to already defined colors
    (not-quite-yellowish "#dcdc22" yellowish yellowish))

    ;; Here come the face specifications.
    ((button (:underline t :weight 'bold :foreground yellowish))
     (error (:foreground reddish)))

    ;; autothemer-deftheme can also execute an arbitrary function body. Here,
    ;; all colors refer to their best possible display representations
    ;; (i.e., reddish = "#dd6611", yellowish = "#dddd22", etc.)
    (custom-theme-set-variables 'some-new-theme
        `(ansi-color-names-vector [,reddish
                                   ,reddish
                                   ,reddish
                                   ,yellowish
                                   ,yellowish
                                   ,yellowish
                                   ,not-quite-yellowish
                                   ,not-quite-yellowish])))

At theme definition time, autothemer-deftheme furthermore extracts the best possible color representations (i.e., the first values in every row of the color palette, in this case "#dd6611", "#dddd22" and "#dcdc22") and writes the list to a global variable, together with the corresponding color names.

Missing face customizations can now be generated automatically by calling autothemer-generate-templates. This command iterates over all currently defined faces that have not been customized during the last invocation of autothemer-deftheme, obtain their current definition and replace every color value therein by the name of the color palette entry that best approximates it (where "best" is defined as having the lowest euclidean distance in RGB space). For instance, if the face some-face currently has the properties (:underline t :weight 'demibold :foreground "red"), autothemer will find that the color "red" is most closely approximated by reddish and emit for some-face the reduced specification (some-face (:underline t :weight 'demibold :foreground reddish)). All face specifications thus obtained are displayed in a temporary buffer and can be copied verbatim into the definition of some-new-theme.

autothemer's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ursulogalvan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.