bug#81663: 31.1; [PATCH] Do not indent if <?php is preceded by a shebang or a comment.
Vincenzo Pupillo <[email protected]>
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
Ciao, this patch fixes the indentation of PHP code when it is preceded by a shebang or a comment, for example: - without this patch #!/bin/bash # test # test <?php echo "a"; - with this patch: #!/bin/bash # test # test <?php echo "a"; Thanks. Vincenzo
0001-Do-not-indent-if-php-is-preceded-by-a-shebang-or-a-c.patch
(text/x-patch, 1.2 KB)
From 9c6789d165621e2ff7f47c63e87337209fd44897 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo <[email protected]> Date: Thu, 20 Aug 2026 16:09:22 +0200 Subject: [PATCH] Do not indent if <?php is preceded by a shebang or a comment. * lisp/progmodes/php-ts-mode.el (php-ts-mode--parent-html-heuristic): Do not indent if <?php is preceded by a shebang or a comment. --- lisp/progmodes/php-ts-mode.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el index dee26915a31..1a14837b2d5 100644 --- a/lisp/progmodes/php-ts-mode.el +++ b/lisp/progmodes/php-ts-mode.el @@ -607,9 +607,10 @@ php-ts-mode--parent-html-heuristic ;; of the "text" node (backward-word) (back-to-indentation) - (if php-ts-mode-html-relative-indent - (+ (point) php-ts-html-indent-offset) - (point))))))) + (cond + ((eq (face-at-point (point)) 'font-lock-comment-face) (point)) ; shebang or comment before <?php + (php-ts-mode-html-relative-indent (+ (point) php-ts-html-indent-offset)) + (t (point)))))))) (defun php-ts-mode--array-element-heuristic (_node parent _bol &rest _) "Return of the position of the first element of the array. -- 2.55.0