emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/jade-mode cb82d16486 017/128: jade-mode depends on sws-mod


From: ELPA Syncer
Subject: [nongnu] elpa/jade-mode cb82d16486 017/128: jade-mode depends on sws-mode
Date: Sat, 29 Jan 2022 08:24:42 -0500 (EST)

branch: elpa/jade-mode
commit cb82d16486dfd45847c4306273620c020d1518c2
Author: Brian Carlson <brian.m.carlson@gmail.com>
Commit: Brian Carlson <brian.m.carlson@gmail.com>

    jade-mode depends on sws-mode
---
 jade-mode.el | 82 ++++++++++--------------------------------------------------
 1 file changed, 13 insertions(+), 69 deletions(-)

diff --git a/jade-mode.el b/jade-mode.el
index c5be348a50..4fdfd160f0 100644
--- a/jade-mode.el
+++ b/jade-mode.el
@@ -1,8 +1,6 @@
 ;; copied from http://xahlee.org/emacs/elisp_syntax_coloring.html
 (require 'font-lock)
 
-(defvar jade-tab-width 2)
-
 (defun jade-debug (string &rest args)
   "Prints a debug message"
   (apply 'message (append (list string) args)))
@@ -12,20 +10,6 @@
   `(buffer-substring (point-at-bol) (point-at-eol)))
 
 
-(defun jade-indent-line ()
-  "Indents current line")
-
-(defun jade-previous-indentation ()
-  "Gets indentation for previous line"
-  (save-excursion
-    (previous-line)
-    (current-indentation)))
-
-(defun jade-should-indent-p ()
-  "Whether or not line should be indented."
-  ;; should only indent if previous line is indented at most one less
-  (> (jade-previous-indentation) (- (current-indentation) 1)))
-
 (defun jade-empty-line-p ()
   "If line is empty or not."
   (= (point-at-eol) (point-at-bol)))
@@ -34,45 +18,6 @@
   "If line contains only spaces."
   (string-match-p "^[ ]*$" (jade-line-as-string)))
 
-(defun jade-indent-line ()
-  "Indents the line."
-  (interactive)
-
-  ;; indent straight to end on empty line
-  (if (jade-empty-line-p)
-      (indent-to (jade-previous-indentation))
-    ;; otherwise indent if nesting is correct
-    (save-excursion
-      (if (jade-should-indent-p)
-          (let ((ci (current-indentation)))
-            (beginning-of-line)
-            (delete-horizontal-space)
-            (indent-to (+ jade-tab-width ci)))
-        ;; if cannot indent, reset indentation
-        (progn
-          (beginning-of-line)
-          (delete-horizontal-space)))))
-  ;; move point to end of line on empty lines to make tabbing
-  ;; more obvious
-  (if (jade-blank-line-p)
-      (move-end-of-line 1)))
-
-(defun jade-max-indent ()
-  "Max indents previous line."
-  (indent-to (+ jade-tab-width (jade-previous-indentation))))
-
-(defun jade-unindent-line ()
-  "Unindents the current line"
-  (interactive)
-  (let ((ci (current-indentation)))
-    (if (= ci 0)
-        ;; no indentation, set to max
-        (jade-max-indent)
-      (progn
-        (beginning-of-line)
-        (delete-horizontal-space)
-        (indent-to (- ci jade-tab-width))))))
-
 (setq jade-font-lock-keywords
       `((,"!!!\\( \\(default\\|5\\|transitional\\)\\)?" 0 
font-lock-constant-face) ;; doctype
         (,"#\\(\\w\\|_\\|-\\)*" . font-lock-type-face) ;; id
@@ -80,12 +25,6 @@
         (,"\\(?:^[ {2,}]+\\(?:[a-z0-9_:\\-]*\\)\\)?\\(\\.[A-Za-z0-9\-\_]*\\)" 
1 font-lock-function-name-face) ;; class name
         (,"^[ {2,}]+[a-z0-9_:\\-]*" 0 font-lock-comment-face)))
 
-(defun jade-next-line-indent ()
-  "Gets indentation level for next line."
-  (save-excursion
-    (next-line)
-    (current-indentation)))
-
 (defun jade-region-for-sexp ()
   "Selects the current sexp as the region"
   (interactive)
@@ -97,10 +36,11 @@
       (end-of-line))))
 
 (defvar jade-mode-map (make-sparse-keymap))
-(define-key jade-mode-map [S-tab] 'jade-unindent-line)
+;;defer to sws-mode
+;;(define-key jade-mode-map [S-tab] 'jade-unindent-line)
 
 ;; mode declaration
-(define-derived-mode jade-mode fundamental-mode
+(define-derived-mode jade-mode sws-mode
   "Jade"
   "Major mode for editing jade node.js templates"
   (kill-all-local-variables)
@@ -109,16 +49,20 @@
   (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)
+
+
   ;; keymap
   (use-local-map jade-mode-map)
 
   ;; highlight syntax
-  (setq font-lock-defaults '(jade-font-lock-keywords))
-
-  (make-local-variable 'indent-line-function)
-  (setq indent-line-function 'jade-indent-line)
-  ;; no tabs
-  (setq indent-tabs-mode nil))
+  (setq font-lock-defaults '(jade-font-lock-keywords)))
 
 (provide 'jade-mode)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]