emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/php-mode 9896cccd64 13/13: Merge pull request #740 from em


From: ELPA Syncer
Subject: [nongnu] elpa/php-mode 9896cccd64 13/13: Merge pull request #740 from emacs-php/apply-monnier-patch
Date: Mon, 10 Apr 2023 10:03:18 -0400 (EDT)

branch: elpa/php-mode
commit 9896cccd647fc85106cc4c6cfd3f0a0833854a24
Merge: e515cc9d0e 4b03e9b956
Author: USAMI Kenta <tadsan@pixiv.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #740 from emacs-php/apply-monnier-patch
    
    Apply Stefan Monnier's patch (3)
---
 lisp/php-mode.el | 68 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/lisp/php-mode.el b/lisp/php-mode.el
index cabb11cb09..b3ea2d083c 100644
--- a/lisp/php-mode.el
+++ b/lisp/php-mode.el
@@ -660,13 +660,14 @@ but only if the setting is enabled."
           '+)
          (t nil)))))))
 
-(defun php-c-looking-at-or-maybe-in-bracelist (&optional _containing-sexp lim)
+(defun php-c-looking-at-or-maybe-in-bracelist (orig-fun &optional 
containing-sexp lim)
   "Replace `c-looking-at-or-maybe-in-bracelist'.
 
 CONTAINING-SEXP is the position of the brace/paren/bracket enclosing
 POINT, or nil if there is no such position, or we do not know it.  LIM is
 a backward search limit."
   (cond
+   ((not (derived-mode-p 'php-mode)) (apply orig-fun containing-sexp lim args))
    ((looking-at-p "{")
     (save-excursion
       (c-backward-token-2 2 t lim)
@@ -994,20 +995,19 @@ HEREDOC-START."
 
 (eval-and-compile
   (defconst php-syntax-propertize-rules
-    `((php-heredoc-start-re
-       (0 (ignore (php--syntax-propertize-heredoc
-                   (match-beginning 0)
-                   (or (match-string 1) (match-string 2) (match-string 3))
-                   (null (match-string 3))))))
-      (,(rx "#[")
-       (0 (ignore (php--syntax-propertize-attributes (match-beginning 0)))))
-      (,(rx (or "'" "\"" ))
-       (0 (ignore (php--syntax-propertize-quotes-in-comment (match-beginning 
0)))))))
-
-  (defmacro php-build-propertize-function ()
-    `(byte-compile (syntax-propertize-rules ,@php-syntax-propertize-rules)))
-
-  (defalias 'php-syntax-propertize-function (php-build-propertize-function)))
+    (syntax-propertize-precompile-rules
+     (php-heredoc-start-re
+      (0 (ignore (php--syntax-propertize-heredoc
+                  (match-beginning 0)
+                  (or (match-string 1) (match-string 2) (match-string 3))
+                  (null (match-string 3))))))
+     ((rx "#[")
+      (0 (ignore (php--syntax-propertize-attributes (match-beginning 0)))))
+     ((rx (or "'" "\""))
+      (0 (ignore (php--syntax-propertize-quotes-in-comment (match-beginning 
0))))))))
+
+(defalias 'php-syntax-propertize-function
+  (syntax-propertize-rules php-syntax-propertize-rules))
 
 (defun php--syntax-propertize-heredoc (start id _is-heredoc)
   "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'."
       (progn
         (add-hook 'hack-local-variables-hook #'php-mode-set-style-delay t t)
         (setq php-mode--delayed-set-style t)
-        (advice-add #'c-set-style :after #'php-mode--disable-delay-set-style 
'(local)))
+        (advice-add 'c-set-style :after #'php-mode--disable-delay-set-style))
     (let ((php-mode-enable-backup-style-variables nil))
       (php-set-style (symbol-name php-mode-coding-style))))
 
@@ -1242,15 +1242,12 @@ After setting the stylevars run hook 
`php-mode-STYLENAME-hook'."
              php-mode-replace-flymake-diag-function)
     (add-hook 'flymake-diagnostic-functions 
php-mode-replace-flymake-diag-function nil t))
 
-  (when (fboundp 'c-looking-at-or-maybe-in-bracelist)
-    (advice-add #'c-looking-at-or-maybe-in-bracelist
-                :override 'php-c-looking-at-or-maybe-in-bracelist '(local)))
-  (advice-add #'fixup-whitespace :after #'php-mode--fixup-whitespace-after 
'(local))
+  (advice-add 'c-looking-at-or-maybe-in-bracelist
+              :around 'php-c-looking-at-or-maybe-in-bracelist)
+  (advice-add 'fixup-whitespace :after #'php-mode--fixup-whitespace-after)
 
-  (when (fboundp #'acm-backend-tabnine-candidate-expand)
-    (advice-add #'acm-backend-tabnine-candidate-expand
-                :filter-args 
#'php-acm-backend-tabnine-candidate-expand-filter-args
-                '(local)))
+  (advice-add 'acm-backend-tabnine-candidate-expand
+              :filter-args 
#'php-acm-backend-tabnine-candidate-expand-filter-args)
 
   (when (>= emacs-major-version 25)
     (with-silent-modifications
@@ -1558,22 +1555,25 @@ The output will appear in the buffer *PHP*."
 ;;; logic of `fixup-whitespace'.
 (defun php-mode--fixup-whitespace-after ()
   "Remove whitespace before certain characters in PHP Mode."
-  (when (or (looking-at-p " \\(?:;\\|,\\|->\\|::\\)")
-            (save-excursion
-              (forward-char -2)
-              (looking-at-p "->\\|::")))
+  (when (and (derived-mode-p 'php-mode)
+             (or (looking-at-p " \\(?:;\\|,\\|->\\|::\\)")
+                 (save-excursion
+                   (forward-char -2)
+                   (looking-at-p "->\\|::"))))
     (delete-char 1)))
 
 ;; Advice for lsp-bridge' acm-backend-tabnine
 ;; see 
https://github.com/manateelazycat/lsp-bridge/issues/402#issuecomment-1305653058
 (defun php-acm-backend-tabnine-candidate-expand-filter-args (args)
   "Adjust to replace bound-start ARGS for Tabnine in PHP."
-  (cl-multiple-value-bind (candidate-info bound-start) args
-    (save-excursion
-      (goto-char bound-start)
-      (when (looking-at-p (eval-when-compile (regexp-quote "$")))
-        (setq bound-start (1+ bound-start))))
-    (list candidate-info bound-start)))
+  (if (not (derived-mode-p 'php-mode))
+      args
+    (cl-multiple-value-bind (candidate-info bound-start) args
+      (save-excursion
+        (goto-char bound-start)
+        (when (looking-at-p (eval-when-compile (regexp-quote "$")))
+          (setq bound-start (1+ bound-start))))
+      (list candidate-info bound-start))))
 
 ;;;###autoload
 (progn



reply via email to

[Prev in Thread] Current Thread [Next in Thread]