From d435866599736398b612a5d054fca7b7acc8d230 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 18 Aug 2019 03:06:58 +0900 Subject: [PATCH 1/5] Add save-match-data macro to php-get-current-element --- php.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/php.el b/php.el index b56f47c6..860370ed 100644 --- a/php.el +++ b/php.el @@ -244,8 +244,9 @@ can be used to match against definitions for that classlike." (defun php-get-current-element (re-pattern) "Return backward matched element by RE-PATTERN." (save-excursion - (when (re-search-backward re-pattern nil t) - (match-string-no-properties 1)))) + (save-match-data + (when (re-search-backward re-pattern nil t) + (match-string-no-properties 1))))) ;;; Provide support for Flymake so that users can see warnings and ;;; errors in real-time as they write code. From 88316f73e7112fe07fe5b684c252e64936253a0b Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 18 Aug 2019 03:07:23 +0900 Subject: [PATCH 2/5] Add type conversion for arg compatibility --- php.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/php.el b/php.el index 860370ed..540c3f55 100644 --- a/php.el +++ b/php.el @@ -175,6 +175,8 @@ The regular expression this function returns will check for other keywords that can appear in method signatures, e.g. 'final' and 'static'. The regular expression will have one capture group which will be the name of the method." + (when (stringp visibility) + (setq visibility (list visibility))) (rx-form `(: line-start (* (syntax whitespace)) ,@(if visibility From 489dcb9bdf4d6b84eb65e79ad34ef33e1384ff66 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 18 Aug 2019 03:29:18 +0900 Subject: [PATCH 3/5] Modify php-beginning-of-defun-regexp pattern for capturing name --- php.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php.el b/php.el index 540c3f55..5e2c7bc5 100644 --- a/php.el +++ b/php.el @@ -160,7 +160,7 @@ it is the character that will terminate the string, or t if the string should be (symbol-value 'poly-php-html-mode))) (defconst php-beginning-of-defun-regexp - "^\\s-*\\(?:\\(?:abstract\\|final\\|private\\|protected\\|public\\|static\\)\\s-+\\)*function\\s-+&?\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" + "^\\s-*\\(?:\\(?:abstract\\|final\\|private\\|protected\\|public\\|static\\)\\s-+\\)*function\\s-+&?\\(\\(\\sw\\|\\s_\\)+\\)\\s-*(" "Regular expression for a PHP function.") (eval-when-compile From 116926d09970022589251bb03cc51de38ee7955a Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 18 Aug 2019 03:30:15 +0900 Subject: [PATCH 4/5] Add new command php-copyit-fqsen for copy(kill) FQSEN --- php.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/php.el b/php.el index 5e2c7bc5..5abd11b2 100644 --- a/php.el +++ b/php.el @@ -352,6 +352,17 @@ Look at the `php-executable' variable instead of the constant \"php\" command." (when matched (insert (concat matched php-namespace-suffix-when-insert))))) +;;;###autoload +(defun php-copyit-fqsen () + "Copy/kill class/method FQSEN." + (interactive) + (let ((namespace (or (php-get-current-element php--re-namespace-pattern) "")) + (class (or (php-get-current-element php--re-classlike-pattern) "")) + (namedfunc (php-get-current-element php-beginning-of-defun-regexp))) + (kill-new (concat (if (string= namespace "") "" namespace) + (if (string= class "") "" (concat "\\" class "::")) + (if (string= namedfunc "") "" (concat namedfunc "()")))))) + ;;;###autoload (defun php-run-builtin-web-server (router-or-dir hostname port &optional document-root) "Run PHP Built-in web server. From 4d87f5eb3466a713b3519b71bc6fd203a28f9699 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 18 Aug 2019 03:34:59 +0900 Subject: [PATCH 5/5] Fix php-create-regexp-for-method pattern --- php.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/php.el b/php.el index 5abd11b2..bda5a73d 100644 --- a/php.el +++ b/php.el @@ -187,10 +187,11 @@ which will be the name of the method." (* (or "abstract" "final" "static") (+ (syntax whitespace)))) '((* (* (or "abstract" "final" "static" - "private" "protected" "public")) - (+ (syntax whitespace))))) + "private" "protected" "public") + (+ (syntax whitespace)))))) "function" (+ (syntax whitespace)) + (? "&" (* (syntax whitespace))) (group (+ (or (syntax word) (syntax symbol)))) (* (syntax whitespace)) "(")))