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
|
Loading…
Add table
Add a link
Reference in a new issue