Compare commits

..

No commits in common. "d40eb4bc3678eb9a9ed74501418c52a016caff6b" and "b1d8a638622b16f51061b009b4856e2a72bb979f" have entirely different histories.

15 changed files with 5 additions and 3218 deletions

View File

@ -1,126 +0,0 @@
;;; php-align.el --- Alignment configuration for PHP -*- lexical-binding: t; -*-
;; Copyright (C) 2011 tetsujin (Yusuke Segawa)
;; Copyright (C) 2020 Friends of Emacs-PHP development
;; Author: tetsujin (Yusuke Segawa) <tetsujin85 (at) gmail.com>
;; Maintainer: USAMI Kenta <tadsan@zonu.me>
;; Keywords: php languages convenience align
;; Homepage: https://github.com/emacs-php/php-mode
;; Version: 1.23.0
;; License: GPL-3.0-or-later
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This extension provides alignment for PHP.
;; Note that you must have Font Lock mode enabled.
;;
;; Put this file into your load-path.and the following code into your ~/.emacs
;;
;; (add-hook 'php-mode-hook #'php-align-setup)
;;; TODO:
;; - Add test codes using el-expectations.
;;; Code:
(require 'align)
(require 'regexp-opt)
(require 'php-project)
(defvar php-align-rules-list
`((php-comma-delimiter
(regexp . ",\\(\\s-*\\)[^/ \t\n]")
(repeat . t)
(modes . '(php-mode))
(run-if . ,(function (lambda () current-prefix-arg))))
(php-assignment
(regexp . ,(concat "[^=!^&*-+<>/.| \t\n]\\(\\s-*[=!^&%*-+<>/.|]*\\)=>?"
"\\(\\s-*\\)\\([^= \t\n]\\|$\\)"))
(group . (1 2))
(modes . '(php-mode))
(justify . t)
(tab-stop . nil))
(php-comment
(regexp . "\\(\\s-*\\)\\(//.*\\|/\\*.*\\*/\\s-*\\)$")
(modes . (php-mode))
(column . comment-column)
(valid . ,(function
(lambda ()
(save-excursion
(goto-char (match-beginning 1))
(not (bolp)))))))
(php-chain-logic
(regexp . "\\(\\s-*\\)\\(&&\\|||\\|\\<and\\>\\|\\<or\\>\\)")
(modes . (php-mode))
(valid . ,(function
(lambda ()
(save-excursion
(goto-char (match-end 2))
(looking-at "\\s-*\\(/[*/]\\|$\\)"))))))))
(defvar php-align-region-separate
(eval-when-compile
(concat
;; blank line
"\\(?:" "^\\s-*$" "\\)"
"\\|"
;; comment start or end line
"\\(?:" "^\\s-*\\(?:/[/*]\\|\\*/\\)" "\\)"
"\\|"
;; end of line are '[', '(', '{', '}', '/*'
"\\(?:" "\\(?:[[({}]\\|/\\*+\\)\\s-*$" "\\)"
"\\|"
;; beginning of line are ')', '}', ']' and trailing character are ',', ';'
"\\(?:" "^\\s-*[)}]][ \t,;]?\\s-*$" "\\)"
"\\|"
;; beginning of line are some PHP keywrods
"\\(?:"
"^\\s-*"
(regexp-opt
'("for" "foreach" "while" "if" "else" "switch" "case" "break" "continue"
"try" "catch" "declare" "do" "return" "namespace" "use"))
"[ ;]"
"\\)"
"\\|"
;; function or method call
"\\(?:" "^\\s-*" "\\(?:" "\\w\\|[->\\: \t]" "\\)+" "(" "\\)"))
"Regexp of a section of PHP for alignment.")
;;;###autoload
(defun php-align-setup ()
"Setup alignment configuration for PHP code."
(when php-project-align-lines
(php-align-mode 1)))
(defvar php-align-mode-lighter " PHP-Align")
;;;###autoload
(define-minor-mode php-align-mode
"Alignment lines for PHP script."
:lighter php-align-mode-lighter
(add-to-list 'align-open-comment-modes 'php-mode)
(add-to-list 'align-dq-string-modes 'php-mode)
(add-to-list 'align-sq-string-modes 'php-mode)
(if php-align-mode
(progn
(setq-local align-mode-rules-list php-align-rules-list)
(setq-local align-region-separate php-align-region-separate))
(setq-local align-mode-rules-list nil)
(setq-local align-region-separate nil)))
(provide 'php-align)
;;; php-align.el ends here

View File

@ -1,246 +0,0 @@
;;; php-face.el --- Face definitions for PHP script -*- lexical-binding: t; -*-
;; Copyright (C) 2020 Friends of Emacs-PHP development
;; Author: USAMI Kenta <tadsan@zonu.me>
;; Created: 5 May 2019
;; Version: 1.23.0
;; Keywords: faces, php
;; Homepage: https://github.com/emacs-php/php-mode
;; License: GPL-3.0-or-later
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Face definitions for PHP script.
;;; Code:
;;;###autoload
(defgroup php-faces nil
"Faces used in PHP Mode"
:tag "PHP Faces"
:group 'php-mode
:group 'faces)
(defface php-string '((t (:inherit font-lock-string-face)))
"PHP Mode face used to highlight string literals."
:group 'php-faces
:tag "PHP String")
(defface php-keyword '((t (:inherit font-lock-keyword-face)))
"PHP Mode face used to highlight keywords."
:group 'php-faces
:tag "PHP Keyword")
(defface php-builtin '((t (:inherit font-lock-builtin-face)))
"PHP Mode face used to highlight builtins."
:group 'php-faces
:tag "PHP Built-in")
(defface php-function-name '((t (:inherit font-lock-function-name-face)))
"PHP Mode face used to highlight function names."
:group 'php-faces
:tag "PHP Function Name")
(defface php-function-call '((t ()))
"PHP Mode face used to highlight function names in calles."
:group 'php-faces
:tag "PHP Function Call")
(defface php-method-call '((t (:inherit php-function-call)))
"PHP Mode face used to highlight method names in calles."
:group 'php-faces
:tag "PHP Method Call")
(defface php-static-method-call '((t (:inherit php-method-call)))
"PHP Mode face used to highlight static method names in calles."
:group 'php-faces
:tag "PHP Static Method Call")
(defface php-variable-name '((t (:inherit font-lock-variable-name-face)))
"PHP Mode face used to highlight variable names."
:group 'php-faces
:tag "PHP Variable Name")
(defface php-property-name '((t (:inherit php-variable-name)))
"PHP Mode face used to highlight property names."
:group 'php-faces
:tag "PHP Property Name")
(defface php-variable-sigil '((t ()))
"PHP Mode face used to highlight variable sigils ($)."
:group 'php-faces
:tag "PHP Variable Sigil")
(defface php-operator '((t ()))
"PHP Mode face used to operators."
:group 'php-faces
:tag "PHP Operator")
(defface php-assignment-op '((t (:inherit php-operator)))
"PHP Mode face used to assignment operators (=, +=, ...)."
:group 'php-faces
:tag "PHP Object Op")
(defface php-comparison-op '((t (:inherit php-operator)))
"PHP Mode face used to comparison operators (==, !=, ===, ...)."
:group 'php-faces
:tag "PHP Comparison Op")
(defface php-logical-op '((t (:inherit php-operator)))
"PHP Mode face used to logical operators (&&, ||, ?:)."
:group 'php-faces
:tag "PHP Logical Op")
(defface php-arithmetic-op '((t (:inherit php-operator)))
"PHP Mode face used to arithmetic operators (+, -, %, ...)."
:group 'php-faces
:tag "PHP Arithmetic Op")
(defface php-inc-dec-op '((t (:inherit php-operator)))
"PHP Mode face used to increment and decremt operators (--, ++)."
:group 'php-faces
:tag "PHP Increment/Decrement Op")
(defface php-string-op '((t (:inherit php-operator)))
"PHP Mode face used to logical operators (.)."
:group 'php-faces
:tag "PHP String Op")
(defface php-object-op '((t (:inherit php-operator)))
"PHP Mode face used to object operators (->)."
:group 'php-faces
:tag "PHP Object Op")
(defface php-paamayim-nekudotayim '((t ()))
"PHP Mode face used to highlight \"Paamayim Nekudotayim\" scope resolution operators (::)."
:group 'php-faces
:tag "PHP Paamayim Nekudotayim")
(defface php-type '((t (:inherit font-lock-type-face)))
"PHP Mode face used to highlight types."
:group 'php-faces
:tag "PHP Type")
(defface php-class '((t (:inherit font-lock-type-face)))
"PHP Mode face used to highlight class."
:group 'php-faces
:tag "PHP Class")
(defface php-constant '((t (:inherit font-lock-constant-face)))
"PHP Mode face used to highlight constants."
:group 'php-faces
:tag "PHP Constant")
(defface php-constant-assign '((t (:inherit font-lock-type-face)))
"PHP Mode face used to highlight constant assigning (\"const\" statement)."
:group 'php-faces
:tag "PHP Constant Assign")
(defface php-magical-constant '((t (:inherit font-lock-builtin-face)))
"PHP Mode face used to highlight magical constants."
:group 'php-faces
:tag "PHP Magical Constant")
(defface php-$this '((t (:inherit php-constant)))
"PHP Mode face used to highlight $this variables."
:group 'php-faces
:tag "PHP $this")
(defface php-$this-sigil '((t (:inherit php-constant)))
"PHP Mode face used to highlight sigils($) of $this variable."
:group 'php-faces
:tag "PHP $this Sigil")
(defface php-errorcontrol-op '((t (:inherit font-lock-type-face)))
"PHP Mode face used to highlight errorcontrol operators (@).."
:group 'php-faces
:tag "PHP ErrorControl Op")
(defface php-php-tag '((t (:inherit font-lock-preprocessor-face)))
"PHP Mode face used to highlight PHP tags."
:group 'php-faces
:tag "PHP php Tag")
(defface php-doc-annotation-tag '((t . (:inherit font-lock-constant-face)))
"Face used to highlight annotation tags in doc-comment."
:group 'php-faces
:tag "PHPDoc Annotation Tag")
(defface php-doc-variable-sigil '((t (:inherit font-lock-variable-name-face)))
"PHP Mode face used to highlight variable sigils($)."
:group 'php-faces
:tag "PHPDoc Variable Sigil")
(defface php-doc-$this '((t (:inherit php-type)))
"PHP Mode face used to highlight $this variable in doc-comment."
:group 'php-faces
:tag "PHPDoc $this")
(defface php-doc-$this-sigil '((t (:inherit php-type)))
"PHP Mode face used to highlight sigil of $this variable in doc-comment."
:group 'php-faces
:tag "PHPDoc $this Sigil")
(defface php-doc-class-name '((t (:inherit php-string)))
"PHP Mode Face used to class names in doc-comment."
:group 'php-faces
:tag "PHPDoc Class Name")
(defface php-class-declaration '((t (:inherit php-keyword)))
"PHP Mode Face used to class declarations."
:group 'php-faces
:tag "PHP Class Declaration")
(defface php-class-declaration-spec '((t (:inherit php-keyword)))
"PHP Mode Face used to highlight class declaration specification keywords (implements, extends)"
:group 'php-faces
:tag "PHP Class Declaration Specification")
(defface php-namespace-declaration '((t (:inherit php-keyword)))
"PHP Mode Face used to highlight namespace declaration keyword."
:group 'php-faces
:tag "PHP Namespace Declaration")
(defface php-import-declaration '((t (:inherit php-keyword)))
"PHP Mode Face used to highlight import statements (use ... as ...)."
:group 'php-faces
:tag "PHP Import Statement")
(defface php-class-modifier '((t (:inherit php-keyword)))
"PHP Mode Face used to highlight class modifiers (final, abstract)."
:group 'php-faces
:tag "PHP Class Modifier")
(defface php-method-modifier '((t (:inherit php-keyword)))
"PHP Mode Face used to highlight method modifiers (final, abstract)."
:group 'php-faces
:tag "PHP Method Modifier")
(defface php-visibility-modifier '((t (:inherit php-keyword)))
"PHP Mode Face used to highlight access keywords (public, protected, private)."
:group 'php-faces
:tag "PHP Visibility Modifier")
(defface php-control-structure '((t (:inherit php-keyword)))
"PHP Mode Face used to highlight control structures (if, foreach, while, switch, catch...)."
:group 'php-faces
:tag "PHP Control Structure")
(define-obsolete-face-alias 'php-annotations-annotation-face 'php-doc-annotation-tag "1.19.0")
(provide 'php-face)
;;; php-face.el ends here

View File

@ -1,235 +0,0 @@
;;; php-mode-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "php" "php.el" (0 0 0 0))
;;; Generated autoloads from php.el
(let ((loads (get 'php 'custom-loads))) (if (member '"php" loads) nil (put 'php 'custom-loads (cons '"php" loads))))
(autoload 'php-mode-maybe "php" "\
Select PHP mode or other major mode.
\(fn)" t nil)
(autoload 'php-current-class "php" "\
Insert current class name if cursor in class context.
\(fn)" t nil)
(autoload 'php-current-namespace "php" "\
Insert current namespace if cursor in namespace context.
\(fn)" t nil)
(autoload 'php-copyit-fqsen "php" "\
Copy/kill class/method FQSEN.
\(fn)" t nil)
(autoload 'php-run-builtin-web-server "php" "\
Run PHP Built-in web server.
`ROUTER-OR-DIR': Path to router PHP script or Document root.
`HOSTNAME': Hostname or IP address of Built-in web server.
`PORT': Port number of Built-in web server.
`DOCUMENT-ROOT': Path to Document root.
When `DOCUMENT-ROOT' is NIL, the document root is obtained from `ROUTER-OR-DIR'.
\(fn ROUTER-OR-DIR HOSTNAME PORT &optional DOCUMENT-ROOT)" t nil)
(autoload 'php-find-system-php-ini-file "php" "\
Find php.ini FILE by `php --ini'.
\(fn &optional FILE)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "php" '("php-")))
;;;***
;;;### (autoloads nil "php-align" "php-align.el" (0 0 0 0))
;;; Generated autoloads from php-align.el
(autoload 'php-align-setup "php-align" "\
Setup alignment configuration for PHP code.
\(fn)" nil nil)
(autoload 'php-align-mode "php-align" "\
Alignment lines for PHP script.
\(fn &optional ARG)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "php-align" '("php-align-")))
;;;***
;;;### (autoloads nil "php-face" "php-face.el" (0 0 0 0))
;;; Generated autoloads from php-face.el
(let ((loads (get 'php-faces 'custom-loads))) (if (member '"php-face" loads) nil (put 'php-faces 'custom-loads (cons '"php-face" loads))))
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "php-face" '("php-annotations-annotation-face")))
;;;***
;;;### (autoloads nil "php-mode" "php-mode.el" (0 0 0 0))
;;; Generated autoloads from php-mode.el
(let ((loads (get 'php-mode 'custom-loads))) (if (member '"php-mode" loads) nil (put 'php-mode 'custom-loads (cons '"php-mode" loads))))
(if (version< emacs-version "24.4") (dolist (i '("php" "php5" "php7")) (add-to-list 'interpreter-mode-alist (cons i 'php-mode))) (add-to-list 'interpreter-mode-alist (cons "php\\(?:-?[3457]\\(?:\\.[0-9]+\\)*\\)?" 'php-mode)))
(define-obsolete-variable-alias 'php-available-project-root-files 'php-project-available-root-files "1.19.0")
(autoload 'php-mode "php-mode" "\
Major mode for editing PHP code.
\\{php-mode-map}
\(fn)" t nil)
(add-to-list 'auto-mode-alist '("/\\.php_cs\\(?:\\.dist\\)?\\'" . php-mode))
(add-to-list 'auto-mode-alist '("\\.\\(?:php\\.inc\\|stub\\)\\'" . php-mode))
(add-to-list 'auto-mode-alist '("\\.\\(?:php[s345]?\\|phtml\\)\\'" . php-mode-maybe))
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "php-mode" '("php-")))
;;;***
;;;### (autoloads nil "php-mode-debug" "php-mode-debug.el" (0 0 0
;;;;;; 0))
;;; Generated autoloads from php-mode-debug.el
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "php-mode-debug" '("php-mode-debug")))
;;;***
;;;### (autoloads nil "php-project" "php-project.el" (0 0 0 0))
;;; Generated autoloads from php-project.el
(defvar-local php-project-root 'auto "\
Method of searching for the top level directory.
`auto' (default)
Try to search file in order of `php-project-available-root-files'.
SYMBOL
Key of `php-project-available-root-files'.
STRING
A file/directory name of top level marker.
If the string is an actual directory path, it is set as the absolute path
of the root directory, not the marker.")
(put 'php-project-root 'safe-local-variable #'(lambda (v) (or (stringp v) (assq v php-project-available-root-files))))
(defvar-local php-project-etags-file nil)
(put 'php-project-etags-file 'safe-local-variable #'(lambda (v) (or (functionp v) (eq v t) (php-project--eval-bootstrap-scripts v))))
(defvar-local php-project-bootstrap-scripts nil "\
List of path to bootstrap php script file.
The ideal bootstrap file is silent, it only includes dependent files,
defines constants, and sets the class loaders.")
(put 'php-project-bootstrap-scripts 'safe-local-variable #'php-project--eval-bootstrap-scripts)
(defvar-local php-project-php-executable nil "\
Path to php executable file.")
(put 'php-project-php-executable 'safe-local-variable #'(lambda (v) (and (stringp v) (file-executable-p v))))
(defvar-local php-project-phan-executable nil "\
Path to phan executable file.")
(put 'php-project-phan-executable 'safe-local-variable #'php-project--eval-bootstrap-scripts)
(defvar-local php-project-coding-style nil "\
Symbol value of the coding style of the project that PHP major mode refers to.
Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
(put 'php-project-coding-style 'safe-local-variable #'symbolp)
(defvar-local php-project-align-lines t "\
If T, automatically turn on `php-align-mode' by `php-align-setup'.")
(put 'php-project-align-lines 'safe-local-variable #'booleanp)
(defvar-local php-project-php-file-as-template 'auto "\
`auto' (default)
Automatically switch to mode for template when HTML tag detected in file.
`t'
Switch all PHP files in that directory to mode for HTML template.
`nil'
Any .php in that directory is just a PHP script.
\((PATTERN . SYMBOL))
Alist of file name pattern regular expressions and the above symbol pairs.
PATTERN is regexp pattern.
")
(put 'php-project-php-file-as-template 'safe-local-variable #'php-project--validate-php-file-as-template)
(defvar-local php-project-repl nil "\
Function name or path to REPL (interactive shell) script.")
(put 'php-project-repl 'safe-local-variable #'(lambda (v) (or (functionp v) (php-project--eval-bootstrap-scripts v))))
(defvar-local php-project-unit-test nil "\
Function name or path to unit test script.")
(put 'php-project-unit-test 'safe-local-variable #'(lambda (v) (or (functionp v) (php-project--eval-bootstrap-scripts v))))
(defvar-local php-project-deploy nil "\
Function name or path to deploy script.")
(put 'php-project-deploy 'safe-local-variable #'(lambda (v) (or (functionp v) (php-project--eval-bootstrap-scripts v))))
(defvar-local php-project-build nil "\
Function name or path to build script.")
(put 'php-project-build 'safe-local-variable #'(lambda (v) (or (functionp v) (php-project--eval-bootstrap-scripts v))))
(defvar-local php-project-server-start nil "\
Function name or path to server-start script.")
(put 'php-project-server-start 'safe-local-variable #'(lambda (v) (or (functionp v) (php-project--eval-bootstrap-scripts v))))
(autoload 'php-project-get-bootstrap-scripts "php-project" "\
Return list of bootstrap script.
\(fn)" nil nil)
(autoload 'php-project-get-root-dir "php-project" "\
Return path to current PHP project.
\(fn)" nil nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "php-project" '("php-project-")))
;;;***
;;;### (autoloads nil nil ("php-mode-pkg.el") (0 0 0 0))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; php-mode-autoloads.el ends here

View File

@ -1,101 +0,0 @@
;;; php-mode-debug.el --- Debug functions for PHP Mode -*- lexical-binding: t; -*-
;; Copyright (C) 2020 Friends of Emacs-PHP development
;; Author: USAMI Kenta <tadsan@zonu.me>
;; URL: https://github.com/emacs-php/php-mode
;; Keywords: maint
;; Version: 1.23.0
;; License: GPL-3.0-or-later
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Provides functions to debugging php-mode work.
;;; Code:
(require 'cc-mode)
(require 'cus-edit)
(require 'php-mode)
(require 'package)
(require 'pkg-info nil t)
(declare-function pkg-info-version-info "pkg-info" (library &optional package show))
(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)
(unless (eq major-mode 'php-mode)
(user-error "Invoke this command only in php-mode buffer"))
(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/emacs-php/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; Cc Mode %s)" (emacs-version) (php-mode-version) c-version)
(php-mode-debug--message "package-version: %s"
(if (fboundp 'pkg-info)
(pkg-info-version-info 'php-mode)
(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 "buffer: %s" (list :length (save-excursion (goto-char (point-max)) (point))))
(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)))
(provide 'php-mode-debug)
;;; php-mode-debug.el ends here

View File

@ -1,12 +0,0 @@
(define-package "php-mode" "20200730.1950" "Major mode for editing PHP code"
'((emacs "24.3"))
:commit "4345dfd81fc6da9b7ac123377902b42f5b7b3e0d" :keywords
'("languages" "php")
:authors
'(("Eric James Michael Ritz"))
:maintainer
'("USAMI Kenta" . "tadsan@zonu.me")
:url "https://github.com/emacs-php/php-mode")
;; Local Variables:
;; no-byte-compile: t
;; End:

File diff suppressed because it is too large Load Diff

View File

@ -1,301 +0,0 @@
;;; php-project.el --- Project support for PHP application -*- lexical-binding: t; -*-
;; Copyright (C) 2020 Friends of Emacs-PHP development
;; Author: USAMI Kenta <tadsan@zonu.me>
;; Keywords: tools, files
;; URL: https://github.com/emacs-php/php-mode
;; Version: 1.23.0
;; License: GPL-3.0-or-later
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Define project specific functions and variables for PHP application.
;;
;; ## API
;;
;; ### `php-project-get-root-dir()'
;;
;; Return root directory of current buffer file. The root directory is
;; determined by several marker file or directory.
;;
;; ### `php-project-get-bootstrap-scripts()'
;;
;; 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'
;; - Symbol value of the coding style. (ex. `pear', `psr2')
;; - `php-project-root'
;; - Symbol of marker file of project root. (ex. `git', `composer')
;; - Full path to project root directory. (ex. "/path/to/your-project")
;; - `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:
(require 'cl-lib)
(require 'projectile nil t)
;; Constants
(defconst php-project-composer-autoloader "vendor/autoload.php")
;; Custom variables
(defgroup php-project nil
"Major mode for editing PHP code."
:tag "PHP Project"
:prefix "php-project-"
:group 'php)
(defcustom php-project-auto-detect-etags-file nil
"If `T', automatically detect etags file when file is opened."
:tag "PHP Project Auto Detect Etags File"
:group 'php-project
:type 'boolean)
(defcustom php-project-use-projectile-to-detect-root nil
"If `T' and projectile-mode is activated, use Projectile for root detection."
:tag "PHP Project Use Projectile To Detect Root"
:group 'php-project
:type 'boolean)
;; Variables
(defvar php-project-available-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")
))
;; Buffer local variables
;;;###autoload
(progn
(defvar-local php-project-root 'auto
"Method of searching for the top level directory.
`auto' (default)
Try to search file in order of `php-project-available-root-files'.
SYMBOL
Key of `php-project-available-root-files'.
STRING
A file/directory name of top level marker.
If the string is an actual directory path, it is set as the absolute path
of the root directory, not the marker.")
(put 'php-project-root 'safe-local-variable
#'(lambda (v) (or (stringp v) (assq v php-project-available-root-files))))
(defvar-local php-project-etags-file nil)
(put 'php-project-etags-file 'safe-local-variable
#'(lambda (v) (or (functionp v)
(eq v t)
(php-project--eval-bootstrap-scripts v))))
(defvar-local php-project-bootstrap-scripts nil
"List of path to bootstrap php script file.
The ideal bootstrap file is silent, it only includes dependent files,
defines constants, and sets the class loaders.")
(put 'php-project-bootstrap-scripts 'safe-local-variable #'php-project--eval-bootstrap-scripts)
(defvar-local php-project-php-executable nil
"Path to php executable file.")
(put 'php-project-php-executable 'safe-local-variable
#'(lambda (v) (and (stringp v) (file-executable-p v))))
(defvar-local php-project-phan-executable nil
"Path to phan executable file.")
(put 'php-project-phan-executable 'safe-local-variable #'php-project--eval-bootstrap-scripts)
(defvar-local php-project-coding-style nil
"Symbol value of the coding style of the project that PHP major mode refers to.
Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
(put 'php-project-coding-style 'safe-local-variable #'symbolp)
(defvar-local php-project-align-lines t
"If T, automatically turn on `php-align-mode' by `php-align-setup'.")
(put 'php-project-align-lines 'safe-local-variable #'booleanp)
(defvar-local php-project-php-file-as-template 'auto
"
`auto' (default)
Automatically switch to mode for template when HTML tag detected in file.
`t'
Switch all PHP files in that directory to mode for HTML template.
`nil'
Any .php in that directory is just a PHP script.
\(\(PATTERN . SYMBOL))
Alist of file name pattern regular expressions and the above symbol pairs.
PATTERN is regexp pattern.
")
(put 'php-project-php-file-as-template 'safe-local-variable #'php-project--validate-php-file-as-template)
(defvar-local php-project-repl nil
"Function name or path to REPL (interactive shell) script.")
(put 'php-project-repl 'safe-local-variable
#'(lambda (v) (or (functionp v)
(php-project--eval-bootstrap-scripts v))))
(defvar-local php-project-unit-test nil
"Function name or path to unit test script.")
(put 'php-project-unit-test 'safe-local-variable
#'(lambda (v) (or (functionp v)
(php-project--eval-bootstrap-scripts v))))
(defvar-local php-project-deploy nil
"Function name or path to deploy script.")
(put 'php-project-deploy 'safe-local-variable
#'(lambda (v) (or (functionp v)
(php-project--eval-bootstrap-scripts v))))
(defvar-local php-project-build nil
"Function name or path to build script.")
(put 'php-project-build 'safe-local-variable
#'(lambda (v) (or (functionp v)
(php-project--eval-bootstrap-scripts v))))
(defvar-local php-project-server-start nil
"Function name or path to server-start script.")
(put 'php-project-server-start 'safe-local-variable
#'(lambda (v) (or (functionp v)
(php-project--eval-bootstrap-scripts v)))))
;; Functions
(defun php-project--validate-php-file-as-template (val)
"Return T when `VAL' is valid list of safe ."
(cond
((null val) t)
((memq val '(t auto)) t)
((listp val)
(cl-loop for v in val
always (and (consp v)
(stringp (car v))
(php-project--validate-php-file-as-template (cdr v)))))
(t nil)))
(defun php-project--eval-bootstrap-scripts (val)
"Return T when `VAL' is valid list of safe bootstrap php script."
(cond
((stringp val) (and (file-exists-p val) val))
((eq 'composer val)
(let ((path (expand-file-name php-project-composer-autoloader (php-project-get-root-dir))))
(and (file-exists-p path) path)))
((and (consp val) (eq 'root (car val)) (stringp (cdr val)))
(let ((path (expand-file-name (cdr val) (php-project-get-root-dir))))
(and (file-exists-p path) path)))
((null val) nil)
((listp val)
(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")))
(defun php-project-get-file-html-template-type (filename)
"Return symbol T, NIL or `auto' by `FILENAME'."
(cond
((not php-project-php-file-as-template) nil)
((eq t php-project-php-file-as-template) t)
((eq 'auto php-project-php-file-as-template) 'auto)
((listp php-project-php-file-as-template)
(assoc-default filename php-project-php-file-as-template #'string-match-p))
(t (prog1 nil
(warn "php-project-php-file-as-template is unexpected format")))))
(defun php-project-apply-local-variables ()
"Apply php-project variables to local variables."
(when (null tags-file-name)
(when (or (and php-project-auto-detect-etags-file
(null php-project-etags-file))
(eq php-project-etags-file t))
(let ((tags-file (expand-file-name "TAGS" (php-project-get-root-dir))))
(when (file-exists-p tags-file)
(setq-local php-project-etags-file tags-file))))
(when php-project-etags-file
(setq-local tags-file-name (php-project--eval-bootstrap-scripts php-project-etags-file)))))
;;;###autoload
(defun php-project-get-bootstrap-scripts ()
"Return list of bootstrap script."
(let ((scripts (php-project--eval-bootstrap-scripts php-project-bootstrap-scripts)))
(if (stringp scripts) (list scripts) scripts)))
;;;###autoload
(defun php-project-get-root-dir ()
"Return path to current PHP project."
(if (and (stringp php-project-root) (file-directory-p php-project-root))
php-project-root
(php-project--detect-root-dir)))
(defun php-project--detect-root-dir ()
"Return detected project root."
(if (and php-project-use-projectile-to-detect-root
(bound-and-true-p projectile-mode)
(fboundp 'projectile-project-root))
(projectile-project-root default-directory)
(let ((detect-method
(cond
((stringp php-project-root) (list php-project-root))
((eq php-project-root 'auto)
(cl-loop for m in php-project-available-root-files
append (cdr m)))
(t (cdr-safe (assq php-project-root php-project-available-root-files))))))
(cl-loop for m in detect-method
thereis (locate-dominating-file default-directory m)))))
(provide 'php-project)
;;; php-project.el ends here

View File

@ -1,452 +0,0 @@
;;; php.el --- PHP support for friends -*- lexical-binding: t; -*-
;; Copyright (C) 2020 Friends of Emacs-PHP development
;; Author: USAMI Kenta <tadsan@zonu.me>
;; Created: 5 Dec 2018
;; Version: 1.23.0
;; Keywords: languages, php
;; Homepage: https://github.com/emacs-php/php-mode
;; License: GPL-3.0-or-later
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides common variable and functions for PHP packages.
;;; Code:
(require 'cl-lib)
(require 'flymake)
(require 'php-project)
(require 'rx)
;;;###autoload
(defgroup php nil
"Language support for PHP."
:tag "PHP"
:group 'languages
:link '(url-link :tag "Official Site" "https://github.com/emacs-php/php-mode")
:link '(url-link :tag "PHP Mode Wiki" "https://github.com/emacs-php/php-mode/wiki"))
(defcustom php-executable (or (executable-find "php") "/usr/bin/php")
"The location of the PHP executable."
:group 'php
:tag "PHP Executable"
:type 'string)
(defcustom php-site-url "https://php.net/"
"Default PHP.net site URL.
The URL to use open PHP manual and search word."
:group 'php
:tag "PHP Site URL"
:type 'string)
(defcustom php-manual-url 'en
"URL at which to find PHP manual.
You can replace \"en\" with your ISO language code."
:group 'php
:tag "PHP Manual URL"
:type '(choice (const :tag "English" 'en)
(const :tag "Brazilian Portuguese" 'pt_BR)
(const :tag "Chinese (Simplified)" 'zh)
(const :tag "French" 'fr)
(const :tag "German" 'de)
(const :tag "Japanese" 'ja)
(const :tag "Romanian" 'ro)
(const :tag "Russian" 'ru)
(const :tag "Spanish" 'es)
(const :tag "Turkish" 'tr)
(string :tag "PHP manual URL")))
(defcustom php-search-url nil
"URL at which to search for documentation on a word."
:group 'php
:tag "PHP Search URL"
:type '(choice (string :tag "URL to search PHP documentation")
(const :tag "Use `php-site-url' variable" nil)))
(defcustom php-class-suffix-when-insert "::"
"Suffix for inserted class."
:group 'php
:type 'string)
(defcustom php-namespace-suffix-when-insert "\\"
"Suffix for inserted namespace."
:group 'php
:type 'string)
(defcustom php-default-major-mode 'php-mode
"Major mode for editing PHP script."
:group 'php
:tag "PHP Default Major Mode"
:type 'function)
(defcustom php-html-template-major-mode 'web-mode
"Major mode for editing PHP-HTML template."
:group 'php
:tag "PHP-HTML Template Major Mode"
:type 'function)
(defcustom php-blade-template-major-mode 'web-mode
"Major mode for editing Blade template."
:group 'php
:tag "PHP Blade Template Major Mode"
:type 'function)
(defcustom php-template-mode-alist
`(("\\.blade" . ,php-blade-template-major-mode)
("\\.phpt\\'" . ,(if (fboundp 'phpt-mode) 'phpt-mode php-default-major-mode))
("\\.phtml\\'" . ,php-html-template-major-mode))
"Automatically use another MAJOR-MODE when open template file."
:group 'php
:tag "PHP Template Mode Alist"
:type '(alist :key-type regexp :value-type function)
:link '(url-link :tag "web-mode" "http://web-mode.org/")
:link '(url-link :tag "phpt-mode" "https://github.com/emacs-php/phpt-mode"))
(defcustom php-mode-maybe-hook nil
"List of functions to be executed on entry to `php-mode-maybe'."
:group 'php
:tag "PHP Mode Maybe Hook"
:type 'hook)
(defcustom php-default-builtin-web-server-port 3939
"Port number of PHP Built-in HTTP server (php -S)."
:group 'php
:tag "PHP Default Built-in Web Server Port"
:type 'integer
:link '(url-link :tag "Built-in web server"
"https://www.php.net/manual/features.commandline.webserver.php"))
;;; PHP Keywords
(defconst php-magical-constants
(list "__LINE__" "__FILE__" "__FUNCTION__" "__CLASS__" "__TRAIT__" "__METHOD__" "__NAMESPACE__")
"Magical keyword that is expanded at compile time.
These are different from \"constants\" in strict terms.
see https://www.php.net/manual/language.constants.predefined.php")
;;; Utillity for locate language construction
(defsubst php-in-string-p ()
"Return non-nil if inside a string.
it is the character that will terminate the string, or t if the string should be terminated by a generic string delimiter."
(nth 3 (syntax-ppss)))
(defsubst php-in-comment-p ()
"Return nil if outside a comment, t if inside a non-nestable comment, else an integer (the current comment nesting)."
(nth 4 (syntax-ppss)))
(defsubst php-in-string-or-comment-p ()
"Return character address of start of comment or string; nil if not in one."
(nth 8 (syntax-ppss)))
(defsubst php-in-poly-php-html-mode ()
"Return T if current buffer is in `poly-html-mode'."
(and (boundp 'poly-php-html-mode)
(symbol-value 'poly-php-html-mode)))
(defconst php-beginning-of-defun-regexp
"^\\s-*\\(?:\\(?:abstract\\|final\\|private\\|protected\\|public\\|static\\)\\s-+\\)*function\\s-+&?\\(\\(\\sw\\|\\s_\\)+\\)\\s-*("
"Regular expression for a PHP function.")
(eval-when-compile
(defun php-create-regexp-for-method (&optional visibility)
"Make a regular expression for methods with the given VISIBILITY.
VISIBILITY must be a string that names the visibility for a PHP
method, e.g. 'public'. The parameter VISIBILITY can itself also
be a regular expression.
The regular expression this function returns will check for other
keywords that can appear in method signatures, e.g. 'final' and
'static'. The regular expression will have one capture group
which will be the name of the method."
(when (stringp visibility)
(setq visibility (list visibility)))
(rx-to-string `(: line-start
(* (syntax whitespace))
,@(if visibility
`((* (or "abstract" "final" "static")
(+ (syntax whitespace)))
(or ,@visibility)
(+ (syntax whitespace))
(* (or "abstract" "final" "static")
(+ (syntax whitespace))))
'((* (* (or "abstract" "final" "static"
"private" "protected" "public")
(+ (syntax whitespace))))))
"function"
(+ (syntax whitespace))
(? "&" (* (syntax whitespace)))
(group (+ (or (syntax word) (syntax symbol))))
(* (syntax whitespace))
"(")))
(defun php-create-regexp-for-classlike (type)
"Accepts a `TYPE' of a 'classlike' object as a string, such as
'class' or 'interface', and returns a regexp as a string which
can be used to match against definitions for that classlike."
(concat
;; First see if 'abstract' or 'final' appear, although really these
;; are not valid for all values of `type' that the function
;; accepts.
"^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?"
;; The classlike type
type
;; Its name, which is the first captured group in the regexp. We
;; allow backslashes in the name to handle namespaces, but again
;; this is not necessarily correct for all values of `type'.
"\\s-+\\(\\(?:\\sw\\|\\\\\\|\\s_\\)+\\)")))
(defconst php-imenu-generic-expression
(eval-when-compile
`(("Namespaces"
,(php-create-regexp-for-classlike "namespace") 1)
("Classes"
,(php-create-regexp-for-classlike "class") 1)
("Interfaces"
,(php-create-regexp-for-classlike "interface") 1)
("Traits"
,(php-create-regexp-for-classlike "trait") 1)
("All Methods"
,(php-create-regexp-for-method) 1)
("Private Methods"
,(php-create-regexp-for-method '("private")) 1)
("Protected Methods"
,(php-create-regexp-for-method '("protected")) 1)
("Public Methods"
,(php-create-regexp-for-method '("public")) 1)
("Anonymous Functions"
"\\<\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*=\\s-*f\\(unctio\\)?n\\s-*(" 1)
("Named Functions"
"^\\s-*function\\s-+\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1)))
"Imenu generic expression for PHP Mode. See `imenu-generic-expression'.")
(defconst php--re-namespace-pattern
(eval-when-compile
(php-create-regexp-for-classlike "namespace")))
(defconst php--re-classlike-pattern
(eval-when-compile
(php-create-regexp-for-classlike (regexp-opt '("class" "interface" "trait")))))
(defun php-get-current-element (re-pattern)
"Return backward matched element by RE-PATTERN."
(save-excursion
(save-match-data
(when (re-search-backward re-pattern nil t)
(match-string-no-properties 1)))))
;;; Provide support for Flymake so that users can see warnings and
;;; errors in real-time as they write code.
(defun php-flymake-php-init ()
"PHP specific init-cleanup routines.
This is an alternative function of `flymake-php-init'.
Look at the `php-executable' variable instead of the constant \"php\" command."
(let* ((init (funcall (eval-when-compile
(if (fboundp 'flymake-proc-php-init)
'flymake-proc-php-init
'flymake-php-init)))))
(list php-executable (cdr init))))
(defconst php-re-detect-html-tag-aggressive
(eval-when-compile
(rx (or (: string-start (* (in space))
"<!"
(or "DOCTYPE" "doctype")
(+ (in space))
(or "HTML" "html"))
(: (or line-start
(: "<" (? "/")
(* (in space)) (+ (in alpha "-")) (* (in space)) ">"))
(: "<" (* (in space)) (+ (in alpha "-")) (* (in space)) ">"))))))
(defconst php-re-detect-html-tag-default
(eval-when-compile
(rx (or (: string-start (* (in space))
"<!"
(or "DOCTYPE" "doctype")
(+ (in space))
(or "HTML" "html"))
(: line-start
(: "<" (* (in space)) (+ (in alpha "-")) (* (in space)) ">"))))))
(defcustom php-re-detect-html-tag 'php-re-detect-html-tag-default
"Regexp pattern variable-name of HTML detection."
:group 'php
:tag "PHP Re Detect HTML Tag"
:type '(choice (const :tag "Default pattern" 'php-re-detect-html-tag-default)
(const :tag "Aggressive pattern" 'php-re-detect-html-tag-aggressive)
(variable :tag "Variable name of RegExp pattern")))
(defsubst php-re-detect-html-tag ()
"Return RegExp pattern for HTML detection."
(if (symbolp php-re-detect-html-tag)
(symbol-value php-re-detect-html-tag)
php-re-detect-html-tag))
(defun php-buffer-has-html-tag ()
"Return position of HTML tag or NIL in current buffer."
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(save-match-data
(re-search-forward (php-re-detect-html-tag) nil t)))))
(defun php-derivation-major-mode ()
"Return major mode for PHP file by file-name and its content."
(let ((mode (assoc-default buffer-file-name
php-template-mode-alist
#'string-match-p))
type)
(when (and (null mode) buffer-file-name
php-project-php-file-as-template)
(setq type (php-project-get-file-html-template-type buffer-file-name))
(cond
((eq t type) (setq mode php-html-template-major-mode))
((eq 'auto type)
(when (php-buffer-has-html-tag)
(setq mode php-html-template-major-mode)))))
(when (and mode (not (fboundp mode)))
(if (string-match-p "\\.blade\\." buffer-file-name)
(warn "php-mode is NOT support blade template. %s"
"Please install `web-mode' package")
(setq mode nil)))
(or mode php-default-major-mode)))
;;;###autoload
(defun php-mode-maybe ()
"Select PHP mode or other major mode."
(interactive)
(run-hooks php-mode-maybe-hook)
(funcall (php-derivation-major-mode)))
;;;###autoload
(defun php-current-class ()
"Insert current class name if cursor in class context."
(interactive)
(let ((matched (php-get-current-element php--re-classlike-pattern)))
(when matched
(insert (concat matched php-class-suffix-when-insert)))))
;;;###autoload
(defun php-current-namespace ()
"Insert current namespace if cursor in namespace context."
(interactive)
(let ((matched (php-get-current-element php--re-namespace-pattern)))
(when matched
(insert (concat matched php-namespace-suffix-when-insert)))))
;;;###autoload
(defun php-copyit-fqsen ()
"Copy/kill class/method FQSEN."
(interactive)
(let ((namespace (or (php-get-current-element php--re-namespace-pattern) ""))
(class (or (php-get-current-element php--re-classlike-pattern) ""))
(namedfunc (php-get-current-element php-beginning-of-defun-regexp)))
(kill-new (concat (if (string= namespace "") "" namespace)
(if (string= class "") "" (concat "\\" class "::"))
(if (string= namedfunc "") "" (concat namedfunc "()"))))))
;;;###autoload
(defun php-run-builtin-web-server (router-or-dir hostname port &optional document-root)
"Run PHP Built-in web server.
`ROUTER-OR-DIR': Path to router PHP script or Document root.
`HOSTNAME': Hostname or IP address of Built-in web server.
`PORT': Port number of Built-in web server.
`DOCUMENT-ROOT': Path to Document root.
When `DOCUMENT-ROOT' is NIL, the document root is obtained from `ROUTER-OR-DIR'."
(interactive
(let ((insert-default-directory t)
(d-o-r (read-file-name "Document root or Script: " default-directory)))
(list
(expand-file-name d-o-r)
(read-string "Hostname: " "0.0.0.0")
(read-number "Port: " php-default-builtin-web-server-port)
(if (file-directory-p d-o-r)
nil
(let ((root-input (read-file-name "Document root: " (directory-file-name d-o-r))))
(file-name-directory
(if (file-directory-p root-input)
root-input
(directory-file-name root-input))))))))
(let* ((default-directory
(or document-root
(if (file-directory-p router-or-dir)
router-or-dir
(directory-file-name router-or-dir))))
(short-dirname (abbreviate-file-name default-directory))
(short-filename (abbreviate-file-name router-or-dir))
(buf-name (format "php -S %s:%s -t %s %s"
hostname
port
short-dirname
(if document-root short-filename "")))
(args (cl-remove-if
#'null
(list "-S"
(format "%s:%d" hostname port)
"-t"
default-directory
(when document-root router-or-dir)))))
(message "Run PHP built-in server: %s" buf-name)
(apply #'make-comint buf-name php-executable nil args)
(funcall
(if (called-interactively-p 'interactive) #'display-buffer #'get-buffer)
(format "*%s*" buf-name))))
(defun php-ini ()
"Get `php --ini' output buffer."
(interactive)
(let ((buffer (get-buffer-create " *php --ini*")))
(with-current-buffer buffer
(view-mode -1)
(read-only-mode -1)
(erase-buffer)
(shell-command (concat php-executable " --ini") buffer)
(view-mode +1))
(if (called-interactively-p 'interactive)
(pop-to-buffer buffer)
buffer)))
;;;###autoload
(defun php-find-system-php-ini-file (&optional file)
"Find php.ini FILE by `php --ini'."
(interactive
(list
(let* ((default-directory (expand-file-name "~"))
(buffer (php-ini))
(path (with-current-buffer buffer
(goto-char (point-min))
(save-match-data
(when (re-search-forward ": \\(.+?\\)$" nil nil)
(match-string 1))))))
(when (or (null path) (not (file-directory-p path)))
(when (called-interactively-p 'interactive)
(pop-to-buffer buffer))
(user-error "Failed get path to PHP ini files directory"))
(read-file-name "Find php.ini file: "
(concat (expand-file-name path) "/")
nil nil nil
#'file-exists-p))))
(find-file file))
(provide 'php)
;;; php.el ends here

Binary file not shown.

View File

@ -10,6 +10,10 @@ Si deseas clonar mi configuración, puedes clonar este repositorio:
`git clone https://git.kj2.me/kj/confi-emacs-inicial.git ~/.emacs.d` `git clone https://git.kj2.me/kj/confi-emacs-inicial.git ~/.emacs.d`
También es necesario instalar php-elisp (y emacs, si aún no los has hecho), en el caso de debian y derivados se instaría así:
`sudo apt install emacs php-elisp`
Finalmente, teniendo emacs adentro, si es que quieres que neotree te muestre unos íconos bonitos, debes precionar ALT+M e ingresar este comando en el minibúfer: Finalmente, teniendo emacs adentro, si es que quieres que neotree te muestre unos íconos bonitos, debes precionar ALT+M e ingresar este comando en el minibúfer:
`all-the-icons-install-fonts` `all-the-icons-install-fonts`
@ -18,4 +22,4 @@ Y eso sería todo.
## Consideraciones ## Consideraciones
Esta configuración está hecha a mi medida, usos y juicio, pero el init.el lo he procurado comentar bastante para que sea sencillo entenderlo y que lo reedites a tu gusto. Esta confi está hecha a mi medida, usos y juicio, pero el init.el lo he procurado comentar bastante para que sea sencillo entenderlo y que lo reedites a tu gusto.