mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-04 19:29:37 +00:00
PHP should be in the PATH, either locally or remotely. (bug#76242).
* lisp/progmodes/php-ts-mode.el (php-ts-mode-php-default-executable): Renamed from 'php-ts-mode-php-executable'. (php-ts-mode--executable): New function that returns the absolute filename of the PHP executable, local or remote, based on 'default-directory'. (php-ts-mode--anchor-prev-sibling): Replaced 'when-let' with “when-let*.” (php-ts-mode--indent-defun): Replaced 'when-let' with 'when-let*'. (php-ts-mode-run-php-webserver): Use the new function (php-ts-mode-php-default-executable). (run-php): Use the new function (php-ts-mode-php-default-executable).
This commit is contained in:
parent
26873d5028
commit
99ff59bd66
1 changed files with 31 additions and 16 deletions
|
@ -134,12 +134,16 @@ Works like `css--fontify-region'."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:safe 'booleanp)
|
:safe 'booleanp)
|
||||||
|
|
||||||
(defcustom php-ts-mode-php-executable (or (executable-find "php") "/usr/bin/php")
|
(defcustom php-ts-mode-php-default-executable (or (executable-find "php") "/usr/bin/php")
|
||||||
"The location of PHP executable."
|
"The default PHP executable."
|
||||||
:tag "PHP Executable"
|
:tag "PHP Executable"
|
||||||
:version "30.1"
|
:version "30.1"
|
||||||
:type 'file)
|
:type 'file)
|
||||||
|
|
||||||
|
(defvar-local php-ts-mode-alternative-php-program-name nil
|
||||||
|
"An alternative to the usual `php' program name.
|
||||||
|
In non-nil, `php-ts-mode--executable' try to find this executable.")
|
||||||
|
|
||||||
(defcustom php-ts-mode-php-config nil
|
(defcustom php-ts-mode-php-config nil
|
||||||
"The location of php.ini file.
|
"The location of php.ini file.
|
||||||
If nil the default one is used to run the embedded webserver or
|
If nil the default one is used to run the embedded webserver or
|
||||||
|
@ -270,7 +274,7 @@ Calls REPORT-FN directly."
|
||||||
:noquery t
|
:noquery t
|
||||||
:connection-type 'pipe
|
:connection-type 'pipe
|
||||||
:buffer (generate-new-buffer " *php-ts-mode-flymake*")
|
:buffer (generate-new-buffer " *php-ts-mode-flymake*")
|
||||||
:command `(,php-ts-mode-php-executable
|
:command `(,(php-ts-mode--executable)
|
||||||
"-l" "-d" "display_errors=0")
|
"-l" "-d" "display_errors=0")
|
||||||
:sentinel
|
:sentinel
|
||||||
(lambda (proc _event)
|
(lambda (proc _event)
|
||||||
|
@ -306,6 +310,16 @@ Calls REPORT-FN directly."
|
||||||
|
|
||||||
;;; Utils
|
;;; Utils
|
||||||
|
|
||||||
|
(defun php-ts-mode--executable ()
|
||||||
|
"Return the absolute filename of the php executable.
|
||||||
|
If the `default-directory' is remote, search on a remote host, otherwise
|
||||||
|
it searches locally. If `php-ts-mode-alternative-php-program-name' is
|
||||||
|
non-zero, it searches for this program instead of the usual `php'.
|
||||||
|
If the search fails, it returns `php-ts-mode-php-default-executable'."
|
||||||
|
(or (executable-find
|
||||||
|
(or php-ts-mode-alternative-php-program-name "php") t)
|
||||||
|
php-ts-mode-php-default-executable))
|
||||||
|
|
||||||
(defun php-ts-mode--get-indent-style ()
|
(defun php-ts-mode--get-indent-style ()
|
||||||
"Helper function to set indentation style.
|
"Helper function to set indentation style.
|
||||||
MODE can be `psr2', `pear', `drupal', `wordpress', `symfony', `zend'."
|
MODE can be `psr2', `pear', `drupal', `wordpress', `symfony', `zend'."
|
||||||
|
@ -595,7 +609,7 @@ doesn't have a child.
|
||||||
|
|
||||||
PARENT is NODE's parent, BOL is the beginning of non-whitespace
|
PARENT is NODE's parent, BOL is the beginning of non-whitespace
|
||||||
characters of the current line."
|
characters of the current line."
|
||||||
(when-let ((prev-sibling
|
(when-let* ((prev-sibling
|
||||||
(or (treesit-node-prev-sibling node t)
|
(or (treesit-node-prev-sibling node t)
|
||||||
(treesit-node-prev-sibling
|
(treesit-node-prev-sibling
|
||||||
(treesit-node-first-child-for-pos parent bol) t)
|
(treesit-node-first-child-for-pos parent bol) t)
|
||||||
|
@ -1236,7 +1250,7 @@ Return nil if the NODE has no field “name” or if NODE is not a defun node."
|
||||||
"Indent the current top-level declaration syntactically.
|
"Indent the current top-level declaration syntactically.
|
||||||
`treesit-defun-type-regexp' defines what constructs to indent."
|
`treesit-defun-type-regexp' defines what constructs to indent."
|
||||||
(interactive "*")
|
(interactive "*")
|
||||||
(when-let ((orig-point (point-marker))
|
(when-let* ((orig-point (point-marker))
|
||||||
(node (treesit-defun-at-point)))
|
(node (treesit-defun-at-point)))
|
||||||
(indent-region (treesit-node-start node)
|
(indent-region (treesit-node-start node)
|
||||||
(treesit-node-end node))
|
(treesit-node-end node))
|
||||||
|
@ -1613,7 +1627,7 @@ for PORT, HOSTNAME, DOCUMENT-ROOT and ROUTER-SCRIPT."
|
||||||
(message "Run PHP built-in web server with args %s into buffer %s"
|
(message "Run PHP built-in web server with args %s into buffer %s"
|
||||||
(string-join args " ")
|
(string-join args " ")
|
||||||
buf-name)
|
buf-name)
|
||||||
(apply #'make-comint name php-ts-mode-php-executable nil args))
|
(apply #'make-comint name (php-ts-mode--executable) nil args))
|
||||||
(funcall
|
(funcall
|
||||||
(if (called-interactively-p 'interactive) #'display-buffer #'get-buffer)
|
(if (called-interactively-p 'interactive) #'display-buffer #'get-buffer)
|
||||||
buf-name)))
|
buf-name)))
|
||||||
|
@ -1677,14 +1691,15 @@ Prompt for CMD if `php-ts-mode-php-executable' is nil.
|
||||||
Optional CONFIG, if supplied, is the php.ini file to use."
|
Optional CONFIG, if supplied, is the php.ini file to use."
|
||||||
(interactive (when current-prefix-arg
|
(interactive (when current-prefix-arg
|
||||||
(list
|
(list
|
||||||
(read-string "Run PHP: " php-ts-mode-php-executable)
|
(read-string "Run PHP: " (php-ts-mode--executable))
|
||||||
(expand-file-name
|
(expand-file-name
|
||||||
(read-file-name "With config: " php-ts-mode-php-config)))))
|
(read-file-name "With config: " php-ts-mode-php-config)))))
|
||||||
(let ((buffer (get-buffer-create php-ts-mode-inferior-php-buffer))
|
(let* ((php-prog (php-ts-mode--executable))
|
||||||
|
(buffer (get-buffer-create php-ts-mode-inferior-php-buffer))
|
||||||
(cmd (or
|
(cmd (or
|
||||||
cmd
|
cmd
|
||||||
php-ts-mode-php-executable
|
php-prog
|
||||||
(read-string "Run PHP: " php-ts-mode-php-executable)))
|
(read-string "Run PHP: " php-prog)))
|
||||||
(config (or
|
(config (or
|
||||||
config
|
config
|
||||||
(and php-ts-mode-php-config
|
(and php-ts-mode-php-config
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue