From f12ad4ea469aa95a4f8a5c42a1899b375fa405b6 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Fri, 9 Mar 2018 08:28:35 +0100 Subject: Update php-project.el and yasnippet.el --- .emacs.d/lisp/php-project.el | 48 ++++++++++++++++++++++++++++++++++++++++++++ .emacs.d/lisp/yasnippet.el | 3 +++ 2 files changed, 51 insertions(+) diff --git a/.emacs.d/lisp/php-project.el b/.emacs.d/lisp/php-project.el index cb04341..c36c81f 100644 --- a/.emacs.d/lisp/php-project.el +++ b/.emacs.d/lisp/php-project.el @@ -37,6 +37,16 @@ ;; ;; Return list of path to bootstrap script file. ;; +;; ### `php-project-get-php-executable()' +;; +;; Return path to PHP executable file with the project settings overriding. +;; +;; ### `php-project-get-phan-executable()' +;; +;; Return path to Phan executable file with the project settings overriding. +;; Phan is a static analyzer and LSP server implementation for PHP. +;; See https://github.com/phan/phan +;; ;; ## `.dir-locals.el' support ;; ;; - `php-project-coding-style' @@ -47,6 +57,13 @@ ;; - `php-project-bootstrap-scripts' ;; - List of path to bootstrap file of project. ;; (ex. (((root . "vendor/autoload.php") (root . "inc/bootstrap.php"))) +;; - `php-project-php-executable' +;; - Path to project specific PHP executable file. +;; - If you want to use a file different from the system wide `php' command. +;; - `php-project-phan-executable' +;; - Path to project specific Phan executable file. +;; - When not specified explicitly, it is automatically searched from +;; Composer's dependency of the project and `exec-path'. ;; ;;; Code: @@ -93,6 +110,21 @@ defines constants, and sets the class loaders.") (make-variable-buffer-local 'php-project-bootstrap-scripts) (put 'php-project-bootstrap-scripts 'safe-local-variable #'php-project--eval-bootstrap-scripts)) +;;;###autoload +(progn + (defvar php-project-php-executable nil + "Path to php executable file.") + (make-variable-buffer-local 'php-project-php-executable) + (put 'php-project-php-executable 'safe-local-variable + #'(lambda (v) (and (stringp v) (file-executable-p v))))) + +;;;###autoload +(progn + (defvar php-project-phan-executable nil + "Path to phan executable file.") + (make-variable-buffer-local 'php-project-phan-executable) + (put 'php-project-phan-executable 'safe-local-variable #'php-project--eval-bootstrap-scripts)) + ;;;###autoload (progn (defvar php-project-coding-style nil @@ -120,6 +152,22 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.") (cl-loop for v in val collect (php-project--eval-bootstrap-scripts v))) (t nil))) +(defun php-project-get-php-executable () + "Return path to PHP executable file." + (cond + ((and (stringp php-project-php-executable) + (file-executable-p php-project-php-executable)) + php-project-php-executable) + ((boundp 'php-executable) php-executable) + (t (executable-find "php")))) + +(defun php-project-get-phan-executable () + "Return path to phan executable file." + (or (car-safe (php-project--eval-bootstrap-scripts + (list php-project-phan-executable + (cons 'root "vendor/bin/phan")))) + (executable-find "phan"))) + ;;;###autoload (defun php-project-get-bootstrap-scripts () "Return list of bootstrap script." diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el index 1f92adc..5f17465 100644 --- a/.emacs.d/lisp/yasnippet.el +++ b/.emacs.d/lisp/yasnippet.el @@ -4306,6 +4306,9 @@ The SNIPPET's markers are preserved." (forward-line 1) (let ((indent-line-function (lambda () + ;; We need to be at beginning of line in order to + ;; indent existing whitespace correctly. + (beginning-of-line) (indent-to-column yas--indent-original-column)))) (yas--indent-region (line-beginning-position) (point-max) -- cgit v1.3