Skip to content

Commit d4b7076

Browse files
committed
Add php-imenu-generic-expression-simple and php-imenu-generic-expression-legacy
1 parent 11d1c65 commit d4b7076

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this
99
* Support new PHP 8.0 and 8.1 syntax hilighting and indentation
1010
* [8.0] `#[Attributes]`
1111
* Add `php-imenu-generic-expression-default` for default value or `php-imenu-generic-expression`
12+
* Add `php-imenu-generic-expression-legacy` for compatibility
13+
* Add `php-imenu-generic-expression-simple` for simple display
1214

1315
### Changed
1416

lisp/php.el

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,70 @@ can be used to match against definitions for that classlike."
332332
,(php-create-regexp-for-classlike "namespace") 1)))
333333
"Imenu generic expression for PHP Mode. See `imenu-generic-expression'.")
334334

335+
(defconst php-imenu-generic-expression-simple
336+
(eval-when-compile
337+
`(("Methods"
338+
,(php-create-regexp-for-method nil) 2)
339+
("Properties"
340+
,(rx line-start
341+
(* (syntax whitespace))
342+
(+ (or "public" "protected" "private" "static" "var")
343+
(+ (syntax whitespace)))
344+
(* (? (? (or "|" "?"))
345+
(or "\\" (syntax word) (syntax symbol))
346+
(+ (syntax whitespace))))
347+
(group
348+
"$" (+ (or (syntax word) (syntax symbol))))
349+
word-boundary)
350+
1)
351+
("Constants"
352+
,(rx line-start
353+
(* (syntax whitespace))
354+
(group
355+
(* (or "public" "protected" "private")
356+
(+ (syntax whitespace)))
357+
"const"
358+
(+ (syntax whitespace))
359+
(+ (or (syntax word) (syntax symbol)))))
360+
1)
361+
("Functions"
362+
,(rx line-start
363+
(* (syntax whitespace))
364+
"function"
365+
(+ (syntax whitespace))
366+
(group
367+
(+ (or (syntax word) (syntax symbol)))))
368+
1)
369+
("Classes"
370+
,(php-create-regexp-for-classlike "\\(?:class\\|interface\\|trait\\|enum\\)") 1)
371+
("Namespace"
372+
,(php-create-regexp-for-classlike "namespace") 1)))
373+
"Imenu generic expression for PHP Mode. See `imenu-generic-expression'.")
374+
375+
(defconst php-imenu-generic-expression-legacy
376+
(eval-when-compile
377+
`(("Namespaces"
378+
,(php-create-regexp-for-classlike "namespace") 1)
379+
("Classes"
380+
,(php-create-regexp-for-classlike "class") 1)
381+
("Interfaces"
382+
,(php-create-regexp-for-classlike "interface") 1)
383+
("Traits"
384+
,(php-create-regexp-for-classlike "trait") 1)
385+
("All Methods"
386+
,(php-create-regexp-for-method) 1)
387+
("Private Methods"
388+
,(php-create-regexp-for-method '("private")) 2)
389+
("Protected Methods"
390+
,(php-create-regexp-for-method '("protected")) 2)
391+
("Public Methods"
392+
,(php-create-regexp-for-method '("public")) 2)
393+
("Anonymous Functions"
394+
"\\<\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*=\\s-*f\\(unctio\\)?n\\s-*(" 1)
395+
("Named Functions"
396+
"^\\s-*function\\s-+\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1)))
397+
"Imenu generic expression for PHP Mode. See `imenu-generic-expression'.")
398+
335399
(defcustom php-imenu-generic-expression php-imenu-generic-expression-default
336400
"Default Imenu generic expression for PHP Mode. See `imenu-generic-expression'."
337401
:type '(alist :key-type string

0 commit comments

Comments
 (0)