Skip to content

Commit

Permalink
Make php-mode inherit from php-base-mode instead of c-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
zonuexe committed Nov 28, 2023
1 parent 0b598a9 commit 52f8297
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this
* Add `php-base-mode` which is the base of php related modes ([#772])
* `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).

### Changed

* Make `php-mode` inherit from `php-base-mode` instead of `c-mode` ([#772])

[#772]: https://github.com/emacs-php/php-mode/pull/772

## [1.25.1] - 2023-11-24
Expand Down
19 changes: 14 additions & 5 deletions lisp/php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ as a function. Call with AS-NUMBER keyword to compare by `version<'.

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

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

;;;###autoload
(define-derived-mode php-mode c-mode "PHP"
(define-derived-mode php-mode php-base-mode "PHP"
"Major mode for editing PHP code.
\\{php-mode-map}"
:syntax-table php-mode-syntax-table
;; :after-hook (c-update-modeline)
;; (setq abbrev-mode t)

:after-hook (progn (c-make-noise-macro-regexps)
(c-make-macro-with-semi-re)
(c-update-modeline))
(unless (string= php-mode-cc-version c-version)
(php-mode-debug-reinstall nil))

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

(c-initialize-cc-mode t)
(setq abbrev-mode t)

;; Must be called once as c-mode to enable font-lock for Heredoc.
;; TODO: This call may be removed in the future.
(c-common-init 'c-mode)

(c-init-language-vars php-mode)
(c-common-init 'php-mode)
(cc-imenu-init cc-imenu-c-generic-expression)

(setq-local c-auto-align-backslashes nil)

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

(when (>= emacs-major-version 25)
(when (eval-when-compile (>= emacs-major-version 25))
(with-silent-modifications
(save-excursion
(let* ((start (point-min))
Expand Down

0 comments on commit 52f8297

Please sign in to comment.