Function: php-ts-mode--comment-setup

php-ts-mode--comment-setup is a byte-compiled function defined in php-ts-mode.el.gz.

Signature

(php-ts-mode--comment-setup &optional FORCE)

Documentation

Set up local variables for comments.

If FORCE is t setup comment for PHP. Depends on mhtml-ts-mode--comment-setup and mhtml-ts-mode--comment-current-lang.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/php-ts-mode.el.gz
(defun php-ts-mode--comment-setup (&optional force)
  "Set up local variables for comments.
If FORCE is t setup comment for PHP.  Depends on
`mhtml-ts-mode--comment-setup' and
`mhtml-ts-mode--comment-current-lang'."
  (let ((lang (treesit-language-at (point))))
    (if (and (or (eq lang 'php) (eq lang 'phpdoc) force)
	     (eq (plist-get php-ts-mode--comment-current-plist :php) nil))
	;; do setup only if the previous language isn't PHP
	(progn
	  (plist-put php-ts-mode--comment-current-plist :php t)
	  (c-ts-common-comment-setup)
	  (setq-local c-ts-common--comment-regexp "comment"
		      comment-line-break-function #'php-ts-mode--comment-indent-new-line
		      comment-style 'extra-line
		      comment-start (plist-get php-ts-mode--comment-current-plist :comment-start)
		      comment-end (plist-get php-ts-mode--comment-current-plist :comment-end)
		      comment-start-skip (rx (or (seq "#" (not (any "[")))
						 (seq "/" (+ "/"))
						 (seq "/" (+ "*")))
					     (* (syntax whitespace)))
		      ;; reset the state of mhtml-ts-mode--comment-setup
		      mhtml-ts-mode--comment-current-lang nil))
      ;; otherwise set comment style for other languages.
      (plist-put php-ts-mode--comment-current-plist :php nil)
      (setq-local comment-style 'indent) ; this is the default for mhtml-ts-mode.
      (mhtml-ts-mode--comment-setup))))