From 57709c323c9c94717626fffd496236a8f1eb8e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Sabat=C3=A9=20Sol=C3=A0?= Date: Sun, 5 Apr 2020 12:37:05 +0200 Subject: [PATCH] Use highlight-numbers-number instead of writing my own number parser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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à --- Makefile | 3 ++- soria-theme.el | 33 +++++---------------------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 739d3bf..73c9b10 100644 --- a/Makefile +++ b/Makefile @@ -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