diff options
| -rw-r--r-- | .emacs.d/lisp/php-mode.el | 100 |
1 files changed, 75 insertions, 25 deletions
diff --git a/.emacs.d/lisp/php-mode.el b/.emacs.d/lisp/php-mode.el index dc9b738..64c58a7 100644 --- a/.emacs.d/lisp/php-mode.el +++ b/.emacs.d/lisp/php-mode.el | |||
| @@ -15,7 +15,7 @@ | |||
| 15 | (defconst php-mode-version-number "1.19.0" | 15 | (defconst php-mode-version-number "1.19.0" |
| 16 | "PHP Mode version number.") | 16 | "PHP Mode version number.") |
| 17 | 17 | ||
| 18 | (defconst php-mode-modified "2018-03-24" | 18 | (defconst php-mode-modified "2018-03-28" |
| 19 | "PHP Mode build date.") | 19 | "PHP Mode build date.") |
| 20 | 20 | ||
| 21 | ;; This file is free software; you can redistribute it and/or | 21 | ;; This file is free software; you can redistribute it and/or |
| @@ -396,8 +396,9 @@ In that case set to `NIL'." | |||
| 396 | (defun php-mode-version () | 396 | (defun php-mode-version () |
| 397 | "Display string describing the version of PHP Mode." | 397 | "Display string describing the version of PHP Mode." |
| 398 | (interactive) | 398 | (interactive) |
| 399 | (message "PHP Mode %s of %s" | 399 | (funcall |
| 400 | php-mode-version-number php-mode-modified)) | 400 | (if (called-interactively-p 'interactive) #'message #'format) |
| 401 | "PHP Mode %s of %s" php-mode-version-number php-mode-modified)) | ||
| 401 | 402 | ||
| 402 | ;;;###autoload | 403 | ;;;###autoload |
| 403 | (define-obsolete-variable-alias 'php-available-project-root-files 'php-project-available-root-files "1.19.0") | 404 | (define-obsolete-variable-alias 'php-available-project-root-files 'php-project-available-root-files "1.19.0") |
| @@ -1161,29 +1162,63 @@ After setting the stylevars run hooks according to STYLENAME | |||
| 1161 | (prog1 (php-set-style (symbol-name coding-style)) | 1162 | (prog1 (php-set-style (symbol-name coding-style)) |
| 1162 | (remove-hook 'hack-local-variables-hook #'php-mode-set-style-delay))))) | 1163 | (remove-hook 'hack-local-variables-hook #'php-mode-set-style-delay))))) |
| 1163 | 1164 | ||
| 1165 | (defun php-mode-debug--buffer (&optional command &rest args) | ||
| 1166 | "Return buffer for php-mode-debug, and execute `COMMAND' with `ARGS'." | ||
| 1167 | (with-current-buffer (get-buffer-create "*PHP Mode DEBUG*") | ||
| 1168 | (cl-case command | ||
| 1169 | (init (erase-buffer) | ||
| 1170 | (goto-address-mode)) | ||
| 1171 | (top (goto-char (point-min))) | ||
| 1172 | (insert (goto-char (point-max)) | ||
| 1173 | (apply #'insert args))) | ||
| 1174 | (current-buffer))) | ||
| 1175 | |||
| 1176 | (defun php-mode-debug--message (format-string &rest args) | ||
| 1177 | "Write message `FORMAT-STRING' and `ARGS' to debug buffer, like `message'." | ||
| 1178 | (declare (indent 1)) | ||
| 1179 | (php-mode-debug--buffer 'insert (apply #'format format-string args) "\n")) | ||
| 1180 | |||
| 1164 | (defun php-mode-debug () | 1181 | (defun php-mode-debug () |
| 1165 | "Display informations useful for debugging PHP Mode." | 1182 | "Display informations useful for debugging PHP Mode." |
| 1166 | (interactive) | 1183 | (interactive) |
| 1167 | (message "--- PHP-MODE DEBUG BEGIN ---") | 1184 | (require 'cus-edit) |
| 1168 | (message "versions: %s; %s" (emacs-version) (php-mode-version)) | 1185 | (php-mode-debug--buffer 'init) |
| 1169 | (message "major-mode: %s" major-mode) | 1186 | (php-mode-debug--message "Feel free to report on GitHub what you noticed!") |
| 1170 | (message "minor-modes: %s" | 1187 | (php-mode-debug--message "https://github.com/ejmr/php-mode/issues/new") |
| 1171 | (cl-loop for s in minor-mode-list | 1188 | (php-mode-debug--message "") |
| 1172 | unless (string-match-p "global" (symbol-name s)) | 1189 | (php-mode-debug--message "Pasting the following information on the issue will help us to investigate the cause.") |
| 1173 | if (and (boundp s) (symbol-value s)) | 1190 | (php-mode-debug--message "```") |
| 1174 | collect s)) | 1191 | (php-mode-debug--message "--- PHP-MODE DEBUG BEGIN ---") |
| 1175 | (message "variables: %s" | 1192 | (php-mode-debug--message "versions: %s; %s" (emacs-version) (php-mode-version)) |
| 1176 | (cl-loop for v in '(indent-tabs-mode tab-width) | 1193 | (php-mode-debug--message "package-version: %s" |
| 1177 | collect (list v (symbol-value v)))) | 1194 | (let ((pkg (and (boundp 'package-alist) |
| 1178 | (message "custom variables: %s" | 1195 | (cadr (assq 'php-mode package-alist))))) |
| 1179 | (cl-loop for (v type) in (custom-group-members 'php nil) | 1196 | (when (and pkg (member (package-desc-status pkg) '("unsigned" "dependency"))) |
| 1180 | if (eq type 'custom-variable) | 1197 | (package-version-join (package-desc-version pkg))))) |
| 1181 | collect (list v (symbol-value v)))) | 1198 | (php-mode-debug--message "major-mode: %s" major-mode) |
| 1182 | (message "c-indentation-style: %s" c-indentation-style) | 1199 | (php-mode-debug--message "minor-modes: %s" |
| 1183 | (message "c-style-variables: %s" (c-get-style-variables c-indentation-style nil)) | 1200 | (cl-loop for s in minor-mode-list |
| 1184 | (message "--- PHP-MODE DEBUG END ---") | 1201 | unless (string-match-p "global" (symbol-name s)) |
| 1185 | (switch-to-buffer "*Messages*") | 1202 | if (and (boundp s) (symbol-value s)) |
| 1186 | (goto-char (point-max))) | 1203 | collect s)) |
| 1204 | (php-mode-debug--message "variables: %s" | ||
| 1205 | (cl-loop for v in '(indent-tabs-mode tab-width) | ||
| 1206 | collect (list v (symbol-value v)))) | ||
| 1207 | (php-mode-debug--message "custom variables: %s" | ||
| 1208 | (cl-loop for (v type) in (custom-group-members 'php nil) | ||
| 1209 | if (eq type 'custom-variable) | ||
| 1210 | collect (list v (symbol-value v)))) | ||
| 1211 | (php-mode-debug--message "c-indentation-style: %s" c-indentation-style) | ||
| 1212 | (php-mode-debug--message "c-style-variables: %s" | ||
| 1213 | (cl-loop for v in c-style-variables | ||
| 1214 | unless (memq v '(c-doc-comment-style c-offsets-alist)) | ||
| 1215 | collect (list v (symbol-value v)))) | ||
| 1216 | (php-mode-debug--message "c-doc-comment-style: %s" c-doc-comment-style) | ||
| 1217 | (php-mode-debug--message "c-offsets-alist: %s" c-offsets-alist) | ||
| 1218 | (php-mode-debug--message "--- PHP-MODE DEBUG END ---") | ||
| 1219 | (php-mode-debug--message "```\n") | ||
| 1220 | (php-mode-debug--message "Thank you!") | ||
| 1221 | (pop-to-buffer (php-mode-debug--buffer 'top))) | ||
| 1187 | 1222 | ||
| 1188 | ;;;###autoload | 1223 | ;;;###autoload |
| 1189 | (define-derived-mode php-mode c-mode "PHP" | 1224 | (define-derived-mode php-mode c-mode "PHP" |
| @@ -1790,8 +1825,23 @@ The output will appear in the buffer *PHP*." | |||
| 1790 | 1825 | ||
| 1791 | 1826 | ||
| 1792 | ;;;###autoload | 1827 | ;;;###autoload |
| 1793 | (dolist (pattern '("\\.php[s345t]?\\'" "/\\.php_cs\\(\\.dist\\)?\\'" "\\.phtml\\'" "/Amkfile\\'" "\\.amk\\'")) | 1828 | (add-to-list 'auto-mode-alist |
| 1794 | (add-to-list 'auto-mode-alist `(,pattern . php-mode) t)) | 1829 | (cons |
| 1830 | (eval-when-compile | ||
| 1831 | (rx (or | ||
| 1832 | ;; File name extensions (ex. "*.php", "*.phtml") | ||
| 1833 | (: "." | ||
| 1834 | (or (: "php" (? (in "s345t"))) | ||
| 1835 | "amk" | ||
| 1836 | "phtml")) | ||
| 1837 | ;; Full file names (ex. "/Makefile", "/Amkfile") | ||
| 1838 | (: "/" | ||
| 1839 | (or "Amkfile" | ||
| 1840 | ".php_cs" | ||
| 1841 | ".php_cs.dist"))) | ||
| 1842 | string-end)) | ||
| 1843 | 'php-mode) | ||
| 1844 | t) | ||
| 1795 | 1845 | ||
| 1796 | (provide 'php-mode) | 1846 | (provide 'php-mode) |
| 1797 | 1847 | ||
