Skip to content

Commit 0817e36

Browse files
committed
Make php-imenu-generic-expression accept symbol of variable name
1 parent c1843b1 commit 0817e36

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

lisp/php-mode.el

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,9 @@ After setting the stylevars run hooks according to STYLENAME
11951195
(add-hook 'syntax-propertize-extend-region-functions
11961196
#'php-syntax-propertize-extend-region t t)
11971197

1198-
(setq imenu-generic-expression php-imenu-generic-expression)
1198+
(setq imenu-generic-expression (if (symbolp php-imenu-generic-expression)
1199+
(symbol-value php-imenu-generic-expression)
1200+
php-imenu-generic-expression))
11991201

12001202
;; PHP vars are case-sensitive
12011203
(setq case-fold-search t)

lisp/php.el

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,12 @@ can be used to match against definitions for that classlike."
396396
"^\\s-*function\\s-+\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1)))
397397
"Imenu generic expression for PHP Mode. See `imenu-generic-expression'.")
398398

399-
(defcustom php-imenu-generic-expression php-imenu-generic-expression-default
399+
(defcustom php-imenu-generic-expression 'php-imenu-generic-expression-default
400400
"Default Imenu generic expression for PHP Mode. See `imenu-generic-expression'."
401-
:type '(alist :key-type string
402-
:value-type list)
401+
:type '(choice (alist :key-type string :value-type list)
402+
(const 'php-imenu-generic-expression-legacy)
403+
(const 'php-imenu-generic-expression-simple)
404+
variable)
403405
:group 'php)
404406

405407
(defconst php--re-namespace-pattern

tests/php-mode-test.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,10 @@ style from Drupal."
320320
(with-php-mode-test ("issue-83.php")
321321
(let* ((index-alist (imenu--make-index-alist))
322322
(all-methods (mapcar 'car (cdr (assoc "Methods" index-alist)))))
323-
(should (member "static public function staticBeforeVisibility()" all-methods))
324-
(should (member "public static function staticAfterVisibility()" all-methods)))))
323+
(should (equal all-methods
324+
(list
325+
"static public function staticBeforeVisibility()"
326+
"public static function staticAfterVisibility()"))))))
325327

326328
(ert-deftest php-mode-test-issue-99 ()
327329
"Proper indentation for 'foreach' statements without braces."

0 commit comments

Comments
 (0)