Created
March 14, 2019 13:59
-
-
Save kzkn/a0db226b2429fe28feeae63cbcd56f5a to your computer and use it in GitHub Desktop.
ssass-mode を使いやすくする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun ssass-indent () | |
"Indent the current line." | |
(interactive) | |
(indent-line-to | |
(cond | |
((and (not ssass-indent-blanks) (ssass--whitespace-p 0)) 0) | |
((ssass--whitespace-p -1) 0) | |
((ssass--no-anchor-line-p) 0) | |
((ssass--comma-before-p) (ssass--last-anchor-line-indent-level)) | |
;; ここが増えた。セレクタ行は自動インデントしない | |
((ssass--selector-p (buffer-substring (point-at-bol) (point-at-eol))) | |
(current-indentation)) | |
(t | |
(+ ssass-tab-width (ssass--last-anchor-line-indent-level)))))) | |
(defun my/ssass-dedent (n) | |
(interactive "p") | |
(if (= (point) (+ (point-at-bol) (current-indentation))) | |
(ssass-dedent) | |
(delete-backward-char n))) | |
(defun my/ssass-indent-cyclic () | |
(interactive) | |
(let* ((curr (current-indentation)) | |
(curr (- curr (mod curr ssass-tab-width))) | |
(next (+ curr ssass-tab-width)) | |
(max-indent (+ ssass-tab-width (ssass--last-anchor-line-indent-level)))) | |
(indent-line-to (if (< max-indent next) | |
0 | |
next)))) | |
;; [backspace] としたいところだけど効かなかった | |
(bind-key "\177" 'my/ssass-dedent ssass-mode-map) | |
(bind-key "C-i" 'my/ssass-indent-cyclic ssass-mode-map) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment