Function: web-mode-fill-paragraph

web-mode-fill-paragraph is a natively compiled function defined in web-mode.el.

Signature

(web-mode-fill-paragraph &optional JUSTIFY)

Source Code

;; Defined in /nix/store/2qgnz1rp30nzfz6w0apx4kdm14if1bbs-emacs-packages-deps/share/emacs/site-lisp/elpa/web-mode-20260831.219/web-mode.el
;;---- EFFECTS -----------------------------------------------------------------

(defun web-mode-fill-paragraph (&optional _justify)
  (save-excursion
    (let ((pos (point))
          prop pair beg end delim-beg delim-end chunk fill-coll)
      (ignore delim-beg delim-end fill-coll)
      (cond
        ((or (eq (get-text-property pos 'part-token) 'comment)
             (eq (get-text-property pos 'block-token) 'comment))
         (setq prop
               (if (get-text-property pos 'part-token) 'part-token 'block-token))
         (setq pair (web-mode-property-boundaries prop pos))
         (when (and pair (> (- (cdr pair) (car pair)) 6))
           (setq fill-coll (if (< fill-column 10) 70 fill-column))
           (setq beg (car pair)
                 end (cdr pair))
           (goto-char beg)
           (setq chunk (buffer-substring-no-properties beg (+ beg 2)))
           (cond
             ((string= chunk "//")
              (setq delim-beg "//"
                    delim-end "EOL"))
             ((string= chunk "/*")
              (setq delim-beg "/*"
                    delim-end "*/"))
             ((string= chunk "{#")
              (setq delim-beg "{#"
                    delim-end "#}"))
             ((string= chunk "<!")
              (setq delim-beg "<!--"
                    delim-end "-->"))
             )
           )
         ) ;comment - case
        ((web-mode-is-content)
         (setq pair (web-mode-content-boundaries pos))
         (setq beg (car pair)
               end (cdr pair))
         )
        ) ;cond
      ;;(message "beg(%S) end(%S)" beg end)
      (when (and beg end)
        (fill-region beg end))
      t)))