diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mode-def.el | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/mode-def.el b/src/mode-def.el index 104ace2..1b4358e 100644 --- a/src/mode-def.el +++ b/src/mode-def.el @@ -19,7 +19,7 @@ "Find the left bound of an emmet expr" (save-excursion (save-match-data (let ((char (char-before)) - (in-style-attr (looking-back "style=[\"'][^\"']*")) + (in-style-attr (looking-back "style=[\"'][^\"']*" nil)) (syn-tab (make-syntax-table))) (modify-syntax-entry ?\\ "\\") (while char @@ -474,12 +474,20 @@ accept it or skip it." (defun emmet-wrap-with-markup (wrap-with) "Wrap region with markup." (interactive "sExpression to wrap with: ") - (let* ((to-wrap (buffer-substring-no-properties (region-beginning) (region-end))) - (expr (concat wrap-with ">{!EMMET-TO-WRAP-REPLACEMENT!}")) - (markup (replace-regexp-in-string - "!EMMET-TO-WRAP-REPLACEMENT!" to-wrap - (emmet-transform expr) - t t))) + (let* ((multi (string-match "\\*$" wrap-with)) + (txt (buffer-substring-no-properties (region-beginning) (region-end))) + (to-wrap (if multi + (split-string txt "\n") + (list txt))) + (initial-elements (replace-regexp-in-string "\\(.*>\\)?[^>*]+\\*?$" "\\1" wrap-with)) + (terminal-element (replace-regexp-in-string "\\(.*>\\)?\\([^>*]+\\)\\*?$" "\\2" wrap-with)) + (expr (concat + initial-elements + (mapconcat (lambda (el) (concat terminal-element "{" el "}")) to-wrap "+"))) + + (markup (emmet-transform expr)) + (debug-shit (message "initial-elements: %s\nterminal-element: %s\n expr: %s\n markup: %s" initial-elements terminal-element expr markup)) + ) (when markup (delete-region (region-beginning) (region-end)) (insert markup) @@ -503,4 +511,3 @@ accept it or skip it." (error "First edit point reached."))) (provide 'emmet-mode) - |