Add narf/scss-toggle-inline-or-block

This commit is contained in:
Henrik Lissner 2015-07-19 00:44:01 +02:00
parent 9b4a46f76c
commit f8a384e5e2
2 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,21 @@
;;; defuns-scss.el
;;;###autoload
(defun narf/scss-toggle-inline-or-block ()
"Toggles between a SCSS multiline block and one-line block."
(interactive)
(save-excursion
(let* ((bounds (ignore-errors (evil-a-curly)))
(beg (car bounds))
(end (cadr bounds)))
(goto-char beg)
(unless bounds
(user-error "No block found"))
(if (= (line-number-at-pos beg) (line-number-at-pos end))
(progn (replace-regexp ";[\s\t]*" ";\n" nil beg end)
(save-excursion (goto-char (1+ beg)) (insert "\n")
(evil-indent beg (+ 2 end))))
(evil-join beg end)))))
(provide 'defuns-scss)
;;; defuns-scss.el ends here

View file

@ -17,6 +17,12 @@
(add-hook! scss-mode (setenv "jsbeautify_indent_size" "2")) (add-hook! scss-mode (setenv "jsbeautify_indent_size" "2"))
(bind! :map scss-mode-map :m "gQ" 'web-beautify-css)) (bind! :map scss-mode-map :m "gQ" 'web-beautify-css))
(after! emr
(emr-declare-command 'narf/scss-toggle-inline-or-block
:title "toggle inline/block"
:modes 'scss-mode
:predicate (lambda () (not (use-region-p)))))
(after! company (add-company-backend! scss-mode (css)))) (after! company (add-company-backend! scss-mode (css))))
(use-package rainbow-mode (use-package rainbow-mode