Skip to content

Commit bec22bf

Browse files
authored
Merge pull request #530 from emacs-php/refactor/php-mode-var
Fix php-mode variables
2 parents 9e96a34 + 4f766f2 commit bec22bf

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

php-mode.el

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,8 @@ This is was done due to the problem reported here:
843843
ret)))
844844

845845
(defun php-c-vsemi-status-unknown-p ()
846-
"See `php-c-at-vsemi-p'."
847-
)
846+
"Always return NIL. See `php-c-at-vsemi-p'."
847+
nil)
848848

849849
(defun php-lineup-string-cont (langelem)
850850
"Line up string toward equal sign or dot.
@@ -996,11 +996,23 @@ After setting the stylevars run hooks according to STYLENAME
996996
(prog1 (php-set-style (symbol-name coding-style))
997997
(remove-hook 'hack-local-variables-hook #'php-mode-set-style-delay)))))
998998

999+
(defvar php-mode-syntax-table
1000+
(let ((table (make-syntax-table)))
1001+
(c-populate-syntax-table table)
1002+
(modify-syntax-entry ?_ "_" table)
1003+
(modify-syntax-entry ?` "\"" table)
1004+
(modify-syntax-entry ?\" "\"" table)
1005+
(modify-syntax-entry ?# "< b" table)
1006+
(modify-syntax-entry ?\n "> b" table)
1007+
(modify-syntax-entry ?$ "'" table)
1008+
table))
1009+
9991010
;;;###autoload
10001011
(define-derived-mode php-mode c-mode "PHP"
10011012
"Major mode for editing PHP code.
10021013
10031014
\\{php-mode-map}"
1015+
:syntax-table php-mode-syntax-table
10041016
;; :after-hook (c-update-modeline)
10051017
;; (setq abbrev-mode t)
10061018
(when php-mode-disable-c-mode-hook
@@ -1010,6 +1022,15 @@ After setting the stylevars run hooks according to STYLENAME
10101022
(c-init-language-vars php-mode)
10111023
(c-common-init 'php-mode)
10121024

1025+
(setq-local comment-start "// ")
1026+
(setq-local comment-start-skip
1027+
(eval-when-compile
1028+
(rx (group (or (: "#")
1029+
(: "/" (+ "/"))
1030+
(: "/*")))
1031+
(* (syntax whitespace)))))
1032+
(setq-local comment-end "")
1033+
10131034
(setq-local font-lock-string-face 'php-string)
10141035
(setq-local font-lock-keyword-face 'php-keyword)
10151036
(setq-local font-lock-builtin-face 'php-builtin)
@@ -1018,13 +1039,6 @@ After setting the stylevars run hooks according to STYLENAME
10181039
(setq-local font-lock-variable-name-face 'php-variable-name)
10191040
(setq-local font-lock-constant-face 'php-constant)
10201041

1021-
(modify-syntax-entry ?_ "_" php-mode-syntax-table)
1022-
(modify-syntax-entry ?` "\"" php-mode-syntax-table)
1023-
(modify-syntax-entry ?\" "\"" php-mode-syntax-table)
1024-
(modify-syntax-entry ?# "< b" php-mode-syntax-table)
1025-
(modify-syntax-entry ?\n "> b" php-mode-syntax-table)
1026-
(modify-syntax-entry ?$ "'" php-mode-syntax-table)
1027-
10281042
(setq-local syntax-propertize-function #'php-syntax-propertize-function)
10291043
(add-to-list (make-local-variable 'syntax-propertize-extend-region-functions)
10301044
#'php-syntax-propertize-extend-region)
@@ -1054,12 +1068,8 @@ After setting the stylevars run hooks according to STYLENAME
10541068

10551069
(setq indent-line-function 'php-cautious-indent-line)
10561070
(setq indent-region-function 'php-cautious-indent-region)
1057-
(setq c-at-vsemi-p-fn 'php-c-at-vsemi-p)
1058-
(setq c-vsemi-status-unknown-p 'php-c-vsemi-status-unknown-p)
1059-
1060-
;; syntax-begin-function is obsolete in Emacs 25.1
1061-
(with-no-warnings
1062-
(setq-local syntax-begin-function 'c-beginning-of-syntax))
1071+
(setq c-at-vsemi-p-fn #'php-c-at-vsemi-p)
1072+
(setq c-vsemi-status-unknown-p-fn #'php-c-vsemi-status-unknown-p)
10631073

10641074
;; We map the php-{beginning,end}-of-defun functions so that they
10651075
;; replace the similar commands that we inherit from CC Mode.

0 commit comments

Comments
 (0)