[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 828cdbb 08/27: Improve regexp and add two faces
From: |
Dmitry Gutov |
Subject: |
[elpa] master 828cdbb 08/27: Improve regexp and add two faces |
Date: |
Sat, 29 Oct 2016 00:04:18 +0000 (UTC) |
branch: master
commit 828cdbb8a2ea4030d96d4cf40cdaaaa320ef5499
Author: Pavel Matcula <address@hidden>
Commit: Pavel Matcula <address@hidden>
Improve regexp and add two faces
---
README.md | 3 ++-
highlight-escape-sequences.el | 36 +++++++++++++++++++++++++-----------
2 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index 172e371..cd91176 100644
--- a/README.md
+++ b/README.md
@@ -10,5 +10,6 @@ The theme on the screenshot is
following addition:
```
-(put 'font-lock-regexp-grouping-backslash 'face-alias 'font-lock-builtin-face)
+(put 'hes-escape-backslash-face 'face-alias 'font-lock-builtin-face)
+(put 'hes-escape-sequence-face 'face-alias 'font-lock-builtin-face)
```
diff --git a/highlight-escape-sequences.el b/highlight-escape-sequences.el
index 5d9a4a1..dedba2f 100644
--- a/highlight-escape-sequences.el
+++ b/highlight-escape-sequences.el
@@ -3,7 +3,7 @@
;; Author: Dmitry Gutov <address@hidden>
;; URL: https://github.com/dgutov/highlight-escape-sequences
;; Keywords: convenience
-;; Version: 0.1
+;; Version: 0.2
;; This file is not part of GNU Emacs.
@@ -23,10 +23,13 @@
;;; Commentary:
;; This global minor mode highlights escape sequences in strings and
-;; other kinds of literals with `font-lock-regexp-grouping-backslash'
-;; face when appropriate.
+;; other kinds of literals with `hes-escape-sequence-face' which
+;; inherits from `font-lock-regexp-grouping-construct' face by
+;; default and with `hes-escape-backslash-face' which inherits from
+;; `font-lock-regexp-grouping-backslash' face by default.
-;; It currently supports `ruby-mode' and both main JavaScript modes.
+;; It currently supports `ruby-mode', both main JavaScript modes,
+;; and C/C++ modes treating the former ones as subsets of the latter.
;; To enable it elsewhere, customize `hes-simple-modes'.
@@ -40,11 +43,19 @@
"Highlight escape sequences"
:group 'convenience)
+(defface hes-escape-sequence-face
+ '((default :inherit font-lock-regexp-grouping-construct))
+ "Face to highlight an escape sequence.")
+
+(defface hes-escape-backslash-face
+ '((default :inherit font-lock-regexp-grouping-backslash))
+ "Face to highlight an escape backslash.")
+
(defconst hes-escape-sequence-re
- "\\(\\\\\\(\\(?:[0-9]\\|x\\)\\(?:[0-9]\\(?:[0-9]\\)?\\)?\\|.\\)\\)"
+
"\\(\\\\\\(\\(?:U[[:xdigit:]]\\{8\\}\\)\\|\\(?:u[[:xdigit:]]\\{4\\}\\)\\|\\(?:x[[:xdigit:]]\\{2,\\}\\)\\|\\(?:[0-7]\\{1,3\\}\\)\\|.\\)\\)"
"Regexp to match an escape sequence.
-Currently handles octals (\\123), hexadecimals (\\x12) and
-backslash followed by anything else.")
+Currently handles octals (\\123), hexadecimals (\\x12..Inf), unicode
+\(\\u1234 or \\U12345678), and backslash followed by anything else.")
(defconst hes-ruby-keywords
`((,hes-escape-sequence-re
@@ -55,16 +66,19 @@ backslash followed by anything else.")
(if (fboundp 'ruby-syntax-expansion-allowed-p)
(ruby-syntax-expansion-allowed-p state)
(memq term '(?\" ?/ ?\n ?` t))))
- 'font-lock-regexp-grouping-backslash))
+ 'hes-escape-backslash-face))
prepend))))
(defconst hes-simple-keywords
`((,hes-escape-sequence-re
(1 (when (nth 3 (syntax-ppss))
- 'font-lock-regexp-grouping-backslash)
- prepend))))
+ 'hes-escape-backslash-face)
+ prepend)
+ (2 (when (nth 3 (syntax-ppss))
+ 'hes-escape-sequence-face)
+ prepend))))
-(defcustom hes-simple-modes '(js-mode js2-mode)
+(defcustom hes-simple-modes '(js-mode js2-mode c-mode c++-mode)
"Modes where escape sequences can appear in any string literal."
:type '(repeat function)
:set (lambda (symbol value)
- [elpa] master updated (2a0dbe5 -> 0e74c8c), Dmitry Gutov, 2016/10/28
- [elpa] master 7777860 03/27: Autoload the mode function, Dmitry Gutov, 2016/10/28
- [elpa] master 74340d0 02/27: hes-ruby-keywords, fallback predicate: Allow in backquoted literals, Dmitry Gutov, 2016/10/28
- [elpa] master 4425527 04/27: hes-simple-mode setter: Fix initialization; turn on when needed, Dmitry Gutov, 2016/10/28
- [elpa] master f7a0074 06/27: Wrong words on the screenshot, Dmitry Gutov, 2016/10/28
- [elpa] master 0df3e63 12/27: Remove explicit group, Dmitry Gutov, 2016/10/28
- [elpa] master 6bc14c4 16/27: Beautify hes-ruby-escape-sequence-keywords, Dmitry Gutov, 2016/10/28
- [elpa] master 828cdbb 08/27: Improve regexp and add two faces,
Dmitry Gutov <=
- [elpa] master fc8f4e7 01/27: Initial commit, Dmitry Gutov, 2016/10/28
- [elpa] master 8098664 05/27: Add readme and screenshot, Dmitry Gutov, 2016/10/28
- [elpa] master 5d45ca5 13/27: Fix the Author: header, Dmitry Gutov, 2016/10/28
- [elpa] master a031ee2 20/27: Add Emacs Lisp and Clojure (same as Java), Dmitry Gutov, 2016/10/28
- [elpa] master 083954e 19/27: Restore compatibility with earlier Emacsen, Dmitry Gutov, 2016/10/28
- [elpa] master 20d3190 22/27: Update copyright, Dmitry Gutov, 2016/10/28
- [elpa] master 02b8d09 10/27: Add more specific regexps, Dmitry Gutov, 2016/10/28
- [elpa] master 9c80a93 18/27: Merge pull request #1 from dev-plvlml/master, Dmitry Gutov, 2016/10/28
- [elpa] master 72c3cdc 07/27: Change wording, Dmitry Gutov, 2016/10/28
- [elpa] master 1e79174 11/27: Fix extra indent, Dmitry Gutov, 2016/10/28