From unknown Wed Aug 20 04:11:35 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#71380 <71380@debbugs.gnu.org> To: bug#71380 <71380@debbugs.gnu.org> Subject: Status: 30.0.50; Submitting php-ts-mode, new major mode for php Reply-To: bug#71380 <71380@debbugs.gnu.org> Date: Wed, 20 Aug 2025 11:11:35 +0000 retitle 71380 30.0.50; Submitting php-ts-mode, new major mode for php reassign 71380 emacs submitter 71380 Vincenzo Pupillo severity 71380 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 05 10:10:16 2024 Received: (at submit) by debbugs.gnu.org; 5 Jun 2024 14:10:16 +0000 Received: from localhost ([127.0.0.1]:37577 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sErLA-0000Aq-Dx for submit@debbugs.gnu.org; Wed, 05 Jun 2024 10:10:16 -0400 Received: from lists.gnu.org ([209.51.188.17]:46442) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sErB1-00087O-VT for submit@debbugs.gnu.org; Wed, 05 Jun 2024 09:59:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sErAn-0003Mm-IO for bug-gnu-emacs@gnu.org; Wed, 05 Jun 2024 09:59:29 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sErAi-0000DI-IZ for bug-gnu-emacs@gnu.org; Wed, 05 Jun 2024 09:59:29 -0400 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-57a4d7ba501so2382612a12.2 for ; Wed, 05 Jun 2024 06:59:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717595963; x=1718200763; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Bre665WrohqzdeMj0Y8LLbujVj2td/A8fcB1Yiyvghk=; b=EFTZLEYxivXcLN6/zMXNHLdTHMWJOqpQI6xmAR1dGy4tCFNqIvzyscqANQW3LOlaSh 9O/AO/97V28byCmT8UKe7/mo1tA/RI3yMWkTo8D7nNyNslVkmzN3/+d2wOOXwjvzAo+g pFgTyivtii7weetMstfPPdJWNWHAphOGu20PhJbhx1C8iABNhy2iuOwafe9bGkY+eQS2 ZzQ+UI5a/JnNCbNPK6muIMeQ96aMXPTtL/tg8OJt5TNUPUyl8CTXQx/4CoRDUEB6GpD+ Y6RMAJvEd99+AnZPQlHChrE5HBg92iLxZUVw6ricoXnffxYOYYhjpEuRUduudF2o0Ej/ riOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717595963; x=1718200763; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Bre665WrohqzdeMj0Y8LLbujVj2td/A8fcB1Yiyvghk=; b=xPEzSkd/w7vb6Ieg+Tl4xcmgcxP0/GnLFLZEJZJuoXd7hkUTfxG1sS2EUlzHHgxC7p RNWbe/ebSurGA+BvOzzQppZd40FZhbvYvM5JNSoTt5sKnXNf511iZPHlUxGEdQrOAImU phkXoWcS98Q7quJYcWr5Gy3gzkatOyLPzUvhVvMIF3pEq1DXNcLyJSm+8Pp3Xxonz8KX VZQM+lOI7M5ogDnxyPvVV1bPbker08P6Nibii7sO2T287OGgvQ6/9H961bfQwLfxZPNu P/aYsfL0v+52YBBdyDX3HYqqE2eowZ/Ah9/g0iJBbyEy3RlZqlZecQGdWKD1mF56D4hT 77gQ== X-Gm-Message-State: AOJu0YygN1c1rlw0pIPkmqb2hFm+ihpypqC1LgII/xr+MCPz057DRvh4 Je1TQBraNyp/vGi2B55ziJtIRqVbpWgdhrJlyyiEU21W8ubsf4+DY7WN9w== X-Google-Smtp-Source: AGHT+IEczMiToUXkEoqPULsPXbjDDyi5yI16YNRlgpbmKRRVImkAGdvTH67Ipnblks9K+us1fb98OQ== X-Received: by 2002:a50:d698:0:b0:579:c08b:afa9 with SMTP id 4fb4d7f45d1cf-57a8b6b0dfcmr1801847a12.11.1717595962351; Wed, 05 Jun 2024 06:59:22 -0700 (PDT) Received: from 3-191.divsi.unimi.it (3-191.divsi.unimi.it. [159.149.3.191]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57a7f1a4d7esm3397592a12.68.2024.06.05.06.59.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 06:59:21 -0700 (PDT) From: Vincenzo Pupillo To: bug-gnu-emacs@gnu.org Subject: 30.0.50; Submitting php-ts-mode, new major mode for php Date: Wed, 05 Jun 2024 15:59:20 +0200 Message-ID: <3686989.dWV9SEqChM@3-191.divsi.unimi.it> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart5707500.rdbgypaU67" Content-Transfer-Encoding: 7Bit Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=v.pupillo@gmail.com; helo=mail-ed1-x529.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --nextPart5707500.rdbgypaU67 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Hi, I would like to submit php-ts-mode. This major mode this major mode, in addition to font-lock for PHP implements the following features: * font-lock for html, javascript, css and phpdoc. * six different indentation styles (PSR, PEAR, Zend, Drupal, Wordpress, Symfony). * Imenu * Flymake * Which-function * a helper function to simplify the installation of parsers, in versions used to develop major-mode * PHP built-in server support * Shell interaction: execute PHP code in an inferior PHP process. I completed the assignment process in March 2023. Thank you. Vincenzo --nextPart5707500.rdbgypaU67 Content-Disposition: attachment; filename="0001-Add-php-ts-mode.patch" Content-Transfer-Encoding: quoted-printable Content-Type: text/x-patch; charset="x-UTF_8J"; name="0001-Add-php-ts-mode.patch" =46rom 430382668698b299040699785ba9ea0279f85a5f Mon Sep 17 00:00:00 2001 =46rom: Vincenzo Pupillo Date: Wed, 5 Jun 2024 15:54:37 +0200 Subject: [PATCH] Add php-ts-mode * etc/NEWS: Mention the new mode. * lisp/progmodes/php-ts-mode.el: New file. =2D-- etc/NEWS | 5 + lisp/progmodes/php-ts-mode.el | 1640 +++++++++++++++++++++++++++++++++ 2 files changed, 1645 insertions(+) create mode 100644 lisp/progmodes/php-ts-mode.el diff --git a/etc/NEWS b/etc/NEWS index 922721f143c..72abedb043a 100644 =2D-- a/etc/NEWS +++ b/etc/NEWS @@ -1926,6 +1926,11 @@ A major mode based on the tree-sitter library for ed= iting Elixir files. *** New major mode 'lua-ts-mode'. A major mode based on the tree-sitter library for editing Lua files. =20 +--- +*** New major mode 'php-ts-mode'. +A major mode based on the tree-sitter library for editing + + ** Minibuffer and Completions =20 +++ diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el new file mode 100644 index 00000000000..bb036fa6dad =2D-- /dev/null +++ b/lisp/progmodes/php-ts-mode.el @@ -0,0 +1,1640 @@ +;;; php-ts-mode.el --- Major mode PHP using tree-sitter -*- lexical-bindin= g: t; -*- + +;; Copyright (C) 2024 Free Software Foundation, Inc. + +;; Author: Vincenzo Pupillo +;; Created: Jun 2024 +;; Keywords: PHP language tree-sitter + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: +;; +;; This package provides `php-ts-mode' which is a major mode +;; for editing PHP files with embedded HTML, JavaScript, CSS and phpdoc. +;; Tree Sitter is used to parse each of these languages. +;; +;; This package is compatible and has been tested with the following +;; tree-sitter grammars: +;; * https://github.com/tree-sitter/tree-sitter-php +;; * https://github.com/tree-sitter/tree-sitter-html +;; * https://github.com/tree-sitter/tree-sitter-javascript +;; * https://github.com/tree-sitter/tree-sitter-css +;; * https://github.com/claytonrcarter/tree-sitter-phpdoc +;; +;; Features +;; +;; * Indent +;; * IMenu +;; * Navigation +;; * Which-function +;; * Flymake +;; * Tree-sitter parser installation helper +;; * PHP built-in server support +;; * Shell interaction: execute PHP code in a inferior PHP process + +;;; Code: + +(require 'treesit) +(require 'c-ts-common) ;; For comment indent and filling. +(require 'html-ts-mode) ;; For embed html +(require 'css-mode) ;; for embed css into html +(require 'js) ;; for embed javascript into html +(require 'comint) + +(eval-when-compile + (require 'cl-lib) + (require 'rx) + (require 'subr-x)) + +(declare-function treesit-node-child "treesit.c") +(declare-function treesit-node-child-by-field-name "treesit.c") +(declare-function treesit-node-end "treesit.c") +(declare-function treesit-node-parent "treesit.c") +(declare-function treesit-node-start "treesit.c") +(declare-function treesit-node-string "treesit.c") +(declare-function treesit-node-type "treesit.c") +(declare-function treesit-parser-add-notifier "treesit.c") +(declare-function treesit-parser-buffer "treesit.c") +(declare-function treesit-parser-create "treesit.c") +(declare-function treesit-parser-included-ranges "treesit.c") +(declare-function treesit-parser-list "treesit.c") +(declare-function treesit-parser-language "treesit.c") + +;;; Install treesitter language parsers +(defvar php-ts-mode--language-source-alist + '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.22.5")) + (phpdoc . ("https://github.com/claytonrcarter/tree-sitter-phpdoc")) + (html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.20.3")) + (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript"= "v0.21.2")) + (css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.21.0"))) + "Treesitter language parsers required by `php-ts-mode'. +You can customize this variable if you want to stick to a specific +commit and/or use different parsers.") + +(defun php-ts-mode-install-parsers () + "Install all the required treesitter parser. +`php-ts-mode--language-source-alist' define which parsers to install." + (interactive) + (let ((treesit-language-source-alist php-ts-mode--language-source-alist)) + (dolist (item php-ts-mode--language-source-alist) + (treesit-install-language-grammar (car item))))) + +;;; Custom variables + +(defgroup php-ts-mode nil + "Major mode for editing PHP files." + :prefix "php-ts-mode-" + :group 'languages) + +(defcustom php-ts-mode-indent-offset 4 + "Number of spaces for each indentation step (default) in `php-ts-mode'." + :tag "PHP indent offset" + :version "30.1" + :type 'integer + :safe 'integerp) + +(defcustom php-ts-mode-js-css-indent-offset html-ts-mode-indent-offset + "JavaScript and CSS indent spaces related to the