Add narf/scss-toggle-inline-or-block
This commit is contained in:
parent
9b4a46f76c
commit
f8a384e5e2
2 changed files with 27 additions and 0 deletions
21
modules/lib/defuns-scss.el
Normal file
21
modules/lib/defuns-scss.el
Normal 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
|
|
@ -17,6 +17,12 @@
|
|||
(add-hook! scss-mode (setenv "jsbeautify_indent_size" "2"))
|
||||
(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))))
|
||||
|
||||
(use-package rainbow-mode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue