@@ -660,13 +660,14 @@ but only if the setting is enabled."
660
660
'+ )
661
661
(t nil )))))))
662
662
663
- (defun php-c-looking-at-or-maybe-in-bracelist (&optional _containing -sexp lim )
663
+ (defun php-c-looking-at-or-maybe-in-bracelist (orig-fun &optional containing -sexp lim )
664
664
" Replace `c-looking-at-or-maybe-in-bracelist' .
665
665
666
666
CONTAINING-SEXP is the position of the brace/paren/bracket enclosing
667
667
POINT, or nil if there is no such position, or we do not know it. LIM is
668
668
a backward search limit."
669
669
(cond
670
+ ((not (derived-mode-p 'php-mode )) (apply orig-fun containing-sexp lim args))
670
671
((looking-at-p " {" )
671
672
(save-excursion
672
673
(c-backward-token-2 2 t lim)
@@ -994,20 +995,19 @@ HEREDOC-START."
994
995
995
996
(eval-and-compile
996
997
(defconst php-syntax-propertize-rules
997
- `((php-heredoc-start-re
998
- (0 (ignore (php--syntax-propertize-heredoc
999
- (match-beginning 0 )
1000
- (or (match-string 1 ) (match-string 2 ) (match-string 3 ))
1001
- (null (match-string 3 ))))))
1002
- (,(rx " #[" )
1003
- (0 (ignore (php--syntax-propertize-attributes (match-beginning 0 )))))
1004
- (,(rx (or " '" " \" " ))
1005
- (0 (ignore (php--syntax-propertize-quotes-in-comment (match-beginning 0 )))))))
1006
-
1007
- (defmacro php-build-propertize-function ()
1008
- `(byte-compile (syntax-propertize-rules ,@php-syntax-propertize-rules )))
1009
-
1010
- (defalias 'php-syntax-propertize-function (php-build-propertize-function)))
998
+ (syntax-propertize-precompile-rules
999
+ (php-heredoc-start-re
1000
+ (0 (ignore (php--syntax-propertize-heredoc
1001
+ (match-beginning 0 )
1002
+ (or (match-string 1 ) (match-string 2 ) (match-string 3 ))
1003
+ (null (match-string 3 ))))))
1004
+ ((rx " #[" )
1005
+ (0 (ignore (php--syntax-propertize-attributes (match-beginning 0 )))))
1006
+ ((rx (or " '" " \" " ))
1007
+ (0 (ignore (php--syntax-propertize-quotes-in-comment (match-beginning 0 ))))))))
1008
+
1009
+ (defalias 'php-syntax-propertize-function
1010
+ (syntax-propertize-rules php-syntax-propertize-rules))
1011
1011
1012
1012
(defun php--syntax-propertize-heredoc (start id _is-heredoc )
1013
1013
" Apply propertize Heredoc and Nowdoc from START, with ID and IS-HEREDOC."
@@ -1208,7 +1208,7 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'."
1208
1208
(progn
1209
1209
(add-hook 'hack-local-variables-hook #'php-mode-set-style-delay t t )
1210
1210
(setq php-mode--delayed-set-style t )
1211
- (advice-add # 'c-set-style :after #'php-mode--disable-delay-set-style '(local) ))
1211
+ (advice-add 'c-set-style :after #'php-mode--disable-delay-set-style ))
1212
1212
(let ((php-mode-enable-backup-style-variables nil ))
1213
1213
(php-set-style (symbol-name php-mode-coding-style))))
1214
1214
@@ -1242,15 +1242,12 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'."
1242
1242
php-mode-replace-flymake-diag-function)
1243
1243
(add-hook 'flymake-diagnostic-functions php-mode-replace-flymake-diag-function nil t ))
1244
1244
1245
- (when (fboundp 'c-looking-at-or-maybe-in-bracelist )
1246
- (advice-add #'c-looking-at-or-maybe-in-bracelist
1247
- :override 'php-c-looking-at-or-maybe-in-bracelist '(local)))
1248
- (advice-add #'fixup-whitespace :after #'php-mode--fixup-whitespace-after '(local))
1245
+ (advice-add 'c-looking-at-or-maybe-in-bracelist
1246
+ :around 'php-c-looking-at-or-maybe-in-bracelist )
1247
+ (advice-add 'fixup-whitespace :after #'php-mode--fixup-whitespace-after )
1249
1248
1250
- (when (fboundp #'acm-backend-tabnine-candidate-expand )
1251
- (advice-add #'acm-backend-tabnine-candidate-expand
1252
- :filter-args #'php-acm-backend-tabnine-candidate-expand-filter-args
1253
- '(local)))
1249
+ (advice-add 'acm-backend-tabnine-candidate-expand
1250
+ :filter-args #'php-acm-backend-tabnine-candidate-expand-filter-args )
1254
1251
1255
1252
(when (>= emacs-major-version 25 )
1256
1253
(with-silent-modifications
@@ -1558,22 +1555,25 @@ The output will appear in the buffer *PHP*."
1558
1555
; ;; logic of `fixup-whitespace' .
1559
1556
(defun php-mode--fixup-whitespace-after ()
1560
1557
" Remove whitespace before certain characters in PHP Mode."
1561
- (when (or (looking-at-p " \\ (?:;\\ |,\\ |->\\ |::\\ )" )
1562
- (save-excursion
1563
- (forward-char -2 )
1564
- (looking-at-p " ->\\ |::" )))
1558
+ (when (and (derived-mode-p 'php-mode )
1559
+ (or (looking-at-p " \\ (?:;\\ |,\\ |->\\ |::\\ )" )
1560
+ (save-excursion
1561
+ (forward-char -2 )
1562
+ (looking-at-p " ->\\ |::" ))))
1565
1563
(delete-char 1 )))
1566
1564
1567
1565
; ; Advice for lsp-bridge' acm-backend-tabnine
1568
1566
; ; see https://github.com/manateelazycat/lsp-bridge/issues/402#issuecomment-1305653058
1569
1567
(defun php-acm-backend-tabnine-candidate-expand-filter-args (args )
1570
1568
" Adjust to replace bound-start ARGS for Tabnine in PHP."
1571
- (cl-multiple-value-bind (candidate-info bound-start) args
1572
- (save-excursion
1573
- (goto-char bound-start)
1574
- (when (looking-at-p (eval-when-compile (regexp-quote " $" )))
1575
- (setq bound-start (1+ bound-start))))
1576
- (list candidate-info bound-start)))
1569
+ (if (not (derived-mode-p 'php-mode ))
1570
+ args
1571
+ (cl-multiple-value-bind (candidate-info bound-start) args
1572
+ (save-excursion
1573
+ (goto-char bound-start)
1574
+ (when (looking-at-p (eval-when-compile (regexp-quote " $" )))
1575
+ (setq bound-start (1+ bound-start))))
1576
+ (list candidate-info bound-start))))
1577
1577
1578
1578
;;;### autoload
1579
1579
(progn
0 commit comments