Function: web-mode-element-extract

web-mode-element-extract is an interactive and natively compiled function defined in web-mode.el.

Signature

(web-mode-element-extract)

Documentation

Flatten element.

Key Bindings

web-mode-map C-c C-e +

Source Code

;; Defined in /nix/store/2qgnz1rp30nzfz6w0apx4kdm14if1bbs-emacs-packages-deps/share/emacs/site-lisp/elpa/web-mode-20260831.219/web-mode.el
(defun web-mode-element-extract ()
  "Flatten element."
  (interactive)
  (let (beg end (continue t) save boundaries)
    (cond
      ((or (not (get-text-property (point) 'tag-type))
           (not (member (get-text-property (point) 'tag-type) '(start end))))
       (web-mode-element-parent))
      ((eq (get-text-property (point) 'tag-type) 'end)
       (web-mode-tag-match))
      ) ;cond
    (setq boundaries (web-mode-element-boundaries (point)))
    (setq beg (car (car boundaries))
          end (cdr (cdr boundaries)))
    (goto-char beg)
    (while continue
      (if (or (not (and (or (get-text-property (point) 'tag-type) (web-mode-tag-next))
                        (web-mode-tag-end)))
              (>= (point) end))
          (setq continue nil)
          (setq save (point))
          ;;(message "point(%S)" (point))
          (skip-chars-forward "\n\t ")
          (when (get-text-property (point) 'tag-type)
            (newline)
            (indent-according-to-mode)
            (setq end (+ end (- (point) save))))
          ) ;if
      ) ;while
    (goto-char beg)
    ))