lang/web: add +css/toggle-inline-or-block command
This commit is contained in:
parent
5f8cbd751a
commit
62e906cf19
1 changed files with 26 additions and 0 deletions
|
@ -5,3 +5,29 @@
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +css/sass-build ()) ; TODO
|
(defun +css/sass-build ()) ; TODO
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +css/toggle-inline-or-block ()
|
||||||
|
"Toggles between a bracketed block and inline block."
|
||||||
|
(interactive)
|
||||||
|
;; TODO Remove evil dependency
|
||||||
|
(save-excursion
|
||||||
|
(let* ((bounds (or (ignore-errors (evil-a-curly))
|
||||||
|
(user-error "No block found")))
|
||||||
|
(beg (car bounds))
|
||||||
|
(end (cadr bounds)))
|
||||||
|
(if (= (line-number-at-pos beg) (line-number-at-pos end))
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (1+ beg)) (insert "\n")
|
||||||
|
(unless (string-match ";[\s\t]*}$" (buffer-substring-no-properties beg (1+ end)))
|
||||||
|
(goto-char end) (insert "\n"))
|
||||||
|
(replace-regexp ";[\s\t]*" ";\n" nil beg (1+ end))
|
||||||
|
(setq end (cadr (evil-a-curly)))
|
||||||
|
(evil-indent beg end)
|
||||||
|
(delete-trailing-whitespace beg end))
|
||||||
|
(goto-char beg)
|
||||||
|
(evil-join beg end)
|
||||||
|
(goto-char (1+ beg))
|
||||||
|
(just-one-space)
|
||||||
|
(goto-char (cadr (evil-inner-curly)))
|
||||||
|
(just-one-space)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue