summaryrefslogtreecommitdiff
path: root/.emacs.d/lisp/php-mode.el
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d/lisp/php-mode.el')
-rw-r--r--.emacs.d/lisp/php-mode.el115
1 files changed, 76 insertions, 39 deletions
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.
144Ignores php-file patterns option; fixed to expression \"\\.\\(inc\\|php[s345]?\\)\"" 145Ignores 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.
155Turning this on will open it whenever `php-mode' is loaded." 157Turning 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
213parent. Set this variable to t if you want to use 219parent. 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'
215enabled." 221enabled."
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.\"
260Turning this on will force PEAR rules on all PHP files." 280Turning 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."
265mumamo-mode turned on. Detects if there are any HTML tags in the 287mumamo-mode turned on. Detects if there are any HTML tags in the
266buffer before warning, but this is is not very smart; e.g. if you 288buffer before warning, but this is is not very smart; e.g. if you
267have any tags inside a PHP string, it will be fooled." 289have 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
298If you want to suppress styles from being overwritten by directory / file 324If you want to suppress styles from being overwritten by directory / file
299local variables, set NIL." 325local 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
305This function may interfere with other hooks and other behaviors. 333This function may interfere with other hooks and other behaviors.
306In that case set to `NIL'." 334In 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
825If the optional argument `QUIET' is non-nil then no syntactic errors are
826reported, 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'."
1221If non-nil, this shadows the value of `browse-url-browser-function' when 1271If non-nil, this shadows the value of `browse-url-browser-function' when
1222calling `php-search-documentation' or `php-search-local-documentation'." 1272calling `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