From b9d7f07b1a3824e117fd82370a41801399f4aae8 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Tue, 1 Apr 2025 02:10:30 +0900 Subject: [PATCH 1/2] Addreadonly class modifier to imenu --- CHANGELOG.md | 9 ++++++++- lisp/php.el | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aa2e9cc..61154bc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,14 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. - +## Unreleased + +### Changed + + * Add `readonly` class modifier to [Imenu] ([#802]) + +[Imenu]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Imenu.html +[#802]: https://github.com/emacs-php/php-mode/pull/802 ## [1.27.0] - 2024-12-20 diff --git a/lisp/php.el b/lisp/php.el index 2e05d2a5..c3491fa9 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -325,12 +325,18 @@ can be used to match against definitions for that classlike." ;; First see if 'abstract' or 'final' appear, although really these ;; are not valid for all values of `type' that the function ;; accepts. - "^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?" + (eval-when-compile + (rx line-start + (* (syntax whitespace)) + (? (or "abstract" "final" "readonly") + (+ (syntax whitespace))))) ;; The classlike type type ;; Its name, which is the first captured group in the regexp. We ;; allow backslashes in the name to handle namespaces, but again ;; this is not necessarily correct for all values of `type'. + ;; (rx (+ (syntax whitespace)) + ;; (group (+ (or (syntax word) "\\" (syntax symbol))))) "\\s-+\\(\\(?:\\sw\\|\\\\\\|\\s_\\)+\\)"))) (defconst php-imenu-generic-expression-default From 4a42c293d7644bf1129d6327c5d3d2de721b45bc Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Tue, 1 Apr 2025 02:10:55 +0900 Subject: [PATCH 2/2] Add `enum` support to `php-current-class` --- CHANGELOG.md | 1 + lisp/php.el | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61154bc3..feb711f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this ### Changed * Add `readonly` class modifier to [Imenu] ([#802]) + * Add `enum` support to `php-current-class` ([#802]) [Imenu]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Imenu.html [#802]: https://github.com/emacs-php/php-mode/pull/802 diff --git a/lisp/php.el b/lisp/php.el index c3491fa9..6a2f40f8 100644 --- a/lisp/php.el +++ b/lisp/php.el @@ -471,7 +471,7 @@ can be used to match against definitions for that classlike." (defconst php--re-classlike-pattern (eval-when-compile - (php-create-regexp-for-classlike (regexp-opt '("class" "interface" "trait"))))) + (php-create-regexp-for-classlike (regexp-opt '("class" "interface" "trait" "enum"))))) (defvar php--analysis-syntax-table (eval-when-compile