[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/jade-mode 62c012c8d6 039/128: Improved Stylus comments syn
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/jade-mode 62c012c8d6 039/128: Improved Stylus comments syntax highlighting. |
Date: |
Sat, 29 Jan 2022 08:24:45 -0500 (EST) |
branch: elpa/jade-mode
commit 62c012c8d6f668cad3fe7cc1b3b77129133a5124
Author: Jaakko Pallari <jkpl@lepovirta.org>
Commit: Jaakko Pallari <jkpl@lepovirta.org>
Improved Stylus comments syntax highlighting.
Since Stylus supports both single line ("//") and multi line ("/* */")
comments, I modified the syntax table so that it supports both comment
styles.
I also initialized the stylus-font-lock-keywords variable using defvar.
---
stylus-mode.el | 41 +++++++++++++++++++++++------------------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/stylus-mode.el b/stylus-mode.el
index 857b4b786a..ca9748b8ab 100644
--- a/stylus-mode.el
+++ b/stylus-mode.el
@@ -39,19 +39,18 @@
'("return" "if" "else" "unless" "for" "in" "true" "false")))
"Stylus keywords.")
-(setq stylus-font-lock-keywords
- `(
- (,"^[ {2,}]+[a-z0-9_:\\-]+[ ]" 0 font-lock-variable-name-face)
- (,"^//.*" 0 font-lock-comment-face)
-
(,"\\(::?\\(root\\|nth-child\\|nth-last-child\\|nth-of-type\\|nth-last-of-type\\|first-child\\|last-child\\|first-of-type\\|last-of-type\\|only-child\\|only-of-type\\|empty\\|link\\|visited\\|active\\|hover\\|focus\\|target\\|lang\\|enabled\\|disabled\\|checked\\|not\\)\\)*"
. font-lock-type-face) ;; pseudoSelectors
- (,(concat "[^_$]?\\<\\(" stylus-colours "\\)\\>[^_]?")
- 0 font-lock-constant-face)
- (,(concat "[^_$]?\\<\\(" stylus-keywords "\\)\\>[^_]?")
- 0 font-lock-keyword-face)
-
(,"\\([0-9]+:?\\(em\\|ex\\|px\\|mm\\|cm\\|in\\|pt\\|pc\\|deg\\|rad\\|grad\\|ms\\|s\\|Hz\\|kHz\\|rem\\|%\\)\\)"
0 font-lock-constant-face)
- (,"#\\w+" 0 font-lock-keyword-face)
- (,"$\\w+" 0 font-lock-variable-name-face)
- ))
+(defvar stylus-font-lock-keywords
+ `(
+ (,"^[ {2,}]+[a-z0-9_:\\-]+[ ]" 0 font-lock-variable-name-face)
+
(,"\\(::?\\(root\\|nth-child\\|nth-last-child\\|nth-of-type\\|nth-last-of-type\\|first-child\\|last-child\\|first-of-type\\|last-of-type\\|only-child\\|only-of-type\\|empty\\|link\\|visited\\|active\\|hover\\|focus\\|target\\|lang\\|enabled\\|disabled\\|checked\\|not\\)\\)*"
. font-lock-type-face) ;; pseudoSelectors
+ (,(concat "[^_$]?\\<\\(" stylus-colours "\\)\\>[^_]?")
+ 0 font-lock-constant-face)
+ (,(concat "[^_$]?\\<\\(" stylus-keywords "\\)\\>[^_]?")
+ 0 font-lock-keyword-face)
+
(,"\\([0-9]+:?\\(em\\|ex\\|px\\|mm\\|cm\\|in\\|pt\\|pc\\|deg\\|rad\\|grad\\|ms\\|s\\|Hz\\|kHz\\|rem\\|%\\)\\)"
0 font-lock-constant-face)
+ (,"#\\w+" 0 font-lock-keyword-face)
+ (,"$\\w+" 0 font-lock-variable-name-face)
+ ))
(defun stylus-region-for-sexp ()
"Selects the current sexp as the region"
@@ -78,6 +77,16 @@
(setq mode-name "Stylus")
(setq major-mode 'stylus-mode)
+ ;; highlight syntax
+ (setq font-lock-defaults '(stylus-font-lock-keywords))
+
+ ;; comments
+ (modify-syntax-entry ?\/ ". 124b")
+ (modify-syntax-entry ?* ". 23")
+ (modify-syntax-entry ?\n "> b")
+ (set (make-local-variable 'comment-start) "//")
+ (set (make-local-variable 'comment-end) "")
+
;; default tab width
(setq sws-tab-width 2)
(make-local-variable 'indent-line-function)
@@ -86,12 +95,8 @@
(setq indent-region-function 'sws-indent-region)
-
;; keymap
- (use-local-map stylus-mode-map)
-
- ;; highlight syntax
- (setq font-lock-defaults '(stylus-font-lock-keywords)))
+ (use-local-map stylus-mode-map))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.styl$" . stylus-mode))
- [nongnu] elpa/jade-mode e621d186c1 080/128: Merge pull request #36 from tjefferson08/remove_hl_after_tags, (continued)
- [nongnu] elpa/jade-mode e621d186c1 080/128: Merge pull request #36 from tjefferson08/remove_hl_after_tags, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 449df109fc 074/128: fix unbound variable reference in let binding, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 279df56bf9 100/128: add some tests for indentation (new file), ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 932a2fef33 095/128: [#46] start unit test file for highlighting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 473d29b5c2 091/128: move doctype in rendering order, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 8a25dd6702 024/128: Merge pull request #4 from travisjeffery/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 41351ec293 027/128: Add autoload declarations, explicit requires and ELPA package dependencies., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode c513eded33 045/128: the string doctype now works as a doctype keyword., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode a1cbadd84d 026/128: add .el file headers to enable automatic packaging - closes gh#6, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 4d2f58abd7 044/128: Merge https://github.com/brianc/jade-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 62c012c8d6 039/128: Improved Stylus comments syntax highlighting.,
ELPA Syncer <=
- [nongnu] elpa/jade-mode 00c789673f 068/128: Closes #26. Fix inline '//' highlight as comment, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 8f61e0dc6a 040/128: Decimal point can be part of a constant., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 109b9850d2 041/128: Created a syntax table for Stylus mode., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode f540df5ee6 056/128: Merge pull request #16 from tardyp/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 275ab149ed 051/128: Merge pull request #11 from jkpl/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode d90ad2cc02 036/128: Add syntax table entry for single line comment., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 05d671fcdb 057/128: Add comment syntax to allow for M-x (un)comment-region., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 351f756569 083/128: [#37] Highlight string lit. manually - Closes #37, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode a90b512c6e 086/128: [#39] add two functions to hl JS blocks, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 57ab4d6555 085/128: [#39] add JS examples to highlight, ELPA Syncer, 2022/01/29