From 58206fbeb12ad33430f6791d6a0e79a2fab6725a Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Wed, 28 Mar 2018 18:27:05 +0200 Subject: Upgrade php-mode --- .emacs.d/lisp/php-mode.el | 100 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 25 deletions(-) (limited to '.emacs.d/lisp') 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 @@ (defconst php-mode-version-number "1.19.0" "PHP Mode version number.") -(defconst php-mode-modified "2018-03-24" +(defconst php-mode-modified "2018-03-28" "PHP Mode build date.") ;; This file is free software; you can redistribute it and/or @@ -396,8 +396,9 @@ In that case set to `NIL'." (defun php-mode-version () "Display string describing the version of PHP Mode." (interactive) - (message "PHP Mode %s of %s" - php-mode-version-number php-mode-modified)) + (funcall + (if (called-interactively-p 'interactive) #'message #'format) + "PHP Mode %s of %s" php-mode-version-number php-mode-modified)) ;;;###autoload (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 (prog1 (php-set-style (symbol-name coding-style)) (remove-hook 'hack-local-variables-hook #'php-mode-set-style-delay))))) +(defun php-mode-debug--buffer (&optional command &rest args) + "Return buffer for php-mode-debug, and execute `COMMAND' with `ARGS'." + (with-current-buffer (get-buffer-create "*PHP Mode DEBUG*") + (cl-case command + (init (erase-buffer) + (goto-address-mode)) + (top (goto-char (point-min))) + (insert (goto-char (point-max)) + (apply #'insert args))) + (current-buffer))) + +(defun php-mode-debug--message (format-string &rest args) + "Write message `FORMAT-STRING' and `ARGS' to debug buffer, like `message'." + (declare (indent 1)) + (php-mode-debug--buffer 'insert (apply #'format format-string args) "\n")) + (defun php-mode-debug () "Display informations useful for debugging PHP Mode." (interactive) - (message "--- PHP-MODE DEBUG BEGIN ---") - (message "versions: %s; %s" (emacs-version) (php-mode-version)) - (message "major-mode: %s" major-mode) - (message "minor-modes: %s" - (cl-loop for s in minor-mode-list - unless (string-match-p "global" (symbol-name s)) - if (and (boundp s) (symbol-value s)) - collect s)) - (message "variables: %s" - (cl-loop for v in '(indent-tabs-mode tab-width) - collect (list v (symbol-value v)))) - (message "custom variables: %s" - (cl-loop for (v type) in (custom-group-members 'php nil) - if (eq type 'custom-variable) - collect (list v (symbol-value v)))) - (message "c-indentation-style: %s" c-indentation-style) - (message "c-style-variables: %s" (c-get-style-variables c-indentation-style nil)) - (message "--- PHP-MODE DEBUG END ---") - (switch-to-buffer "*Messages*") - (goto-char (point-max))) + (require 'cus-edit) + (php-mode-debug--buffer 'init) + (php-mode-debug--message "Feel free to report on GitHub what you noticed!") + (php-mode-debug--message "https://github.com/ejmr/php-mode/issues/new") + (php-mode-debug--message "") + (php-mode-debug--message "Pasting the following information on the issue will help us to investigate the cause.") + (php-mode-debug--message "```") + (php-mode-debug--message "--- PHP-MODE DEBUG BEGIN ---") + (php-mode-debug--message "versions: %s; %s" (emacs-version) (php-mode-version)) + (php-mode-debug--message "package-version: %s" + (let ((pkg (and (boundp 'package-alist) + (cadr (assq 'php-mode package-alist))))) + (when (and pkg (member (package-desc-status pkg) '("unsigned" "dependency"))) + (package-version-join (package-desc-version pkg))))) + (php-mode-debug--message "major-mode: %s" major-mode) + (php-mode-debug--message "minor-modes: %s" + (cl-loop for s in minor-mode-list + unless (string-match-p "global" (symbol-name s)) + if (and (boundp s) (symbol-value s)) + collect s)) + (php-mode-debug--message "variables: %s" + (cl-loop for v in '(indent-tabs-mode tab-width) + collect (list v (symbol-value v)))) + (php-mode-debug--message "custom variables: %s" + (cl-loop for (v type) in (custom-group-members 'php nil) + if (eq type 'custom-variable) + collect (list v (symbol-value v)))) + (php-mode-debug--message "c-indentation-style: %s" c-indentation-style) + (php-mode-debug--message "c-style-variables: %s" + (cl-loop for v in c-style-variables + unless (memq v '(c-doc-comment-style c-offsets-alist)) + collect (list v (symbol-value v)))) + (php-mode-debug--message "c-doc-comment-style: %s" c-doc-comment-style) + (php-mode-debug--message "c-offsets-alist: %s" c-offsets-alist) + (php-mode-debug--message "--- PHP-MODE DEBUG END ---") + (php-mode-debug--message "```\n") + (php-mode-debug--message "Thank you!") + (pop-to-buffer (php-mode-debug--buffer 'top))) ;;;###autoload (define-derived-mode php-mode c-mode "PHP" @@ -1790,8 +1825,23 @@ The output will appear in the buffer *PHP*." ;;;###autoload -(dolist (pattern '("\\.php[s345t]?\\'" "/\\.php_cs\\(\\.dist\\)?\\'" "\\.phtml\\'" "/Amkfile\\'" "\\.amk\\'")) - (add-to-list 'auto-mode-alist `(,pattern . php-mode) t)) +(add-to-list 'auto-mode-alist + (cons + (eval-when-compile + (rx (or + ;; File name extensions (ex. "*.php", "*.phtml") + (: "." + (or (: "php" (? (in "s345t"))) + "amk" + "phtml")) + ;; Full file names (ex. "/Makefile", "/Amkfile") + (: "/" + (or "Amkfile" + ".php_cs" + ".php_cs.dist"))) + string-end)) + 'php-mode) + t) (provide 'php-mode) -- cgit v1.3