[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/php-mode 7ff913f3b6 3/4: Merge pull request #772 from emac
|
From: |
ELPA Syncer |
|
Subject: |
[nongnu] elpa/php-mode 7ff913f3b6 3/4: Merge pull request #772 from emacs-php/feature/php-base-mode |
|
Date: |
Tue, 28 Nov 2023 16:00:11 -0500 (EST) |
branch: elpa/php-mode
commit 7ff913f3b6b044e1aa5cda1c5da00278a820468a
Merge: f7beda8e0a 52f8297606
Author: USAMI Kenta <tadsan@pixiv.com>
Commit: GitHub <noreply@github.com>
Merge pull request #772 from emacs-php/feature/php-base-mode
Make php-mode inherit from php-base-mode instead of c-mode
---
CHANGELOG.md | 13 ++++++++++++-
lisp/php-mode.el | 19 ++++++++++++++-----
lisp/php.el | 9 +++++++++
3 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3ffd269358..649c813212 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,18 @@
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 -->
+## Unreleased
+
+### Added
+
+ * 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
diff --git a/lisp/php-mode.el b/lisp/php-mode.el
index 022b2a62f0..e19faea8ce 100644
--- a/lisp/php-mode.el
+++ b/lisp/php-mode.el
@@ -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)
@@ -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))
@@ -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 "// ")
@@ -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))
diff --git a/lisp/php.el b/lisp/php.el
index 3c5f34901c..8fa7a6d56f 100644
--- a/lisp/php.el
+++ b/lisp/php.el
@@ -627,6 +627,15 @@ Look at the `php-executable' variable instead of the
constant \"php\" command."
(setq mode nil)))
(or mode php-default-major-mode)))
+;;;###autoload
+(define-derived-mode php-base-mode prog-mode "PHP"
+ "Generic major mode for editing PHP.
+
+This mode is intended to be inherited by concrete major modes.
+Currently there are `php-mode' and `php-ts-mode'."
+ :group 'php
+ nil)
+
;;;###autoload
(defun php-mode-maybe ()
"Select PHP mode or other major mode."