Skip to content

Commit 52f8297

Browse files
committed
Make php-mode inherit from php-base-mode instead of c-mode
1 parent 0b598a9 commit 52f8297

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this
99
* Add `php-base-mode` which is the base of php related modes ([#772])
1010
* `php-base-mode` is designed as a common parent mode for `php-mode` and [`php-ts-mode`](https://github.com/emacs-php/php-ts-mode).
1111

12+
### Changed
13+
14+
* Make `php-mode` inherit from `php-base-mode` instead of `c-mode` ([#772])
15+
1216
[#772]: https://github.com/emacs-php/php-mode/pull/772
1317

1418
## [1.25.1] - 2023-11-24

lisp/php-mode.el

+14-5
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ as a function. Call with AS-NUMBER keyword to compare by `version<'.
327327

328328
(defvar php-mode-map
329329
(let ((map (make-sparse-keymap "PHP Mode")))
330+
(set-keymap-parent map c-mode-base-map)
330331
;; Remove menu item for c-mode
331332
(define-key map [menu-bar C] nil)
332333

@@ -1150,14 +1151,14 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'."
11501151
table))
11511152

11521153
;;;###autoload
1153-
(define-derived-mode php-mode c-mode "PHP"
1154+
(define-derived-mode php-mode php-base-mode "PHP"
11541155
"Major mode for editing PHP code.
11551156
11561157
\\{php-mode-map}"
11571158
:syntax-table php-mode-syntax-table
1158-
;; :after-hook (c-update-modeline)
1159-
;; (setq abbrev-mode t)
1160-
1159+
:after-hook (progn (c-make-noise-macro-regexps)
1160+
(c-make-macro-with-semi-re)
1161+
(c-update-modeline))
11611162
(unless (string= php-mode-cc-version c-version)
11621163
(php-mode-debug-reinstall nil))
11631164

@@ -1168,8 +1169,16 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'."
11681169
:warning))
11691170

11701171
(c-initialize-cc-mode t)
1172+
(setq abbrev-mode t)
1173+
1174+
;; Must be called once as c-mode to enable font-lock for Heredoc.
1175+
;; TODO: This call may be removed in the future.
1176+
(c-common-init 'c-mode)
1177+
11711178
(c-init-language-vars php-mode)
11721179
(c-common-init 'php-mode)
1180+
(cc-imenu-init cc-imenu-c-generic-expression)
1181+
11731182
(setq-local c-auto-align-backslashes nil)
11741183

11751184
(setq-local comment-start "// ")
@@ -1252,7 +1261,7 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'."
12521261
(advice-add 'acm-backend-tabnine-candidate-expand
12531262
:filter-args #'php-acm-backend-tabnine-candidate-expand-filter-args)
12541263

1255-
(when (>= emacs-major-version 25)
1264+
(when (eval-when-compile (>= emacs-major-version 25))
12561265
(with-silent-modifications
12571266
(save-excursion
12581267
(let* ((start (point-min))

0 commit comments

Comments
 (0)