branch: elpa/jade-mode
commit 4d2f58abd7442297083707a6c675324fa90aeebd
Merge: eea90de1df 18dfef2623
Author: Shawn Krisman <skrisman@nodelings>
Commit: Shawn Krisman <skrisman@nodelings>
Merge https://github.com/brianc/jade-mode
Conflicts:
jade-mode.el
---
jade-mode.el | 10 ++++++++++
stylus-mode.el | 50 +++++++++++++++++++++++++++++++-------------------
2 files changed, 41 insertions(+), 19 deletions(-)
diff --git a/jade-mode.el b/jade-mode.el
index b1dab1c438..57a16cae4e 100644
--- a/jade-mode.el
+++ b/jade-mode.el
@@ -87,6 +87,16 @@ For detail, see `comment-dwim'."
(setq mode-name "Jade")
(setq major-mode 'jade-mode)
+ ;; default tab width
+ (setq sws-tab-width 2)
+ (make-local-variable 'indent-line-function)
+ (setq indent-line-function 'sws-indent-line)
+ (make-local-variable 'indent-region-function)
+
+ (setq indent-region-function 'sws-indent-region)
+
+ (setq indent-tabs-mode nil)
+
;; keymap
(use-local-map jade-mode-map)
diff --git a/stylus-mode.el b/stylus-mode.el
index 857b4b786a..63eef0b6d0 100644
--- a/stylus-mode.el
+++ b/stylus-mode.el
@@ -39,19 +39,26 @@
'("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)
+ ))
+
+(defvar stylus-syntax-table
+ (let ((syntable (make-syntax-table)))
+ (modify-syntax-entry ?\/ ". 124b" syntable)
+ (modify-syntax-entry ?* ". 23" syntable)
+ (modify-syntax-entry ?\n "> b" syntable)
+ syntable)
+ "Syntax table for `stylus-mode'.")
(defun stylus-region-for-sexp ()
"Selects the current sexp as the region"
@@ -72,12 +79,21 @@
(define-derived-mode stylus-mode sws-mode
"Stylus"
"Major mode for editing stylus node.js templates"
- (kill-all-local-variables)
(setq tab-width 2)
(setq mode-name "Stylus")
(setq major-mode 'stylus-mode)
+ ;; syntax table
+ (set-syntax-table stylus-syntax-table)
+
+ ;; highlight syntax
+ (setq font-lock-defaults '(stylus-font-lock-keywords))
+
+ ;; comments
+ (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 +102,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))