diff options
| author | Simeon Simeonov | 2019-05-27 09:57:43 +0200 |
|---|---|---|
| committer | Simeon Simeonov | 2019-05-27 09:57:43 +0200 |
| commit | aede1540a05b083908ef17ef4571569e0960dda0 (patch) | |
| tree | b5feddb1b88323e1a56aa3c1920b985895518165 | |
| parent | 415d6b9a9e26b7cb0ee8ca6d0ec384841b2359ec (diff) | |
Update php-mode
| -rw-r--r-- | .emacs.d/lisp/php-face.el | 77 | ||||
| -rw-r--r-- | .emacs.d/lisp/php-mode.el | 115 | ||||
| -rw-r--r-- | .emacs.d/lisp/php-project.el | 92 | ||||
| -rw-r--r-- | .emacs.d/lisp/php.el | 98 |
4 files changed, 278 insertions, 104 deletions
diff --git a/.emacs.d/lisp/php-face.el b/.emacs.d/lisp/php-face.el index e01d517..a674dd4 100644 --- a/.emacs.d/lisp/php-face.el +++ b/.emacs.d/lisp/php-face.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: USAMI Kenta <tadsan@zonu.me> | 5 | ;; Author: USAMI Kenta <tadsan@zonu.me> |
| 6 | ;; Created: 5 May 2019 | 6 | ;; Created: 5 May 2019 |
| 7 | ;; Version: 1.21.2 | 7 | ;; Version: 1.21.3 |
| 8 | ;; Keywords: faces, php | 8 | ;; Keywords: faces, php |
| 9 | ;; Homepage: https://github.com/emacs-php/php-mode | 9 | ;; Homepage: https://github.com/emacs-php/php-mode |
| 10 | ;; Package-Requires: ((emacs "24.3")) | 10 | ;; Package-Requires: ((emacs "24.3")) |
| @@ -38,103 +38,128 @@ | |||
| 38 | 38 | ||
| 39 | (defface php-string '((t (:inherit font-lock-string-face))) | 39 | (defface php-string '((t (:inherit font-lock-string-face))) |
| 40 | "PHP Mode face used to highlight string literals." | 40 | "PHP Mode face used to highlight string literals." |
| 41 | :group 'php-faces) | 41 | :group 'php-faces |
| 42 | :tag "PHP String") | ||
| 42 | 43 | ||
| 43 | (defface php-keyword '((t (:inherit font-lock-keyword-face))) | 44 | (defface php-keyword '((t (:inherit font-lock-keyword-face))) |
| 44 | "PHP Mode face used to highlight keywords." | 45 | "PHP Mode face used to highlight keywords." |
| 45 | :group 'php-faces) | 46 | :group 'php-faces |
| 47 | :tag "PHP Keyword") | ||
| 46 | 48 | ||
| 47 | (defface php-builtin '((t (:inherit font-lock-builtin-face))) | 49 | (defface php-builtin '((t (:inherit font-lock-builtin-face))) |
| 48 | "PHP Mode face used to highlight builtins." | 50 | "PHP Mode face used to highlight builtins." |
| 49 | :group 'php-faces) | 51 | :group 'php-faces |
| 52 | :tag "PHP Built-in") | ||
| 50 | 53 | ||
| 51 | (defface php-function-name '((t (:inherit font-lock-function-name-face))) | 54 | (defface php-function-name '((t (:inherit font-lock-function-name-face))) |
| 52 | "PHP Mode face used to highlight function names." | 55 | "PHP Mode face used to highlight function names." |
| 53 | :group 'php-faces) | 56 | :group 'php-faces |
| 57 | :tag "PHP Function Name") | ||
| 54 | 58 | ||
| 55 | (defface php-function-call '((t (:inherit default))) | 59 | (defface php-function-call '((t (:inherit default))) |
| 56 | "PHP Mode face used to highlight function names in calles." | 60 | "PHP Mode face used to highlight function names in calles." |
| 57 | :group 'php-faces) | 61 | :group 'php-faces |
| 62 | :tag "PHP Function Call") | ||
| 58 | 63 | ||
| 59 | (defface php-method-call '((t (:inherit php-function-call))) | 64 | (defface php-method-call '((t (:inherit php-function-call))) |
| 60 | "PHP Mode face used to highlight method names in calles." | 65 | "PHP Mode face used to highlight method names in calles." |
| 61 | :group 'php-faces) | 66 | :group 'php-faces |
| 67 | :tag "PHP Method Call") | ||
| 62 | 68 | ||
| 63 | (defface php-static-method-call '((t (:inherit php-method-call))) | 69 | (defface php-static-method-call '((t (:inherit php-method-call))) |
| 64 | "PHP Mode face used to highlight static method names in calles." | 70 | "PHP Mode face used to highlight static method names in calles." |
| 65 | :group 'php-faces) | 71 | :group 'php-faces |
| 72 | :tag "PHP Static Method Call") | ||
| 66 | 73 | ||
| 67 | (defface php-variable-name '((t (:inherit font-lock-variable-name-face))) | 74 | (defface php-variable-name '((t (:inherit font-lock-variable-name-face))) |
| 68 | "PHP Mode face used to highlight variable names." | 75 | "PHP Mode face used to highlight variable names." |
| 69 | :group 'php-faces) | 76 | :group 'php-faces |
| 77 | :tag "PHP Variable Name") | ||
| 70 | 78 | ||
| 71 | (defface php-property-name '((t (:inherit php-variable-name))) | 79 | (defface php-property-name '((t (:inherit php-variable-name))) |
| 72 | "PHP Mode face used to highlight property names." | 80 | "PHP Mode face used to highlight property names." |
| 73 | :group 'php-faces) | 81 | :group 'php-faces |
| 82 | :tag "PHP Property Name") | ||
| 74 | 83 | ||
| 75 | (defface php-variable-sigil '((t (:inherit default))) | 84 | (defface php-variable-sigil '((t (:inherit default))) |
| 76 | "PHP Mode face used to highlight variable sigils ($)." | 85 | "PHP Mode face used to highlight variable sigils ($)." |
| 77 | :group 'php-faces) | 86 | :group 'php-faces |
| 87 | :tag "PHP Variable Sigil") | ||
| 78 | 88 | ||
| 79 | (defface php-object-op '((t (:inherit default))) | 89 | (defface php-object-op '((t (:inherit default))) |
| 80 | "PHP Mode face used to object operators (->)." | 90 | "PHP Mode face used to object operators (->)." |
| 81 | :group 'php-faces) | 91 | :group 'php-faces |
| 92 | :tag "PHP Object Op") | ||
| 82 | 93 | ||
| 83 | (defface php-paamayim-nekudotayim '((t (:inherit default))) | 94 | (defface php-paamayim-nekudotayim '((t (:inherit default))) |
| 84 | "PHP Mode face used to highlight \"Paamayim Nekudotayim\" scope resolution operators (::)." | 95 | "PHP Mode face used to highlight \"Paamayim Nekudotayim\" scope resolution operators (::)." |
| 85 | :group 'php-faces) | 96 | :group 'php-faces |
| 97 | :tag "PHP Paamayim Nekudotayim") | ||
| 86 | 98 | ||
| 87 | (defface php-type '((t (:inherit font-lock-type-face))) | 99 | (defface php-type '((t (:inherit font-lock-type-face))) |
| 88 | "PHP Mode face used to highlight types." | 100 | "PHP Mode face used to highlight types." |
| 89 | :group 'php-faces) | 101 | :group 'php-faces |
| 102 | :tag "PHP Type") | ||
| 90 | 103 | ||
| 91 | (defface php-constant '((t (:inherit font-lock-constant-face))) | 104 | (defface php-constant '((t (:inherit font-lock-constant-face))) |
| 92 | "PHP Mode face used to highlight constants." | 105 | "PHP Mode face used to highlight constants." |
| 93 | :group 'php-faces) | 106 | :group 'php-faces |
| 107 | :tag "PHP Constant") | ||
| 94 | 108 | ||
| 95 | (defface php-constant-assign '((t (:inherit font-lock-type-face))) | 109 | (defface php-constant-assign '((t (:inherit font-lock-type-face))) |
| 96 | "PHP Mode face used to highlight constant assigning (\"const\" statement)." | 110 | "PHP Mode face used to highlight constant assigning (\"const\" statement)." |
| 97 | :group 'php-faces) | 111 | :group 'php-faces |
| 112 | :tag "PHP Constant Assign") | ||
| 98 | 113 | ||
| 99 | (defface php-magical-constant '((t (:inherit font-lock-builtin-face))) | 114 | (defface php-magical-constant '((t (:inherit font-lock-builtin-face))) |
| 100 | "PHP Mode face used to highlight magical constants." | 115 | "PHP Mode face used to highlight magical constants." |
| 101 | :group 'php-faces) | 116 | :group 'php-faces |
| 117 | :tag "PHP Magical Constant") | ||
| 102 | 118 | ||
| 103 | (defface php-$this '((t (:inherit php-constant))) | 119 | (defface php-$this '((t (:inherit php-constant))) |
| 104 | "PHP Mode face used to highlight $this variables." | 120 | "PHP Mode face used to highlight $this variables." |
| 105 | :group 'php-faces) | 121 | :group 'php-faces |
| 122 | :tag "PHP $this") | ||
| 106 | 123 | ||
| 107 | (defface php-$this-sigil '((t (:inherit php-constant))) | 124 | (defface php-$this-sigil '((t (:inherit php-constant))) |
| 108 | "PHP Mode face used to highlight sigils($) of $this variable." | 125 | "PHP Mode face used to highlight sigils($) of $this variable." |
| 109 | :group 'php-faces) | 126 | :group 'php-faces |
| 127 | :tag "PHP $this Sigil") | ||
| 110 | 128 | ||
| 111 | (defface php-errorcontrol-op '((t (:inherit font-lock-type-face))) | 129 | (defface php-errorcontrol-op '((t (:inherit font-lock-type-face))) |
| 112 | "PHP Mode face used to highlight errorcontrol operators (@).." | 130 | "PHP Mode face used to highlight errorcontrol operators (@).." |
| 113 | :group 'php-face) | 131 | :group 'php-faces |
| 132 | :tag "PHP ErrorControl Op") | ||
| 114 | 133 | ||
| 115 | (defface php-php-tag '((t (:inherit font-lock-preprocessor-face))) | 134 | (defface php-php-tag '((t (:inherit font-lock-preprocessor-face))) |
| 116 | "PHP Mode face used to highlight PHP tags." | 135 | "PHP Mode face used to highlight PHP tags." |
| 117 | :group 'php-faces) | 136 | :group 'php-faces |
| 137 | :tag "PHP php Tag") | ||
| 118 | 138 | ||
| 119 | (defface php-doc-annotation-tag '((t . (:inherit font-lock-constant-face))) | 139 | (defface php-doc-annotation-tag '((t . (:inherit font-lock-constant-face))) |
| 120 | "Face used to highlight annotation tags in doc-comment." | 140 | "Face used to highlight annotation tags in doc-comment." |
| 121 | :group 'php-faces) | 141 | :group 'php-faces |
| 142 | :tag "PHPDoc Annotation Tag") | ||
| 122 | 143 | ||
| 123 | (defface php-doc-variable-sigil '((t (:inherit font-lock-variable-name-face))) | 144 | (defface php-doc-variable-sigil '((t (:inherit font-lock-variable-name-face))) |
| 124 | "PHP Mode face used to highlight variable sigils($)." | 145 | "PHP Mode face used to highlight variable sigils($)." |
| 125 | :group 'php-faces) | 146 | :group 'php-faces |
| 147 | :tag "PHPDoc Variable Sigil") | ||
| 126 | 148 | ||
| 127 | (defface php-doc-$this '((t (:inherit php-type))) | 149 | (defface php-doc-$this '((t (:inherit php-type))) |
| 128 | "PHP Mode face used to highlight $this variable in doc-comment." | 150 | "PHP Mode face used to highlight $this variable in doc-comment." |
| 129 | :group 'php-faces) | 151 | :group 'php-faces |
| 152 | :tag "PHPDoc $this") | ||
| 130 | 153 | ||
| 131 | (defface php-doc-$this-sigil '((t (:inherit php-type))) | 154 | (defface php-doc-$this-sigil '((t (:inherit php-type))) |
| 132 | "PHP Mode face used to highlight sigil of $this variable in doc-comment." | 155 | "PHP Mode face used to highlight sigil of $this variable in doc-comment." |
| 133 | :group 'php-faces) | 156 | :group 'php-faces |
| 157 | :tag "PHPDoc $this Sigil") | ||
| 134 | 158 | ||
| 135 | (defface php-doc-class-name '((t (:inherit php-string))) | 159 | (defface php-doc-class-name '((t (:inherit php-string))) |
| 136 | "Face used to class names in doc-comment." | 160 | "Face used to class names in doc-comment." |
| 137 | :group 'php-faces) | 161 | :group 'php-faces |
| 162 | :tag "PHPDoc Class Name") | ||
| 138 | 163 | ||
| 139 | (define-obsolete-face-alias 'php-annotations-annotation-face 'php-doc-annotation-tag "1.19.0") | 164 | (define-obsolete-face-alias 'php-annotations-annotation-face 'php-doc-annotation-tag "1.19.0") |
| 140 | 165 | ||
diff --git a/.emacs.d/lisp/php-mode.el b/.emacs.d/lisp/php-mode.el index 2fa1ab5..09d762b 100644 --- a/.emacs.d/lisp/php-mode.el +++ b/.emacs.d/lisp/php-mode.el | |||
| @@ -9,14 +9,14 @@ | |||
| 9 | ;; Maintainer: USAMI Kenta <tadsan@zonu.me> | 9 | ;; Maintainer: USAMI Kenta <tadsan@zonu.me> |
| 10 | ;; URL: https://github.com/emacs-php/php-mode | 10 | ;; URL: https://github.com/emacs-php/php-mode |
| 11 | ;; Keywords: languages php | 11 | ;; Keywords: languages php |
| 12 | ;; Version: 1.21.2 | 12 | ;; Version: 1.21.3 |
| 13 | ;; Package-Requires: ((emacs "24.3") (cl-lib "0.5")) | 13 | ;; Package-Requires: ((emacs "24.3") (cl-lib "0.5")) |
| 14 | ;; License: GPL-3.0-or-later | 14 | ;; License: GPL-3.0-or-later |
| 15 | 15 | ||
| 16 | (defconst php-mode-version-number "1.21.2" | 16 | (defconst php-mode-version-number "1.21.3" |
| 17 | "PHP Mode version number.") | 17 | "PHP Mode version number.") |
| 18 | 18 | ||
| 19 | (defconst php-mode-modified "2019-05-11" | 19 | (defconst php-mode-modified "2019-05-25" |
| 20 | "PHP Mode build date.") | 20 | "PHP Mode build date.") |
| 21 | 21 | ||
| 22 | ;; This program is free software; you can redistribute it and/or modify | 22 | ;; This program is free software; you can redistribute it and/or modify |
| @@ -136,6 +136,7 @@ | |||
| 136 | (defcustom php-mode-default-face 'default | 136 | (defcustom php-mode-default-face 'default |
| 137 | "Default face in `php-mode' buffers." | 137 | "Default face in `php-mode' buffers." |
| 138 | :group 'php-mode | 138 | :group 'php-mode |
| 139 | :tag "PHP Mode Default Face" | ||
| 139 | :type 'face) | 140 | :type 'face) |
| 140 | 141 | ||
| 141 | (define-obsolete-variable-alias 'php-speedbar-config 'php-mode-speedbar-config "1.20.0") | 142 | (define-obsolete-variable-alias 'php-speedbar-config 'php-mode-speedbar-config "1.20.0") |
| @@ -143,6 +144,7 @@ | |||
| 143 | "When set to true automatically configures Speedbar to observe PHP files. | 144 | "When set to true automatically configures Speedbar to observe PHP files. |
| 144 | Ignores php-file patterns option; fixed to expression \"\\.\\(inc\\|php[s345]?\\)\"" | 145 | Ignores php-file patterns option; fixed to expression \"\\.\\(inc\\|php[s345]?\\)\"" |
| 145 | :group 'php-mode | 146 | :group 'php-mode |
| 147 | :tag "PHP Mode Speedbar Config" | ||
| 146 | :type 'boolean | 148 | :type 'boolean |
| 147 | :set (lambda (sym val) | 149 | :set (lambda (sym val) |
| 148 | (set-default sym val) | 150 | (set-default sym val) |
| @@ -154,6 +156,7 @@ Ignores php-file patterns option; fixed to expression \"\\.\\(inc\\|php[s345]?\\ | |||
| 154 | "Normally `php-mode' starts with the speedbar closed. | 156 | "Normally `php-mode' starts with the speedbar closed. |
| 155 | Turning this on will open it whenever `php-mode' is loaded." | 157 | Turning this on will open it whenever `php-mode' is loaded." |
| 156 | :group 'php-mode | 158 | :group 'php-mode |
| 159 | :tag "PHP Mode Speedbar Open" | ||
| 157 | :type 'boolean | 160 | :type 'boolean |
| 158 | :set (lambda (sym val) | 161 | :set (lambda (sym val) |
| 159 | (set-default sym val) | 162 | (set-default sym val) |
| @@ -164,6 +167,7 @@ Turning this on will open it whenever `php-mode' is loaded." | |||
| 164 | (defcustom php-mode-template-compatibility t | 167 | (defcustom php-mode-template-compatibility t |
| 165 | "Should detect presence of html tags." | 168 | "Should detect presence of html tags." |
| 166 | :group 'php-mode | 169 | :group 'php-mode |
| 170 | :tag "PHP Mode Template Compatibility" | ||
| 167 | :type 'boolean) | 171 | :type 'boolean) |
| 168 | 172 | ||
| 169 | (defun php-mode-extra-constants-create-regexp (kwds) | 173 | (defun php-mode-extra-constants-create-regexp (kwds) |
| @@ -194,6 +198,7 @@ of constants when set." | |||
| 194 | (defcustom php-mode-lineup-cascaded-calls nil | 198 | (defcustom php-mode-lineup-cascaded-calls nil |
| 195 | "Indent chained method calls to the previous line." | 199 | "Indent chained method calls to the previous line." |
| 196 | :group 'php-mode | 200 | :group 'php-mode |
| 201 | :tag "PHP Mode Lineup Cascaded Calls" | ||
| 197 | :type 'boolean) | 202 | :type 'boolean) |
| 198 | 203 | ||
| 199 | 204 | ||
| @@ -201,6 +206,7 @@ of constants when set." | |||
| 201 | (defcustom php-mode-extra-constants '() | 206 | (defcustom php-mode-extra-constants '() |
| 202 | "A list of additional strings to treat as PHP constants." | 207 | "A list of additional strings to treat as PHP constants." |
| 203 | :group 'php-mode | 208 | :group 'php-mode |
| 209 | :tag "PHP Mode Extra Constants" | ||
| 204 | :type '(repeat string) | 210 | :type '(repeat string) |
| 205 | :set 'php-mode-extra-constants-set) | 211 | :set 'php-mode-extra-constants-set) |
| 206 | 212 | ||
| @@ -213,6 +219,8 @@ set to `semantic-create-imenu-index' due to `c-mode' being its | |||
| 213 | parent. Set this variable to t if you want to use | 219 | parent. Set this variable to t if you want to use |
| 214 | `imenu-default-create-index-function' even with `semantic-mode' | 220 | `imenu-default-create-index-function' even with `semantic-mode' |
| 215 | enabled." | 221 | enabled." |
| 222 | :group 'php-mode | ||
| 223 | :tag "PHP Mode Do Not Use Semantic Imenu" | ||
| 216 | :type 'boolean) | 224 | :type 'boolean) |
| 217 | 225 | ||
| 218 | (defcustom php-completion-file "" | 226 | (defcustom php-completion-file "" |
| @@ -233,31 +241,45 @@ enabled." | |||
| 233 | 241 | ||
| 234 | (defcustom php-mode-hook nil | 242 | (defcustom php-mode-hook nil |
| 235 | "List of functions to be executed on entry to `php-mode'." | 243 | "List of functions to be executed on entry to `php-mode'." |
| 244 | :group 'php-mode | ||
| 245 | :tag "PHP Mode Hook" | ||
| 236 | :type 'hook) | 246 | :type 'hook) |
| 237 | 247 | ||
| 238 | (defcustom php-mode-pear-hook nil | 248 | (defcustom php-mode-pear-hook nil |
| 239 | "Hook called when a PHP PEAR file is opened with `php-mode'." | 249 | "Hook called when a PHP PEAR file is opened with `php-mode'." |
| 250 | :group 'php-mode | ||
| 251 | :tag "PHP Mode Pear Hook" | ||
| 240 | :type 'hook) | 252 | :type 'hook) |
| 241 | 253 | ||
| 242 | (defcustom php-mode-drupal-hook nil | 254 | (defcustom php-mode-drupal-hook nil |
| 243 | "Hook called when a Drupal file is opened with `php-mode'." | 255 | "Hook called when a Drupal file is opened with `php-mode'." |
| 256 | :group 'php-mode | ||
| 257 | :tag "PHP Mode Drupal Hook" | ||
| 244 | :type 'hook) | 258 | :type 'hook) |
| 245 | 259 | ||
| 246 | (defcustom php-mode-wordpress-hook nil | 260 | (defcustom php-mode-wordpress-hook nil |
| 247 | "Hook called when a WordPress file is opened with `php-mode'." | 261 | "Hook called when a WordPress file is opened with `php-mode'." |
| 262 | :group 'php-mode | ||
| 263 | :tag "PHP Mode WordPress Hook" | ||
| 248 | :type 'hook) | 264 | :type 'hook) |
| 249 | 265 | ||
| 250 | (defcustom php-mode-symfony2-hook nil | 266 | (defcustom php-mode-symfony2-hook nil |
| 251 | "Hook called when a Symfony2 file is opened with `php-mode'." | 267 | "Hook called when a Symfony2 file is opened with `php-mode'." |
| 268 | :group 'php-mode | ||
| 269 | :tag "PHP Mode Symfony2 Hook" | ||
| 252 | :type 'hook) | 270 | :type 'hook) |
| 253 | 271 | ||
| 254 | (defcustom php-mode-psr2-hook nil | 272 | (defcustom php-mode-psr2-hook nil |
| 255 | "Hook called when a PSR-2 file is opened with `php-mode'." | 273 | "Hook called when a PSR-2 file is opened with `php-mode'." |
| 274 | :group 'php-mode | ||
| 275 | :tag "PHP Mode PSR-2 Hook" | ||
| 256 | :type 'hook) | 276 | :type 'hook) |
| 257 | 277 | ||
| 258 | (defcustom php-mode-force-pear nil | 278 | (defcustom php-mode-force-pear nil |
| 259 | "Normally PEAR coding rules are enforced only when the filename contains \"PEAR.\" | 279 | "Normally PEAR coding rules are enforced only when the filename contains \"PEAR.\" |
| 260 | Turning this on will force PEAR rules on all PHP files." | 280 | Turning this on will force PEAR rules on all PHP files." |
| 281 | :group 'php-mode | ||
| 282 | :tag "PHP Mode Force Pear" | ||
| 261 | :type 'boolean) | 283 | :type 'boolean) |
| 262 | 284 | ||
| 263 | (defcustom php-mode-warn-if-mumamo-off t | 285 | (defcustom php-mode-warn-if-mumamo-off t |
| @@ -265,6 +287,8 @@ Turning this on will force PEAR rules on all PHP files." | |||
| 265 | mumamo-mode turned on. Detects if there are any HTML tags in the | 287 | mumamo-mode turned on. Detects if there are any HTML tags in the |
| 266 | buffer before warning, but this is is not very smart; e.g. if you | 288 | buffer before warning, but this is is not very smart; e.g. if you |
| 267 | have any tags inside a PHP string, it will be fooled." | 289 | have any tags inside a PHP string, it will be fooled." |
| 290 | :group 'php-mode | ||
| 291 | :tag "PHP Mode Warn If MuMaMo Off" | ||
| 268 | :type '(choice (const :tag "Warn" t) (const "Don't warn" nil))) | 292 | :type '(choice (const :tag "Warn" t) (const "Don't warn" nil))) |
| 269 | 293 | ||
| 270 | (defcustom php-mode-coding-style 'pear | 294 | (defcustom php-mode-coding-style 'pear |
| @@ -282,6 +306,8 @@ This variable can take one of the following symbol values: | |||
| 282 | `Symfony2' - use coding styles preferred for working with Symfony2 projects. | 306 | `Symfony2' - use coding styles preferred for working with Symfony2 projects. |
| 283 | 307 | ||
| 284 | `PSR-2' - use coding styles preferred for working with projects using PSR-2 standards." | 308 | `PSR-2' - use coding styles preferred for working with projects using PSR-2 standards." |
| 309 | :group 'php-mode | ||
| 310 | :tag "PHP Mode Coding Style" | ||
| 285 | :type '(choice (const :tag "Default" default) | 311 | :type '(choice (const :tag "Default" default) |
| 286 | (const :tag "PEAR" pear) | 312 | (const :tag "PEAR" pear) |
| 287 | (const :tag "Drupal" drupal) | 313 | (const :tag "Drupal" drupal) |
| @@ -297,6 +323,8 @@ This variable can take one of the following symbol values: | |||
| 297 | 323 | ||
| 298 | If you want to suppress styles from being overwritten by directory / file | 324 | If you want to suppress styles from being overwritten by directory / file |
| 299 | local variables, set NIL." | 325 | local variables, set NIL." |
| 326 | :group 'php-mode | ||
| 327 | :tag "PHP Mode Enable Project Coding Style" | ||
| 300 | :type 'boolean) | 328 | :type 'boolean) |
| 301 | 329 | ||
| 302 | (defcustom php-mode-enable-backup-style-variables t | 330 | (defcustom php-mode-enable-backup-style-variables t |
| @@ -304,11 +332,15 @@ local variables, set NIL." | |||
| 304 | 332 | ||
| 305 | This function may interfere with other hooks and other behaviors. | 333 | This function may interfere with other hooks and other behaviors. |
| 306 | In that case set to `NIL'." | 334 | In that case set to `NIL'." |
| 335 | :group 'php-mode | ||
| 336 | :tag "PHP Mode Enable Backup Style Variables" | ||
| 307 | :type 'boolean) | 337 | :type 'boolean) |
| 308 | 338 | ||
| 309 | (define-obsolete-variable-alias 'php-mode-disable-parent-mode-hooks 'php-mode-disable-c-mode-hook "1.21.0") | 339 | (define-obsolete-variable-alias 'php-mode-disable-parent-mode-hooks 'php-mode-disable-c-mode-hook "1.21.0") |
| 310 | (defcustom php-mode-disable-c-mode-hook t | 340 | (defcustom php-mode-disable-c-mode-hook t |
| 311 | "When set to `T', do not run hooks of parent modes (`java-mode', `c-mode')." | 341 | "When set to `T', do not run hooks of parent modes (`java-mode', `c-mode')." |
| 342 | :group 'php-mode | ||
| 343 | :tag "PHP Mode Disable C Mode Hook" | ||
| 312 | :type 'boolean | 344 | :type 'boolean |
| 313 | :group 'php-mode) | 345 | :group 'php-mode) |
| 314 | 346 | ||
| @@ -432,9 +464,7 @@ In that case set to `NIL'." | |||
| 432 | php t) | 464 | php t) |
| 433 | 465 | ||
| 434 | (c-lang-defconst c-assignment-operators | 466 | (c-lang-defconst c-assignment-operators |
| 435 | ;; falls back to java, so no need to specify the language | 467 | php '("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|=" ".=" "??=")) |
| 436 | php (append (remove ">>>=" (c-lang-const c-assignment-operators)) | ||
| 437 | '(".="))) | ||
| 438 | 468 | ||
| 439 | (c-lang-defconst beginning-of-defun-function | 469 | (c-lang-defconst beginning-of-defun-function |
| 440 | php 'php-beginning-of-defun) | 470 | php 'php-beginning-of-defun) |
| @@ -790,13 +820,20 @@ example `html-mode'. Known such libraries are:\n\t" | |||
| 790 | nil)))) | 820 | nil)))) |
| 791 | 821 | ||
| 792 | (defun php-cautious-indent-region (start end &optional quiet) | 822 | (defun php-cautious-indent-region (start end &optional quiet) |
| 823 | "Carefully indent region `START' `END' in contexts other than HTML templates. | ||
| 824 | |||
| 825 | If the optional argument `QUIET' is non-nil then no syntactic errors are | ||
| 826 | reported, even if `c-report-syntactic-errors' is non-nil." | ||
| 793 | (if (or (not php-mode-warn-if-mumamo-off) | 827 | (if (or (not php-mode-warn-if-mumamo-off) |
| 828 | (not (php-in-poly-php-html-mode)) | ||
| 794 | php-warned-bad-indent | 829 | php-warned-bad-indent |
| 795 | (php-check-html-for-indentation)) | 830 | (php-check-html-for-indentation)) |
| 796 | (funcall 'c-indent-region start end quiet))) | 831 | (funcall 'c-indent-region start end quiet))) |
| 797 | 832 | ||
| 798 | (defun php-cautious-indent-line () | 833 | (defun php-cautious-indent-line () |
| 834 | "Carefully indent lines in contexts other than HTML templates." | ||
| 799 | (if (or (not php-mode-warn-if-mumamo-off) | 835 | (if (or (not php-mode-warn-if-mumamo-off) |
| 836 | (not (php-in-poly-php-html-mode)) | ||
| 800 | php-warned-bad-indent | 837 | php-warned-bad-indent |
| 801 | (php-check-html-for-indentation)) | 838 | (php-check-html-for-indentation)) |
| 802 | (let ((here (point)) | 839 | (let ((here (point)) |
| @@ -843,8 +880,8 @@ This is was done due to the problem reported here: | |||
| 843 | ret))) | 880 | ret))) |
| 844 | 881 | ||
| 845 | (defun php-c-vsemi-status-unknown-p () | 882 | (defun php-c-vsemi-status-unknown-p () |
| 846 | "See `php-c-at-vsemi-p'." | 883 | "Always return NIL. See `php-c-at-vsemi-p'." |
| 847 | ) | 884 | nil) |
| 848 | 885 | ||
| 849 | (defun php-lineup-string-cont (langelem) | 886 | (defun php-lineup-string-cont (langelem) |
| 850 | "Line up string toward equal sign or dot. | 887 | "Line up string toward equal sign or dot. |
| @@ -996,11 +1033,23 @@ After setting the stylevars run hooks according to STYLENAME | |||
| 996 | (prog1 (php-set-style (symbol-name coding-style)) | 1033 | (prog1 (php-set-style (symbol-name coding-style)) |
| 997 | (remove-hook 'hack-local-variables-hook #'php-mode-set-style-delay))))) | 1034 | (remove-hook 'hack-local-variables-hook #'php-mode-set-style-delay))))) |
| 998 | 1035 | ||
| 1036 | (defvar php-mode-syntax-table | ||
| 1037 | (let ((table (make-syntax-table))) | ||
| 1038 | (c-populate-syntax-table table) | ||
| 1039 | (modify-syntax-entry ?_ "_" table) | ||
| 1040 | (modify-syntax-entry ?` "\"" table) | ||
| 1041 | (modify-syntax-entry ?\" "\"" table) | ||
| 1042 | (modify-syntax-entry ?# "< b" table) | ||
| 1043 | (modify-syntax-entry ?\n "> b" table) | ||
| 1044 | (modify-syntax-entry ?$ "'" table) | ||
| 1045 | table)) | ||
| 1046 | |||
| 999 | ;;;###autoload | 1047 | ;;;###autoload |
| 1000 | (define-derived-mode php-mode c-mode "PHP" | 1048 | (define-derived-mode php-mode c-mode "PHP" |
| 1001 | "Major mode for editing PHP code. | 1049 | "Major mode for editing PHP code. |
| 1002 | 1050 | ||
| 1003 | \\{php-mode-map}" | 1051 | \\{php-mode-map}" |
| 1052 | :syntax-table php-mode-syntax-table | ||
| 1004 | ;; :after-hook (c-update-modeline) | 1053 | ;; :after-hook (c-update-modeline) |
| 1005 | ;; (setq abbrev-mode t) | 1054 | ;; (setq abbrev-mode t) |
| 1006 | (when php-mode-disable-c-mode-hook | 1055 | (when php-mode-disable-c-mode-hook |
| @@ -1010,6 +1059,15 @@ After setting the stylevars run hooks according to STYLENAME | |||
| 1010 | (c-init-language-vars php-mode) | 1059 | (c-init-language-vars php-mode) |
| 1011 | (c-common-init 'php-mode) | 1060 | (c-common-init 'php-mode) |
| 1012 | 1061 | ||
| 1062 | (setq-local comment-start "// ") | ||
| 1063 | (setq-local comment-start-skip | ||
| 1064 | (eval-when-compile | ||
| 1065 | (rx (group (or (: "#") | ||
| 1066 | (: "/" (+ "/")) | ||
| 1067 | (: "/*"))) | ||
| 1068 | (* (syntax whitespace))))) | ||
| 1069 | (setq-local comment-end "") | ||
| 1070 | |||
| 1013 | (setq-local font-lock-string-face 'php-string) | 1071 | (setq-local font-lock-string-face 'php-string) |
| 1014 | (setq-local font-lock-keyword-face 'php-keyword) | 1072 | (setq-local font-lock-keyword-face 'php-keyword) |
| 1015 | (setq-local font-lock-builtin-face 'php-builtin) | 1073 | (setq-local font-lock-builtin-face 'php-builtin) |
| @@ -1018,13 +1076,6 @@ After setting the stylevars run hooks according to STYLENAME | |||
| 1018 | (setq-local font-lock-variable-name-face 'php-variable-name) | 1076 | (setq-local font-lock-variable-name-face 'php-variable-name) |
| 1019 | (setq-local font-lock-constant-face 'php-constant) | 1077 | (setq-local font-lock-constant-face 'php-constant) |
| 1020 | 1078 | ||
| 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 | |||
| 1028 | (setq-local syntax-propertize-function #'php-syntax-propertize-function) | 1079 | (setq-local syntax-propertize-function #'php-syntax-propertize-function) |
| 1029 | (add-to-list (make-local-variable 'syntax-propertize-extend-region-functions) | 1080 | (add-to-list (make-local-variable 'syntax-propertize-extend-region-functions) |
| 1030 | #'php-syntax-propertize-extend-region) | 1081 | #'php-syntax-propertize-extend-region) |
| @@ -1054,12 +1105,8 @@ After setting the stylevars run hooks according to STYLENAME | |||
| 1054 | 1105 | ||
| 1055 | (setq indent-line-function 'php-cautious-indent-line) | 1106 | (setq indent-line-function 'php-cautious-indent-line) |
| 1056 | (setq indent-region-function 'php-cautious-indent-region) | 1107 | (setq indent-region-function 'php-cautious-indent-region) |
| 1057 | (setq c-at-vsemi-p-fn 'php-c-at-vsemi-p) | 1108 | (setq c-at-vsemi-p-fn #'php-c-at-vsemi-p) |
| 1058 | (setq c-vsemi-status-unknown-p 'php-c-vsemi-status-unknown-p) | 1109 | (setq c-vsemi-status-unknown-p-fn #'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)) | ||
| 1063 | 1110 | ||
| 1064 | ;; We map the php-{beginning,end}-of-defun functions so that they | 1111 | ;; We map the php-{beginning,end}-of-defun functions so that they |
| 1065 | ;; replace the similar commands that we inherit from CC Mode. | 1112 | ;; replace the similar commands that we inherit from CC Mode. |
| @@ -1079,7 +1126,10 @@ After setting the stylevars run hooks according to STYLENAME | |||
| 1079 | (when (>= emacs-major-version 25) | 1126 | (when (>= emacs-major-version 25) |
| 1080 | (with-silent-modifications | 1127 | (with-silent-modifications |
| 1081 | (save-excursion | 1128 | (save-excursion |
| 1082 | (php-syntax-propertize-function (point-min) (point-max)))))) | 1129 | (let* ((start (point-min)) |
| 1130 | (end (min (point-max) | ||
| 1131 | (+ start syntax-propertize-chunk-size)))) | ||
| 1132 | (php-syntax-propertize-function start end)))))) | ||
| 1083 | 1133 | ||
| 1084 | (declare-function semantic-create-imenu-index "semantic/imenu" (&optional stream)) | 1134 | (declare-function semantic-create-imenu-index "semantic/imenu" (&optional stream)) |
| 1085 | 1135 | ||
| @@ -1221,6 +1271,7 @@ current `tags-file-name'." | |||
| 1221 | If non-nil, this shadows the value of `browse-url-browser-function' when | 1271 | If non-nil, this shadows the value of `browse-url-browser-function' when |
| 1222 | calling `php-search-documentation' or `php-search-local-documentation'." | 1272 | calling `php-search-documentation' or `php-search-local-documentation'." |
| 1223 | :group 'php | 1273 | :group 'php |
| 1274 | :tag "PHP Search Documentation Browser Function" | ||
| 1224 | :type '(choice (const :tag "default" nil) function) | 1275 | :type '(choice (const :tag "default" nil) function) |
| 1225 | :link '(variable-link browse-url-browser-function)) | 1276 | :link '(variable-link browse-url-browser-function)) |
| 1226 | 1277 | ||
| @@ -1549,23 +1600,9 @@ The output will appear in the buffer *PHP*." | |||
| 1549 | (ad-activate 'fixup-whitespace) | 1600 | (ad-activate 'fixup-whitespace) |
| 1550 | 1601 | ||
| 1551 | ;;;###autoload | 1602 | ;;;###autoload |
| 1552 | (add-to-list 'auto-mode-alist | 1603 | (progn |
| 1553 | (cons | 1604 | (add-to-list 'auto-mode-alist '("/\\.php_cs\\(?:\\.dist\\)?\\'" . php-mode)) |
| 1554 | (eval-when-compile | 1605 | (add-to-list 'auto-mode-alist '("\\.\\(?:php[s345]?\\|phtml\\)\\'" . php-mode-maybe))) |
| 1555 | (rx (or | ||
| 1556 | ;; File name extensions (ex. "*.php", "*.phtml") | ||
| 1557 | (: "." | ||
| 1558 | (or (: "php" (? (in "s345t"))) | ||
| 1559 | "amk" | ||
| 1560 | "phtml")) | ||
| 1561 | ;; Full file names (ex. "/Makefile", "/Amkfile") | ||
| 1562 | (: "/" | ||
| 1563 | (or "Amkfile" | ||
| 1564 | ".php_cs" | ||
| 1565 | ".php_cs.dist"))) | ||
| 1566 | string-end)) | ||
| 1567 | 'php-mode) | ||
| 1568 | t) | ||
| 1569 | 1606 | ||
| 1570 | (provide 'php-mode) | 1607 | (provide 'php-mode) |
| 1571 | ;;; php-mode.el ends here | 1608 | ;;; php-mode.el ends here |
diff --git a/.emacs.d/lisp/php-project.el b/.emacs.d/lisp/php-project.el index e12d83a..7ab003e 100644 --- a/.emacs.d/lisp/php-project.el +++ b/.emacs.d/lisp/php-project.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: USAMI Kenta <tadsan@zonu.me> | 5 | ;; Author: USAMI Kenta <tadsan@zonu.me> |
| 6 | ;; Keywords: tools, files | 6 | ;; Keywords: tools, files |
| 7 | ;; URL: https://github.com/emacs-php/php-mode | 7 | ;; URL: https://github.com/emacs-php/php-mode |
| 8 | ;; Version: 1.21.2 | 8 | ;; Version: 1.21.3 |
| 9 | ;; Package-Requires: ((emacs "24.3") (cl-lib "0.5")) | 9 | ;; Package-Requires: ((emacs "24.3") (cl-lib "0.5")) |
| 10 | ;; License: GPL-3.0-or-later | 10 | ;; License: GPL-3.0-or-later |
| 11 | 11 | ||
| @@ -102,85 +102,90 @@ STRING | |||
| 102 | If the string is an actual directory path, it is set as the absolute path | 102 | If the string is an actual directory path, it is set as the absolute path |
| 103 | of the root directory, not the marker.") | 103 | of the root directory, not the marker.") |
| 104 | (put 'php-project-root 'safe-local-variable | 104 | (put 'php-project-root 'safe-local-variable |
| 105 | #'(lambda (v) (or (stringp v) (assq v php-project-available-root-files))))) | 105 | #'(lambda (v) (or (stringp v) (assq v php-project-available-root-files)))) |
| 106 | 106 | ||
| 107 | ;;;###autoload | ||
| 108 | (progn | ||
| 109 | (defvar-local php-project-bootstrap-scripts nil | 107 | (defvar-local php-project-bootstrap-scripts nil |
| 110 | "List of path to bootstrap php script file. | 108 | "List of path to bootstrap php script file. |
| 111 | 109 | ||
| 112 | The ideal bootstrap file is silent, it only includes dependent files, | 110 | The ideal bootstrap file is silent, it only includes dependent files, |
| 113 | defines constants, and sets the class loaders.") | 111 | defines constants, and sets the class loaders.") |
| 114 | (put 'php-project-bootstrap-scripts 'safe-local-variable #'php-project--eval-bootstrap-scripts)) | 112 | (put 'php-project-bootstrap-scripts 'safe-local-variable #'php-project--eval-bootstrap-scripts) |
| 115 | 113 | ||
| 116 | ;;;###autoload | ||
| 117 | (progn | ||
| 118 | (defvar-local php-project-php-executable nil | 114 | (defvar-local php-project-php-executable nil |
| 119 | "Path to php executable file.") | 115 | "Path to php executable file.") |
| 120 | (put 'php-project-php-executable 'safe-local-variable | 116 | (put 'php-project-php-executable 'safe-local-variable |
| 121 | #'(lambda (v) (and (stringp v) (file-executable-p v))))) | 117 | #'(lambda (v) (and (stringp v) (file-executable-p v)))) |
| 122 | 118 | ||
| 123 | ;;;###autoload | ||
| 124 | (progn | ||
| 125 | (defvar-local php-project-phan-executable nil | 119 | (defvar-local php-project-phan-executable nil |
| 126 | "Path to phan executable file.") | 120 | "Path to phan executable file.") |
| 127 | (put 'php-project-phan-executable 'safe-local-variable #'php-project--eval-bootstrap-scripts)) | 121 | (put 'php-project-phan-executable 'safe-local-variable #'php-project--eval-bootstrap-scripts) |
| 128 | 122 | ||
| 129 | ;;;###autoload | ||
| 130 | (progn | ||
| 131 | (defvar-local php-project-coding-style nil | 123 | (defvar-local php-project-coding-style nil |
| 132 | "Symbol value of the coding style of the project that PHP major mode refers to. | 124 | "Symbol value of the coding style of the project that PHP major mode refers to. |
| 133 | 125 | ||
| 134 | Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.") | 126 | Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.") |
| 135 | (put 'php-project-coding-style 'safe-local-variable #'symbolp)) | 127 | (put 'php-project-coding-style 'safe-local-variable #'symbolp) |
| 136 | 128 | ||
| 137 | ;;;###autoload | 129 | (defvar-local php-project-php-file-as-template 'auto |
| 138 | (progn | 130 | " |
| 139 | (defvar php-project-repl nil | 131 | `auto' (default) |
| 132 | Automatically switch to mode for template when HTML tag detected in file. | ||
| 133 | |||
| 134 | `t' | ||
| 135 | Switch all PHP files in that directory to mode for HTML template. | ||
| 136 | |||
| 137 | `nil' | ||
| 138 | Any .php in that directory is just a PHP script. | ||
| 139 | |||
| 140 | \(\(PATTERN . SYMBOL)) | ||
| 141 | Alist of file name pattern regular expressions and the above symbol pairs. | ||
| 142 | PATTERN is regexp pattern. | ||
| 143 | ") | ||
| 144 | (put 'php-project-php-file-as-template 'safe-local-variable #'php-project--validate-php-file-as-template) | ||
| 145 | |||
| 146 | (defvar-local php-project-repl nil | ||
| 140 | "Function name or path to REPL (interactive shell) script.") | 147 | "Function name or path to REPL (interactive shell) script.") |
| 141 | (make-variable-buffer-local 'php-project-repl) | ||
| 142 | (put 'php-project-repl 'safe-local-variable | 148 | (put 'php-project-repl 'safe-local-variable |
| 143 | #'(lambda (v) (or (functionp v) | 149 | #'(lambda (v) (or (functionp v) |
| 144 | (php-project--eval-bootstrap-scripts v))))) | 150 | (php-project--eval-bootstrap-scripts v)))) |
| 145 | 151 | ||
| 146 | ;;;###autoload | 152 | (defvar-local php-project-unit-test nil |
| 147 | (progn | ||
| 148 | (defvar php-project-unit-test nil | ||
| 149 | "Function name or path to unit test script.") | 153 | "Function name or path to unit test script.") |
| 150 | (make-variable-buffer-local 'php-project-unit-test) | ||
| 151 | (put 'php-project-unit-test 'safe-local-variable | 154 | (put 'php-project-unit-test 'safe-local-variable |
| 152 | #'(lambda (v) (or (functionp v) | 155 | #'(lambda (v) (or (functionp v) |
| 153 | (php-project--eval-bootstrap-scripts v))))) | 156 | (php-project--eval-bootstrap-scripts v)))) |
| 154 | 157 | ||
| 155 | ;;;###autoload | 158 | (defvar-local php-project-deploy nil |
| 156 | (progn | ||
| 157 | (defvar php-project-deploy nil | ||
| 158 | "Function name or path to deploy script.") | 159 | "Function name or path to deploy script.") |
| 159 | (make-variable-buffer-local 'php-project-deploy) | ||
| 160 | (put 'php-project-deploy 'safe-local-variable | 160 | (put 'php-project-deploy 'safe-local-variable |
| 161 | #'(lambda (v) (or (functionp v) | 161 | #'(lambda (v) (or (functionp v) |
| 162 | (php-project--eval-bootstrap-scripts v))))) | 162 | (php-project--eval-bootstrap-scripts v)))) |
| 163 | 163 | ||
| 164 | ;;;###autoload | 164 | (defvar-local php-project-build nil |
| 165 | (progn | ||
| 166 | (defvar php-project-build nil | ||
| 167 | "Function name or path to build script.") | 165 | "Function name or path to build script.") |
| 168 | (make-variable-buffer-local 'php-project-build) | ||
| 169 | (put 'php-project-build 'safe-local-variable | 166 | (put 'php-project-build 'safe-local-variable |
| 170 | #'(lambda (v) (or (functionp v) | 167 | #'(lambda (v) (or (functionp v) |
| 171 | (php-project--eval-bootstrap-scripts v))))) | 168 | (php-project--eval-bootstrap-scripts v)))) |
| 172 | 169 | ||
| 173 | ;;;###autoload | 170 | (defvar-local php-project-server-start nil |
| 174 | (progn | ||
| 175 | (defvar php-project-server-start nil | ||
| 176 | "Function name or path to server-start script.") | 171 | "Function name or path to server-start script.") |
| 177 | (make-variable-buffer-local 'php-project-server-start) | ||
| 178 | (put 'php-project-server-start 'safe-local-variable | 172 | (put 'php-project-server-start 'safe-local-variable |
| 179 | #'(lambda (v) (or (functionp v) | 173 | #'(lambda (v) (or (functionp v) |
| 180 | (php-project--eval-bootstrap-scripts v))))) | 174 | (php-project--eval-bootstrap-scripts v))))) |
| 181 | 175 | ||
| 182 | 176 | ||
| 183 | ;; Functions | 177 | ;; Functions |
| 178 | (defun php-project--validate-php-file-as-template (val) | ||
| 179 | "Return T when `VAL' is valid list of safe ." | ||
| 180 | (cond | ||
| 181 | ((null val) t) | ||
| 182 | ((memq val '(t auto)) t) | ||
| 183 | ((listp val) | ||
| 184 | (cl-loop for v in val | ||
| 185 | always (and (consp v) | ||
| 186 | (stringp (car v)) | ||
| 187 | (php-project--validate-php-file-as-template (cdr v))))) | ||
| 188 | (t nil))) | ||
| 184 | 189 | ||
| 185 | (defun php-project--eval-bootstrap-scripts (val) | 190 | (defun php-project--eval-bootstrap-scripts (val) |
| 186 | "Return T when `VAL' is valid list of safe bootstrap php script." | 191 | "Return T when `VAL' is valid list of safe bootstrap php script." |
| @@ -213,6 +218,17 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.") | |||
| 213 | (cons 'root "vendor/bin/phan")))) | 218 | (cons 'root "vendor/bin/phan")))) |
| 214 | (executable-find "phan"))) | 219 | (executable-find "phan"))) |
| 215 | 220 | ||
| 221 | (defun php-project-get-file-html-template-type (filename) | ||
| 222 | "Return symbol T, NIL or `auto' by `FILENAME'." | ||
| 223 | (cond | ||
| 224 | ((not php-project-php-file-as-template) nil) | ||
| 225 | ((eq t php-project-php-file-as-template) t) | ||
| 226 | ((eq 'auto php-project-php-file-as-template) 'auto) | ||
| 227 | ((listp php-project-php-file-as-template) | ||
| 228 | (assoc-default filename php-project-php-file-as-template #'string-match-p)) | ||
| 229 | (t (prog1 nil | ||
| 230 | (warn "php-project-php-file-as-template is unexpected format"))))) | ||
| 231 | |||
| 216 | ;;;###autoload | 232 | ;;;###autoload |
| 217 | (defun php-project-get-bootstrap-scripts () | 233 | (defun php-project-get-bootstrap-scripts () |
| 218 | "Return list of bootstrap script." | 234 | "Return list of bootstrap script." |
diff --git a/.emacs.d/lisp/php.el b/.emacs.d/lisp/php.el index db9e46d..13f2cef 100644 --- a/.emacs.d/lisp/php.el +++ b/.emacs.d/lisp/php.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: USAMI Kenta <tadsan@zonu.me> | 5 | ;; Author: USAMI Kenta <tadsan@zonu.me> |
| 6 | ;; Created: 5 Dec 2018 | 6 | ;; Created: 5 Dec 2018 |
| 7 | ;; Version: 1.21.2 | 7 | ;; Version: 1.21.3 |
| 8 | ;; Keywords: languages, php | 8 | ;; Keywords: languages, php |
| 9 | ;; Homepage: https://github.com/emacs-php/php-mode | 9 | ;; Homepage: https://github.com/emacs-php/php-mode |
| 10 | ;; Package-Requires: ((emacs "24.3") (cl-lib "0.5")) | 10 | ;; Package-Requires: ((emacs "24.3") (cl-lib "0.5")) |
| @@ -29,6 +29,7 @@ | |||
| 29 | 29 | ||
| 30 | ;;; Code: | 30 | ;;; Code: |
| 31 | (require 'flymake) | 31 | (require 'flymake) |
| 32 | (require 'php-project) | ||
| 32 | 33 | ||
| 33 | ;;;###autoload | 34 | ;;;###autoload |
| 34 | (defgroup php nil | 35 | (defgroup php nil |
| @@ -40,17 +41,23 @@ | |||
| 40 | 41 | ||
| 41 | (defcustom php-executable (or (executable-find "php") "/usr/bin/php") | 42 | (defcustom php-executable (or (executable-find "php") "/usr/bin/php") |
| 42 | "The location of the PHP executable." | 43 | "The location of the PHP executable." |
| 44 | :group 'php | ||
| 45 | :tag "PHP Executable" | ||
| 43 | :type 'string) | 46 | :type 'string) |
| 44 | 47 | ||
| 45 | (defcustom php-site-url "https://php.net/" | 48 | (defcustom php-site-url "https://php.net/" |
| 46 | "Default PHP.net site URL. | 49 | "Default PHP.net site URL. |
| 47 | 50 | ||
| 48 | The URL to use open PHP manual and search word." | 51 | The URL to use open PHP manual and search word." |
| 52 | :group 'php | ||
| 53 | :tag "PHP Site URL" | ||
| 49 | :type 'string) | 54 | :type 'string) |
| 50 | 55 | ||
| 51 | (defcustom php-manual-url 'en | 56 | (defcustom php-manual-url 'en |
| 52 | "URL at which to find PHP manual. | 57 | "URL at which to find PHP manual. |
| 53 | You can replace \"en\" with your ISO language code." | 58 | You can replace \"en\" with your ISO language code." |
| 59 | :group 'php | ||
| 60 | :tag "PHP Manual URL" | ||
| 54 | :type '(choice (const :tag "English" 'en) | 61 | :type '(choice (const :tag "English" 'en) |
| 55 | (const :tag "Brazilian Portuguese" 'pt_BR) | 62 | (const :tag "Brazilian Portuguese" 'pt_BR) |
| 56 | (const :tag "Chinese (Simplified)" 'zh) | 63 | (const :tag "Chinese (Simplified)" 'zh) |
| @@ -66,6 +73,7 @@ You can replace \"en\" with your ISO language code." | |||
| 66 | (defcustom php-search-url nil | 73 | (defcustom php-search-url nil |
| 67 | "URL at which to search for documentation on a word." | 74 | "URL at which to search for documentation on a word." |
| 68 | :group 'php | 75 | :group 'php |
| 76 | :tag "PHP Search URL" | ||
| 69 | :type '(choice (string :tag "URL to search PHP documentation") | 77 | :type '(choice (string :tag "URL to search PHP documentation") |
| 70 | (const :tag "Use `php-site-url' variable" nil))) | 78 | (const :tag "Use `php-site-url' variable" nil))) |
| 71 | 79 | ||
| @@ -78,6 +86,41 @@ You can replace \"en\" with your ISO language code." | |||
| 78 | "Suffix for inserted namespace." | 86 | "Suffix for inserted namespace." |
| 79 | :group 'php | 87 | :group 'php |
| 80 | :type 'string) | 88 | :type 'string) |
| 89 | |||
| 90 | (defcustom php-default-major-mode 'php-mode | ||
| 91 | "Major mode for editing PHP script." | ||
| 92 | :group 'php | ||
| 93 | :tag "PHP Default Major Mode" | ||
| 94 | :type 'function) | ||
| 95 | |||
| 96 | (defcustom php-html-template-major-mode 'web-mode | ||
| 97 | "Major mode for editing PHP-HTML template." | ||
| 98 | :group 'php | ||
| 99 | :tag "PHP-HTML Template Major Mode" | ||
| 100 | :type 'function) | ||
| 101 | |||
| 102 | (defcustom php-blade-template-major-mode 'web-mode | ||
| 103 | "Major mode for editing Blade template." | ||
| 104 | :group 'php | ||
| 105 | :tag "PHP Blade Template Major Mode" | ||
| 106 | :type 'function) | ||
| 107 | |||
| 108 | (defcustom php-template-mode-alist | ||
| 109 | `(("\\.blade" . ,php-blade-template-major-mode) | ||
| 110 | ("\\.phpt\\'" . ,(if (fboundp 'phpt-mode) 'phpt-mode php-html-template-major-mode)) | ||
| 111 | ("\\.phtml\\'" . ,php-html-template-major-mode)) | ||
| 112 | "Automatically use another MAJOR-MODE when open template file." | ||
| 113 | :group 'php | ||
| 114 | :tag "PHP Template Mode Alist" | ||
| 115 | :type '(alist :key-type regexp :value-type function) | ||
| 116 | :link '(url-link :tag "web-mode" "http://web-mode.org/") | ||
| 117 | :link '(url-link :tag "phpt-mode" "https://github.com/emacs-php/phpt-mode")) | ||
| 118 | |||
| 119 | (defcustom php-mode-maybe-hook nil | ||
| 120 | "List of functions to be executed on entry to `php-mode-maybe'." | ||
| 121 | :group 'php | ||
| 122 | :tag "PHP Mode Maybe Hook" | ||
| 123 | :type 'hook) | ||
| 81 | 124 | ||
| 82 | ;;; PHP Keywords | 125 | ;;; PHP Keywords |
| 83 | (defconst php-magical-constants | 126 | (defconst php-magical-constants |
| @@ -101,6 +144,11 @@ it is the character that will terminate the string, or t if the string should be | |||
| 101 | "Return character address of start of comment or string; nil if not in one." | 144 | "Return character address of start of comment or string; nil if not in one." |
| 102 | (nth 8 (syntax-ppss))) | 145 | (nth 8 (syntax-ppss))) |
| 103 | 146 | ||
| 147 | (defsubst php-in-poly-php-html-mode () | ||
| 148 | "Return T if current buffer is in `poly-html-mode'." | ||
| 149 | (and (boundp 'poly-php-html-mode) | ||
| 150 | (symbol-value 'poly-php-html-mode))) | ||
| 151 | |||
| 104 | (defun php-create-regexp-for-method (visibility) | 152 | (defun php-create-regexp-for-method (visibility) |
| 105 | "Make a regular expression for methods with the given VISIBILITY. | 153 | "Make a regular expression for methods with the given VISIBILITY. |
| 106 | 154 | ||
| @@ -187,6 +235,54 @@ Look at the `php-executable' variable instead of the constant \"php\" command." | |||
| 187 | 'flymake-php-init))))) | 235 | 'flymake-php-init))))) |
| 188 | (list php-executable (cdr init)))) | 236 | (list php-executable (cdr init)))) |
| 189 | 237 | ||
| 238 | (defconst php-re-detect-html-tag | ||
| 239 | (eval-when-compile | ||
| 240 | (rx (or (: string-start (* (in space)) | ||
| 241 | "<!" | ||
| 242 | (or "DOCTYPE" "doctype") | ||
| 243 | (+ (in space)) | ||
| 244 | (or "HTML" "html")) | ||
| 245 | (: (or line-start | ||
| 246 | (: "<" (? "/") | ||
| 247 | (* (in space)) (+ (in alpha "-")) (* (in space)) ">")) | ||
| 248 | (: "<" (* (in space)) (+ (in alpha "-")) (* (in space)) ">")))))) | ||
| 249 | |||
| 250 | (defun php-buffer-has-html-tag () | ||
| 251 | "Return position of HTML tag or NIL in current buffer." | ||
| 252 | (save-excursion | ||
| 253 | (save-restriction | ||
| 254 | (widen) | ||
| 255 | (goto-char (point-min)) | ||
| 256 | (re-search-forward php-re-detect-html-tag nil t)))) | ||
| 257 | |||
| 258 | (defun php-derivation-major-mode () | ||
| 259 | "Return major mode for PHP file by file-name and its content." | ||
| 260 | (let ((mode (assoc-default buffer-file-name | ||
| 261 | php-template-mode-alist | ||
| 262 | #'string-match-p)) | ||
| 263 | type) | ||
| 264 | (when (and (null mode) buffer-file-name | ||
| 265 | php-project-php-file-as-template) | ||
| 266 | (setq type (php-project-get-file-html-template-type buffer-file-name)) | ||
| 267 | (cond | ||
| 268 | ((eq t type) (setq mode php-html-template-major-mode)) | ||
| 269 | ((eq 'auto type) | ||
| 270 | (when (php-buffer-has-html-tag) | ||
| 271 | (setq mode php-html-template-major-mode))))) | ||
| 272 | (when (and mode (not (fboundp mode))) | ||
| 273 | (if (string-match-p "\\.blade\\." buffer-file-name) | ||
| 274 | (warn "php-mode is NOT support blade template. %s" | ||
| 275 | "Please install `web-mode' package") | ||
| 276 | (setq mode nil))) | ||
| 277 | (or mode php-default-major-mode))) | ||
| 278 | |||
| 279 | ;;;###autoload | ||
| 280 | (defun php-mode-maybe () | ||
| 281 | "Select PHP mode or other major mode." | ||
| 282 | (interactive) | ||
| 283 | (run-hooks php-mode-maybe-hook) | ||
| 284 | (funcall (php-derivation-major-mode))) | ||
| 285 | |||
| 190 | ;;;###autoload | 286 | ;;;###autoload |
| 191 | (defun php-current-class () | 287 | (defun php-current-class () |
| 192 | "Insert current class name if cursor in class context." | 288 | "Insert current class name if cursor in class context." |
