From de9d904f4a4a7b3df8d536bc3dc964c1b2c61786 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Tue, 6 Mar 2018 13:11:32 +0100 Subject: Upgrade php-mode, yasnippet and add glib_false glib_print glib_printf glib_true --- .emacs.d/lisp/php-mode.el | 104 +++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 70 deletions(-) (limited to '.emacs.d/lisp/php-mode.el') diff --git a/.emacs.d/lisp/php-mode.el b/.emacs.d/lisp/php-mode.el index 629c974..2e23642 100644 --- a/.emacs.d/lisp/php-mode.el +++ b/.emacs.d/lisp/php-mode.el @@ -8,14 +8,14 @@ ;; Maintainer: USAMI Kenta ;; URL: https://github.com/ejmr/php-mode ;; Keywords: languages php -;; Version: 1.18.4 +;; Version: 1.19.0 ;; Package-Requires: ((emacs "24") (cl-lib "0.5")) ;; License: GPL-3.0-or-later -(defconst php-mode-version-number "1.18.4" +(defconst php-mode-version-number "1.19.0" "PHP Mode version number.") -(defconst php-mode-modified "2018-01-30" +(defconst php-mode-modified "2018-03-05" "PHP Mode build date.") ;; This file is free software; you can redistribute it and/or @@ -83,9 +83,11 @@ (require 'etags) (require 'speedbar) (require 'imenu) +(require 'php-project nil t) (require 'cl-lib) (require 'mode-local) +(require 'php-project) (eval-when-compile (require 'regexp-opt) @@ -373,14 +375,15 @@ This variable can take one of the following symbol values: (const :tag "WordPress" wordpress) (const :tag "Symfony2" symfony2) (const :tag "PSR-2" psr2)) - :set 'php-mode-custom-coding-style-set :initialize 'custom-initialize-default) -(defun php-mode-custom-coding-style-set (sym value) - (when (eq major-mode 'php-mode) - (set sym value) - (set-default sym value) - (php-set-style (symbol-name value)))) + +(defcustom php-mode-enable-project-coding-style t + "When set to true override php-mode-coding-style by php-project-coding-style. + +If you want to suppress styles from being overwritten by directory / file +local variables, set NIL." + :type 'boolean) (defun php-mode-version () "Display string describing the version of PHP Mode." @@ -388,30 +391,8 @@ This variable can take one of the following symbol values: (message "PHP Mode %s of %s" php-mode-version-number php-mode-modified)) -(defvar php-available-project-root-files - '((projectile ".projectile") - (composer "composer.json" "composer.lock") - (git ".git") - (mercurial ".hg") - (subversion ".svn") - ;; NOTICE: This method does not detect the top level of .editorconfig - ;; However, we can integrate it by adding the editorconfig.el's API. - ;;(editorconfig . ".editorconfig") - )) - ;;;###autoload -(progn - (defvar php-project-root 'auto - "Method of searching for the top level directory. - -`auto' (default) - Try to search file in order of `php-available-project-root-files'. - -SYMBOL - Key of `php-available-project-root-files'.") - (make-variable-buffer-local 'php-project-root) - (put 'php-project-root 'safe-local-variable - #'(lambda (v) (assq v php-available-project-root-files)))) +(define-obsolete-variable-alias 'php-available-project-root-files 'php-project-available-root-files "1.19.0") (defvar php-mode-map (let ((map (make-sparse-keymap))) @@ -441,11 +422,8 @@ SYMBOL ;; ;; https://www.gnu.org/software/emacs/manual/html_node/ccmode/Subword-Movement.html ;; - ;; for more information about Submode Word. - (if (boundp 'subword-mode) - (if subword-mode - (subword-mode nil) - (subword-mode t))) + ;; for more information about Subword mode. + (define-key map (kbd "C-c C-w") 'subword-mode) ;; We inherit c-beginning-of-defun and c-end-of-defun from CC Mode ;; but we have two replacement functions specifically for PHP. We @@ -595,7 +573,6 @@ PHP does not have an \"enum\"-like keyword." "iterable" "as" "break" - "catch all" "catch" "clone" "default" @@ -682,7 +659,6 @@ but only if the setting is enabled" (indent-tabs-mode . nil) (tab-width . ,(default-value 'tab-width)) (fill-column . ,(default-value 'fill-column)) - (require-final-newline . ,(default-value 'require-final-newline)) (show-trailing-whitespace . ,(default-value 'show-trailing-whitespace)) (php-style-delete-trailing-whitespace . nil))) @@ -736,8 +712,7 @@ but only if the setting is enabled" '("php" (c-offsets-alist . ((statement-cont . php-lineup-hanging-semicolon))) (c-indent-comments-syntactically-p . t) - (fill-column . 78) - (require-final-newline . t))) + (fill-column . 78))) (defun php-enable-symfony2-coding-style () "Make php-mode use coding styles that are preferable for working with Symfony2." @@ -750,7 +725,6 @@ but only if the setting is enabled" (c-offsets-alist . ((statement-cont . +))) (c-indent-comments-syntactically-p . t) (fill-column . 78) - (require-final-newline . t) (show-trailing-whitespace . t) (php-style-delete-trailing-whitespace . t))) @@ -1148,15 +1122,24 @@ After setting the stylevars run hooks according to STYLENAME (put 'php-set-style 'interactive-form (interactive-form 'c-set-style)) +(defun php-mode-set-style-delay () + "Set the current `php-mode' buffer to use the style by custom or local variables." + (let ((coding-style (or (and (boundp 'php-project-coding-style) php-project-coding-style) + php-mode-coding-style))) + (prog1 (php-set-style (symbol-name coding-style)) + (remove-hook 'hack-local-variables-hook #'php-mode-set-style-delay)))) + (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-remove-if - (lambda (s) (string-match-p "global" (symbol-name s))) - minor-mode-list)) + (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)))) @@ -1203,13 +1186,12 @@ After setting the stylevars run hooks according to STYLENAME ;; PHP vars are case-sensitive (setq case-fold-search t) - ;; Do not force newline at end of file. Such newlines can cause - ;; trouble if the PHP file is included in another file before calls - ;; to header() or cookie(). - (set (make-local-variable 'require-final-newline) nil) - (set (make-local-variable 'next-line-add-newlines) nil) - - (php-set-style (symbol-name php-mode-coding-style)) + ;; When php-mode-enable-project-coding-style is set, it is delayed by hook. + ;; Since it depends on the timing at which the file local variable is set. + ;; File local variables are set after initialization of major mode except `run-hook' is complete. + (if php-mode-enable-project-coding-style + (add-hook 'hack-local-variables-hook #'php-mode-set-style-delay t t) + (php-set-style (symbol-name php-mode-coding-style))) (when (or php-mode-force-pear (and (stringp buffer-file-name) @@ -1599,12 +1581,6 @@ a completion list." ;; already fontified by another pattern. Note that using OVERRIDE ;; is usually overkill. `( - ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but - ;; not in $obj->var() - ("->\\(\\sw+\\)\\s-*(" 1 'php-method-call) - - ("\\(\\$\\|->\\)\\([a-zA-Z0-9_]+\\)" 2 'php-property-name) - ;; Highlight all upper-cased symbols as constant ("\\<\\([A-Z_][A-Z0-9_]+\\)\\>" 1 'php-constant) @@ -1752,18 +1728,6 @@ The output will appear in the buffer *PHP*." (when (re-search-backward re-pattern nil t) (match-string-no-properties 1)))) -;;;###autoload -(defun php-project-get-root-dir () - "Return path to current PHP project." - (let ((detect-method (if (stringp php-project-root) - (list php-project-root) - (if (eq php-project-root 'auto) - (cl-loop for m in php-available-project-root-files - append (cdr m)) - (cdr-safe (assq php-project-root php-available-project-root-files)))))) - (cl-loop for m in detect-method - thereis (locate-dominating-file default-directory m)))) - ;;;###autoload (defun php-current-class () "Insert current class name if cursor in class context." -- cgit v1.3