[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/jade-mode c6623ac6a6 021/128: added a basic stylus-mode
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/jade-mode c6623ac6a6 021/128: added a basic stylus-mode |
Date: |
Sat, 29 Jan 2022 08:24:42 -0500 (EST) |
branch: elpa/jade-mode
commit c6623ac6a67d1df147c82c52ea413367ac1b63d6
Author: mmichelli <mario@edison.no>
Commit: mmichelli <mario@edison.no>
added a basic stylus-mode
---
stylus-mode.el | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
diff --git a/stylus-mode.el b/stylus-mode.el
new file mode 100644
index 0000000000..853b39e3ae
--- /dev/null
+++ b/stylus-mode.el
@@ -0,0 +1,90 @@
+;; copied from http://xahlee.org/emacs/elisp_syntax_coloring.html
+(require 'font-lock)
+
+(defun stylus-debug (string &rest args)
+ "Prints a debug message"
+ (apply 'message (append (list string) args)))
+
+(defmacro stylus-line-as-string ()
+ "Returns the current line as a string."
+ `(buffer-substring (point-at-bol) (point-at-eol)))
+
+
+(defun stylus-empty-line-p ()
+ "If line is empty or not."
+ (= (point-at-eol) (point-at-bol)))
+
+(defun stylus-blank-line-p ()
+ "If line contains only spaces."
+ (string-match-p "^[ ]*$" (stylus-line-as-string)))
+
+(defconst stylus-colours
+ (eval-when-compile
+ (regexp-opt
+ '("black" "silver" "gray" "white" "maroon" "red"
+ "purple" "fuchsia" "green" "lime" "olive" "yellow" "navy"
+ "blue" "teal" "aqua")))
+ "Stylus keywords.")
+
+(defconst stylus-keywords
+ (eval-when-compile
+ (regexp-opt
+ '("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)
+ ))
+
+(defun stylus-region-for-sexp ()
+ "Selects the current sexp as the region"
+ (interactive)
+ (beginning-of-line)
+ (let ((ci (current-indentation)))
+ (push-mark nil nil t)
+ (while (> (stylus-next-line-indent) ci)
+ (next-line)
+ (end-of-line))))
+
+(defvar stylus-mode-map (make-sparse-keymap))
+;;defer to sws-mode
+;;(define-key stylus-mode-map [S-tab] 'stylus-unindent-line)
+
+;; mode declaration
+(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)
+
+ ;; 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)
+
+
+ ;; keymap
+ (use-local-map stylus-mode-map)
+
+ ;; highlight syntax
+ (setq font-lock-defaults '(stylus-font-lock-keywords)))
+
+(provide 'stylus-mode)
+
+(add-to-list 'auto-mode-alist '("\\.styl$" . stylus-mode))
- [nongnu] branch elpa/jade-mode created (now 1ad7c51f3c), ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 7a36edb480 002/128: added readme, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 63561e36f7 006/128: functional line indentation logic, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode f8b5b062a0 005/128: started work on electric tab, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 684a5c0fba 014/128: require whitespace-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 63f6e54b85 013/128: define backtab for ubuntu, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode c6623ac6a6 021/128: added a basic stylus-mode,
ELPA Syncer <=
- [nongnu] elpa/jade-mode 039b637cee 016/128: new blank line + single tab = full indent, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode b8778ae525 015/128: use builtin for moving point to beginning of text, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode de66308323 004/128: reboot, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode a22d4acd31 001/128: initial commit, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode a7c85da4df 048/128: Added single quoted strings support to stylus mode., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 3db33f4642 050/128: Fixed sws-indent-line not detecting the use of tab indent, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode eea90de1df 038/128: Add support for keywords syntax coloring., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode dd7becb0fb 062/128: Merge pull request #25 from gavinpc/patch-1, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 0eb59822bf 081/128: Merge pull request #35 from tjefferson08/add_new_comment_syntax, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 2e75549657 058/128: Merge pull request #18 from abutcher/comment-syntax, ELPA Syncer, 2022/01/29