Function: php-ts-mode--comment-indent-new-line

php-ts-mode--comment-indent-new-line is a byte-compiled function defined in php-ts-mode.el.gz.

Signature

(php-ts-mode--comment-indent-new-line &optional SOFT)

Documentation

Break line at point and indent, continuing comment if within one.

Like c-ts-common-comment-indent-new-line, but handle the less common PHP-style # comment. SOFT works the same as in comment-indent-new-line.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/php-ts-mode.el.gz
;;; Filling

(defun php-ts-mode--comment-indent-new-line (&optional soft)
  "Break line at point and indent, continuing comment if within one.
Like `c-ts-common-comment-indent-new-line', but handle the
less common PHP-style # comment.  SOFT works the same as in
`comment-indent-new-line'."
  (if (save-excursion
	;; Line start with # or ## or ###...
	(beginning-of-line)
	(re-search-forward
	 (rx "#" (group (* (any "#")) (* " ")))
	 (line-end-position)
	 t nil))
      (let ((offset (- (match-beginning 0) (line-beginning-position)))
	    (comment-prefix (match-string 0))
	    (insert-line-break
	     (lambda ()
	       (delete-horizontal-space)
	       (if soft
		   (insert-and-inherit ?\n)
		 (newline  1)))))
	(funcall insert-line-break)
	(delete-region (line-beginning-position) (point))
	(insert
	 (make-string offset ?\s)
	 comment-prefix))
    ;; other style of comments
    (c-ts-common-comment-indent-new-line soft)))