diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2020-04-05 12:37:05 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2020-04-05 12:37:05 +0200 |
| commit | 57709c323c9c94717626fffd496236a8f1eb8e08 (patch) | |
| tree | bbbfec280f63ef1528f414e027e0186257c9726a | |
| parent | eb0d6621c991557964823c8af326a5dfdc56dd6f (diff) | |
| download | soria-57709c323c9c94717626fffd496236a8f1eb8e08.tar.gz soria-57709c323c9c94717626fffd496236a8f1eb8e08.zip | |
Use highlight-numbers-number instead of writing my own number parser
This is cleaner, more maintainable, and it has a couple of added benefits:
1. It will no longer be troublesome for people switching between themes, since
the hook that we automatically injected would still be there.
2. Lexical binding is not discarded, with all its benefits.
As suggested by @riscy in https://github.com/melpa/melpa/pull/6808.
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | soria-theme.el | 33 |
2 files changed, 7 insertions, 29 deletions
@@ -4,6 +4,7 @@ PKG = soria ELS_ALL = $(wildcard *.el) ELS = $(filter-out $(PKG)-autoloads.el,$(ELS_ALL)) +OBJECTS = $(ELS:.el=.elc) EMACS ?= emacs BATCH = $(EMACS) --quick --batch $(LOAD_PATH) @@ -20,7 +21,7 @@ version: .PHONY: clean clean: - @rm -rf $(TOP)vendor/* $(PKG)-autoloads.el* + @rm -rf $(TOP)vendor/* $(PKG)-autoloads.el* $(OBJECTS) ## # Test diff --git a/soria-theme.el b/soria-theme.el index 14788ae..dbafbd7 100644 --- a/soria-theme.el +++ b/soria-theme.el @@ -55,30 +55,6 @@ The theme has to be reloaded after changing anything in this group." :type 'boolean :group 'soria) -;; First of all, let's create our own font-lock for numbers. - -(make-face 'font-lock-number-face) -(set-face-attribute 'font-lock-number-face nil :inherit font-lock-constant-face) -(setq font-lock-number-face 'font-lock-number-face) - -(defun soria-theme-add-font-lock-numbers () - "Add to the list of keywords numeric formats. -It adds to `font-lock-number-face' decimal, octal, hex and bin formats." - - (defvar soria-theme-font-lock-number "[0-9]+\\([eE][+-]?[0-9]*\\)?") - (defvar soria-theme-font-lock-hexnumber "0[xX][0-9a-fA-F]+") - (defvar soria-theme-font-lock-binnumber "0[bB][01]+") - - (font-lock-add-keywords - nil - (list - (list (concat "\\<\\(" soria-theme-font-lock-number "\\)\\>" ) - 0 font-lock-number-face) - (list (concat "\\<\\(" soria-theme-font-lock-hexnumber "\\)\\>" ) - 0 font-lock-number-face) - (list (concat "\\<\\(" soria-theme-font-lock-binnumber "\\)\\>" ) - 0 font-lock-number-face)))) - ;; The color theme itself. (let* @@ -228,6 +204,11 @@ It adds to `font-lock-number-face' decimal, octal, hex and bin formats." `(font-lock-warning-face ((,class (:foreground ,soria-green)))) + ;; highlight-numbers + + `(highlight-numbers-number + ((,class (:foreground ,soria-orange)))) + ;; Search `(isearch @@ -1366,10 +1347,6 @@ It adds to `font-lock-number-face' decimal, octal, hex and bin formats." `(org-date ((,class (:foreground ,soria-gray, :weight normal :underline nil)))))) -;; And finally hook the defined font locks and call provide-theme. - -(add-hook 'prog-mode-hook 'soria-theme-add-font-lock-numbers) - (defun soria-theme-purple-identifiers () "Make function identifiers purple. This function might be used as a hook for modes that prefer having purple |
