Skip to content

Commit

Permalink
Merge pull request #44 from arcticicestudio/feature/gh-43-custom-comm…
Browse files Browse the repository at this point in the history
…ent-brightness

Custom comment brightness customization
  • Loading branch information
arcticicestudio authored Oct 5, 2017
2 parents 24deba8 + 4d0a891 commit 3e6bfda
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 7 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Nord Emacs is a 16 colorspace theme build to run in GUI- and terminal mode with
- [Package.el](#package-el)
- [Activation](#activation)
- [Features](#features)
- [Customization](#customization)
- [Custom Comment Brightness](#custom-comment-brightness)
- [Package Support](#package-support)
- [Syntax Packages](#syntax-packages)
- [UI Packages](#ui-packages)
Expand Down Expand Up @@ -71,6 +73,50 @@ or change it on-the-fly by running <kbd>M-x</kbd> `load-theme` <kbd>RET</kbd> `n

<p align="center"><strong>Colors of selected code can still be easily recognized.</strong><br><img src="https://raw.githubusercontent.com/arcticicestudio/nord-emacs/develop/assets/scrcast-feature-selection.gif"/></p>

## Customization

All customizations need to be set before `load-theme` is invoked for Nord and require a restart of Emacs when changed!

### Custom Comment Brightness

This customization allows to define a custom comment color brightness with percentage adjustments from *0* - *20*. It is a way to provide a way for users to easily adjust the comment color to fit their needs without overriding specific faces individually.

It can be enabled by adding the `nord-comment-brightness` variable to a number between `1` and `20` in your `init.el`:

```lisp
(setq nord-comment-brightness 15)
```

To adhere to the Nord style guide this option uses `nord3` by default and applied as fallback when the variable is assigned a invalid value.

This customization is a port of the reference implementation from the [Nord Atom Syntax][nord-atom-syntax-gh-47] project. The values are calculated using the LESSCSS [`lighten`][lesscss-doc-lighten] function to ensure full interoperability with other port projects that providing this theme feature.

| Increased by | Calculated value |
| --- | --- |
| 0% (default) | `nord3` |
| 1% | `#4e586d` |
| 2% | `#505b70` |
| 3% | `#525d73` |
| 4% | `#556076` |
| 5% | `#576279` |
| 6% | `#59647c` |
| 7% | `#5b677f` |
| 8% | `#5d6982` |
| 9% | `#5f6c85` |
| 10% | `#616e88` |
| 11% | `#63718b` |
| 12% | `#66738e` |
| 13% | `#687591` |
| 14% | `#6a7894` |
| 15% | `#6d7a96` |
| 16% | `#6f7d98` |
| 17% | `#72809a` |
| 18% | `#75829c` |
| 19% | `#78859e` |
| 20% | `#7b88a1` |

<align="center"><strong>Default comment brightness</strong><br><img src="https://raw.githubusercontent.com/arcticicestudio/nord-emacs/develop/assets/scrot-custom-comment-brightness-java-default.png"/><br><img src="https://raw.githubusercontent.com/arcticicestudio/nord-emacs/develop/assets/scrot-custom-comment-brightness-js-default.png"/><br><strong>Increased comment brightness by 15%</strong><br><img src="https://raw.githubusercontent.com/arcticicestudio/nord-emacs/develop/assets/scrot-custom-comment-brightness-java-15percent.png"/><br><img src="https://raw.githubusercontent.com/arcticicestudio/nord-emacs/develop/assets/scrot-custom-comment-brightness-js-15percent.png"/></p>

## Package Support
Nord Emacs provides support for many third-party syntax- and the UI packages.
Detailed descriptions for supported packages can be found in the [project wiki](https://github.com/arcticicestudio/nord-emacs/wiki).
Expand Down Expand Up @@ -118,3 +164,6 @@ Please report issues/bugs, feature requests and suggestions for improvements to
<p align="center"> <img src="http://arcticicestudio.com/favicon.ico" width=16 height=16/> Copyright &copy; 2017 Arctic Ice Studio</p>

<p align="center"><a href="http://www.apache.org/licenses/LICENSE-2.0"><img src="https://img.shields.io/badge/License-Apache_2.0-5E81AC.svg?style=flat-square"/></a> <a href="https://creativecommons.org/licenses/by-sa/4.0"><img src="https://img.shields.io/badge/License-CC_BY--SA_4.0-5E81AC.svg?style=flat-square"/></a></p>

[lesscss-doc-lighten]: http://lesscss.org/functions/#color-operations-lighten
[nord-atom-syntax-gh-47]: https://github.com/arcticicestudio/nord-atom-syntax/issues/47
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 29 additions & 7 deletions nord-theme.el
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@

(deftheme nord "An arctic, north-bluish clean and elegant theme")

(defgroup nord nil
"Nord theme customizations.
The theme has to be reloaded after changing anything in this group."
:group 'faces)

(defcustom nord-comment-brightness 0
"Allows to define a custom comment color brightness with percentage adjustments from 0% - 20%.
The value must be greater or equal to 0 and less or equal to 20, otherwise the default 'nord3' color is used."
:type 'integer
:group 'nord)

(setq nord-brightened-comments '("#4c566a" "#4e586d" "#505b70" "#525d73" "#556076" "#576279" "#59647c" "#5b677f" "#5d6982" "#5f6c85" "#616e88" "#63718b" "#66738e" "#687591" "#6a7894" "#6d7a96" "#6f7d98" "#72809a" "#75829c" "#78859e" "#7b88a1"))

(defun brightened-comment-color (percent)
"Returns the brightened comment color for the given percent.
The value must be greater or equal to 0 and less or equal to 20, otherwise the default 'nord3' color is used."
(if (and (integerp percent)
(>= percent 0)
(<= percent 20))
(nth percent nord-brightened-comments)
(nth 0 nord-brightened-comments)))

;;;; Color Constants
(let ((class '((class color) (min-colors 89)))
(nord0 (if (display-graphic-p) "#2E3440" nil))
Expand All @@ -63,7 +85,7 @@
(nord-annotation (if (display-graphic-p) "#D08770" "brightyellow"))
(nord-attribute (if (display-graphic-p) "#8FBCBB" "cyan"))
(nord-class (if (display-graphic-p) "#8FBCBB" "cyan"))
(nord-comment (if (display-graphic-p) "#4C566A" "brightblack"))
(nord-comment (if (display-graphic-p) (brightened-comment-color nord-comment-brightness) "brightblack"))
(nord-escape (if (display-graphic-p) "#D08770" "brightyellow"))
(nord-method (if (display-graphic-p) "#88C0D0" "brightcyan"))
(nord-keyword (if (display-graphic-p) "#81A1C1" "blue"))
Expand All @@ -88,10 +110,10 @@
`(error ((,class (:foreground ,nord11 :weight bold))))
`(escape-glyph ((,class (:foreground ,nord12))))
`(font-lock-builtin-face ((,class (:foreground ,nord9))))
`(font-lock-comment-face ((,class (:foreground ,nord3))))
`(font-lock-comment-delimiter-face ((,class (:foreground ,nord3))))
`(font-lock-comment-face ((,class (:foreground ,nord-comment))))
`(font-lock-comment-delimiter-face ((,class (:foreground ,nord-comment))))
`(font-lock-constant-face ((,class (:foreground ,nord9))))
`(font-lock-doc-face ((,class (:foreground ,nord3))))
`(font-lock-doc-face ((,class (:foreground ,nord-comment))))
`(font-lock-function-name-face ((,class (:foreground ,nord8))))
`(font-lock-keyword-face ((,class (:foreground ,nord9))))
`(font-lock-negation-char-face ((,class (:foreground ,nord9))))
Expand Down Expand Up @@ -142,7 +164,7 @@
`(custom-button-pressed-unraised ((,class (:background ,nord4 :foreground ,nord0 :box (:line-width 2 :color ,nord4 :style sunken-button)))))
`(custom-button-unraised ((,class (:background ,nord0 :foreground ,nord8 :box (:line-width 2 :color ,nord4 :style sunken-button)))))
`(custom-changed ((,class (:foreground ,nord13))))
`(custom-comment ((,class (:foreground ,nord3))))
`(custom-comment ((,class (:foreground ,nord-comment))))
`(custom-comment-tag ((,class (:foreground ,nord7))))
`(custom-documentation ((,class (:foreground ,nord4))))
`(custom-group-tag ((,class (:foreground ,nord8 :weight bold))))
Expand Down Expand Up @@ -323,7 +345,7 @@
`(js2-jsdoc-html-tag-name ((,class (:foreground ,nord9))))
`(js2-external-variable ((,class (:foreground ,nord4))))
`(js2-function-param ((,class (:foreground ,nord4))))
`(js2-jsdoc-value ((,class (:foreground ,nord3))))
`(js2-jsdoc-value ((,class (:foreground ,nord-comment))))
`(js2-jsdoc-tag ((,class (:foreground ,nord7))))
`(js2-jsdoc-type ((,class (:foreground ,nord7))))
`(js2-private-member ((,class (:foreground ,nord4))))
Expand All @@ -348,7 +370,7 @@
`(js3-warning-face ((,class (:foreground ,nord13))))

;; > Markdown
`(markdown-blockquote-face ((,class (:foreground ,nord3))))
`(markdown-blockquote-face ((,class (:foreground ,nord-comment))))
`(markdown-bold-face ((,class (:inherit bold))))
`(markdown-header-face-1 ((,class (:foreground ,nord8))))
`(markdown-header-face-2 ((,class (:foreground ,nord8))))
Expand Down

0 comments on commit 3e6bfda

Please sign in to comment.