diff options
| author | Simeon Simeonov | 2026-08-27 20:53:38 +0200 |
|---|---|---|
| committer | Simeon Simeonov | 2026-08-27 20:53:38 +0200 |
| commit | 9daec97a593cd6c419badbf08259bdf3653520ab (patch) | |
| tree | b7896065cf7ecab0ace30dafb2a9a1d758d0a6cf /.emacs.d/lisp/php-project.el | |
| parent | 85601f50f236686da662b1b00e01df0a0abe761b (diff) | |
Upgrade markdown-mode rust-mode and yaml-mode. Remove PHP mode.
Diffstat (limited to '.emacs.d/lisp/php-project.el')
| -rw-r--r-- | .emacs.d/lisp/php-project.el | 283 |
1 files changed, 0 insertions, 283 deletions
diff --git a/.emacs.d/lisp/php-project.el b/.emacs.d/lisp/php-project.el deleted file mode 100644 index 18115cc..0000000 --- a/.emacs.d/lisp/php-project.el +++ /dev/null | |||
| @@ -1,283 +0,0 @@ | |||
| 1 | ;;; php-project.el --- Project support for PHP application -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2018-2019 Friends of Emacs-PHP development | ||
| 4 | |||
| 5 | ;; Author: USAMI Kenta <tadsan@zonu.me> | ||
| 6 | ;; Keywords: tools, files | ||
| 7 | ;; URL: https://github.com/emacs-php/php-mode | ||
| 8 | ;; Version: 1.22.1 | ||
| 9 | ;; Package-Requires: ((emacs "24.3")) | ||
| 10 | ;; License: GPL-3.0-or-later | ||
| 11 | |||
| 12 | ;; This program is free software; you can redistribute it and/or modify | ||
| 13 | ;; it under the terms of the GNU General Public License as published by | ||
| 14 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 15 | ;; (at your option) any later version. | ||
| 16 | |||
| 17 | ;; This program is distributed in the hope that it will be useful, | ||
| 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 20 | ;; GNU General Public License for more details. | ||
| 21 | |||
| 22 | ;; You should have received a copy of the GNU General Public License | ||
| 23 | ;; along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| 24 | |||
| 25 | ;;; Commentary: | ||
| 26 | |||
| 27 | ;; Define project specific functions and variables for PHP application. | ||
| 28 | ;; | ||
| 29 | ;; ## API | ||
| 30 | ;; | ||
| 31 | ;; ### `php-project-get-root-dir()' | ||
| 32 | ;; | ||
| 33 | ;; Return root directory of current buffer file. The root directory is | ||
| 34 | ;; determined by several marker file or directory. | ||
| 35 | ;; | ||
| 36 | ;; ### `php-project-get-bootstrap-scripts()' | ||
| 37 | ;; | ||
| 38 | ;; Return list of path to bootstrap script file. | ||
| 39 | ;; | ||
| 40 | ;; ### `php-project-get-php-executable()' | ||
| 41 | ;; | ||
| 42 | ;; Return path to PHP executable file with the project settings overriding. | ||
| 43 | ;; | ||
| 44 | ;; ### `php-project-get-phan-executable()' | ||
| 45 | ;; | ||
| 46 | ;; Return path to Phan executable file with the project settings overriding. | ||
| 47 | ;; Phan is a static analyzer and LSP server implementation for PHP. | ||
| 48 | ;; See https://github.com/phan/phan | ||
| 49 | ;; | ||
| 50 | ;; ## `.dir-locals.el' support | ||
| 51 | ;; | ||
| 52 | ;; - `php-project-coding-style' | ||
| 53 | ;; - Symbol value of the coding style. (ex. `pear', `psr2') | ||
| 54 | ;; - `php-project-root' | ||
| 55 | ;; - Symbol of marker file of project root. (ex. `git', `composer') | ||
| 56 | ;; - Full path to project root directory. (ex. "/path/to/your-project") | ||
| 57 | ;; - `php-project-bootstrap-scripts' | ||
| 58 | ;; - List of path to bootstrap file of project. | ||
| 59 | ;; (ex. (((root . "vendor/autoload.php") (root . "inc/bootstrap.php"))) | ||
| 60 | ;; - `php-project-php-executable' | ||
| 61 | ;; - Path to project specific PHP executable file. | ||
| 62 | ;; - If you want to use a file different from the system wide `php' command. | ||
| 63 | ;; - `php-project-phan-executable' | ||
| 64 | ;; - Path to project specific Phan executable file. | ||
| 65 | ;; - When not specified explicitly, it is automatically searched from | ||
| 66 | ;; Composer's dependency of the project and `exec-path'. | ||
| 67 | ;; | ||
| 68 | |||
| 69 | ;;; Code: | ||
| 70 | (require 'cl-lib) | ||
| 71 | |||
| 72 | ;; Constants | ||
| 73 | (defconst php-project-composer-autoloader "vendor/autoload.php") | ||
| 74 | |||
| 75 | ;; Custom variables | ||
| 76 | (defgroup php-project nil | ||
| 77 | "Major mode for editing PHP code." | ||
| 78 | :tag "PHP Project" | ||
| 79 | :prefix "php-project-" | ||
| 80 | :group 'php) | ||
| 81 | |||
| 82 | (defcustom php-project-auto-detect-etags-file nil | ||
| 83 | "If `T', automatically detect etags file when file is opened." | ||
| 84 | :tag "PHP Project Auto Detect Etags File" | ||
| 85 | :group 'php-project | ||
| 86 | :type 'boolean) | ||
| 87 | |||
| 88 | ;; Variables | ||
| 89 | (defvar php-project-available-root-files | ||
| 90 | '((projectile ".projectile") | ||
| 91 | (composer "composer.json" "composer.lock") | ||
| 92 | (git ".git") | ||
| 93 | (mercurial ".hg") | ||
| 94 | (subversion ".svn") | ||
| 95 | ;; NOTICE: This method does not detect the top level of .editorconfig | ||
| 96 | ;; However, we can integrate it by adding the editorconfig.el's API. | ||
| 97 | ;;(editorconfig . ".editorconfig") | ||
| 98 | )) | ||
| 99 | |||
| 100 | ;; Buffer local variables | ||
| 101 | |||
| 102 | ;;;###autoload | ||
| 103 | (progn | ||
| 104 | (defvar-local php-project-root 'auto | ||
| 105 | "Method of searching for the top level directory. | ||
| 106 | |||
| 107 | `auto' (default) | ||
| 108 | Try to search file in order of `php-project-available-root-files'. | ||
| 109 | |||
| 110 | SYMBOL | ||
| 111 | Key of `php-project-available-root-files'. | ||
| 112 | |||
| 113 | STRING | ||
| 114 | A file/directory name of top level marker. | ||
| 115 | If the string is an actual directory path, it is set as the absolute path | ||
| 116 | of the root directory, not the marker.") | ||
| 117 | (put 'php-project-root 'safe-local-variable | ||
| 118 | #'(lambda (v) (or (stringp v) (assq v php-project-available-root-files)))) | ||
| 119 | |||
| 120 | (defvar-local php-project-etags-file nil) | ||
| 121 | (put 'php-project-etags-file 'safe-local-variable | ||
| 122 | #'(lambda (v) (or (functionp v) | ||
| 123 | (eq v t) | ||
| 124 | (php-project--eval-bootstrap-scripts v)))) | ||
| 125 | |||
| 126 | (defvar-local php-project-bootstrap-scripts nil | ||
| 127 | "List of path to bootstrap php script file. | ||
| 128 | |||
| 129 | The ideal bootstrap file is silent, it only includes dependent files, | ||
| 130 | defines constants, and sets the class loaders.") | ||
| 131 | (put 'php-project-bootstrap-scripts 'safe-local-variable #'php-project--eval-bootstrap-scripts) | ||
| 132 | |||
| 133 | (defvar-local php-project-php-executable nil | ||
| 134 | "Path to php executable file.") | ||
| 135 | (put 'php-project-php-executable 'safe-local-variable | ||
| 136 | #'(lambda (v) (and (stringp v) (file-executable-p v)))) | ||
| 137 | |||
| 138 | (defvar-local php-project-phan-executable nil | ||
| 139 | "Path to phan executable file.") | ||
| 140 | (put 'php-project-phan-executable 'safe-local-variable #'php-project--eval-bootstrap-scripts) | ||
| 141 | |||
| 142 | (defvar-local php-project-coding-style nil | ||
| 143 | "Symbol value of the coding style of the project that PHP major mode refers to. | ||
| 144 | |||
| 145 | Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.") | ||
| 146 | (put 'php-project-coding-style 'safe-local-variable #'symbolp) | ||
| 147 | |||
| 148 | (defvar-local php-project-php-file-as-template 'auto | ||
| 149 | " | ||
| 150 | `auto' (default) | ||
| 151 | Automatically switch to mode for template when HTML tag detected in file. | ||
| 152 | |||
| 153 | `t' | ||
| 154 | Switch all PHP files in that directory to mode for HTML template. | ||
| 155 | |||
| 156 | `nil' | ||
| 157 | Any .php in that directory is just a PHP script. | ||
| 158 | |||
| 159 | \(\(PATTERN . SYMBOL)) | ||
| 160 | Alist of file name pattern regular expressions and the above symbol pairs. | ||
| 161 | PATTERN is regexp pattern. | ||
| 162 | ") | ||
| 163 | (put 'php-project-php-file-as-template 'safe-local-variable #'php-project--validate-php-file-as-template) | ||
| 164 | |||
| 165 | (defvar-local php-project-repl nil | ||
| 166 | "Function name or path to REPL (interactive shell) script.") | ||
| 167 | (put 'php-project-repl 'safe-local-variable | ||
| 168 | #'(lambda (v) (or (functionp v) | ||
| 169 | (php-project--eval-bootstrap-scripts v)))) | ||
| 170 | |||
| 171 | (defvar-local php-project-unit-test nil | ||
| 172 | "Function name or path to unit test script.") | ||
| 173 | (put 'php-project-unit-test 'safe-local-variable | ||
| 174 | #'(lambda (v) (or (functionp v) | ||
| 175 | (php-project--eval-bootstrap-scripts v)))) | ||
| 176 | |||
| 177 | (defvar-local php-project-deploy nil | ||
| 178 | "Function name or path to deploy script.") | ||
| 179 | (put 'php-project-deploy 'safe-local-variable | ||
| 180 | #'(lambda (v) (or (functionp v) | ||
| 181 | (php-project--eval-bootstrap-scripts v)))) | ||
| 182 | |||
| 183 | (defvar-local php-project-build nil | ||
| 184 | "Function name or path to build script.") | ||
| 185 | (put 'php-project-build 'safe-local-variable | ||
| 186 | #'(lambda (v) (or (functionp v) | ||
| 187 | (php-project--eval-bootstrap-scripts v)))) | ||
| 188 | |||
| 189 | (defvar-local php-project-server-start nil | ||
| 190 | "Function name or path to server-start script.") | ||
| 191 | (put 'php-project-server-start 'safe-local-variable | ||
| 192 | #'(lambda (v) (or (functionp v) | ||
| 193 | (php-project--eval-bootstrap-scripts v))))) | ||
| 194 | |||
| 195 | ;; Functions | ||
| 196 | (defun php-project--validate-php-file-as-template (val) | ||
| 197 | "Return T when `VAL' is valid list of safe ." | ||
| 198 | (cond | ||
| 199 | ((null val) t) | ||
| 200 | ((memq val '(t auto)) t) | ||
| 201 | ((listp val) | ||
| 202 | (cl-loop for v in val | ||
| 203 | always (and (consp v) | ||
| 204 | (stringp (car v)) | ||
| 205 | (php-project--validate-php-file-as-template (cdr v))))) | ||
| 206 | (t nil))) | ||
| 207 | |||
| 208 | (defun php-project--eval-bootstrap-scripts (val) | ||
| 209 | "Return T when `VAL' is valid list of safe bootstrap php script." | ||
| 210 | (cond | ||
| 211 | ((stringp val) (and (file-exists-p val) val)) | ||
| 212 | ((eq 'composer val) | ||
| 213 | (let ((path (expand-file-name php-project-composer-autoloader (php-project-get-root-dir)))) | ||
| 214 | (and (file-exists-p path) path))) | ||
| 215 | ((and (consp val) (eq 'root (car val)) (stringp (cdr val))) | ||
| 216 | (let ((path (expand-file-name (cdr val) (php-project-get-root-dir)))) | ||
| 217 | (and (file-exists-p path) path))) | ||
| 218 | ((null val) nil) | ||
| 219 | ((listp val) | ||
| 220 | (cl-loop for v in val collect (php-project--eval-bootstrap-scripts v))) | ||
| 221 | (t nil))) | ||
| 222 | |||
| 223 | (defun php-project-get-php-executable () | ||
| 224 | "Return path to PHP executable file." | ||
| 225 | (cond | ||
| 226 | ((and (stringp php-project-php-executable) | ||
| 227 | (file-executable-p php-project-php-executable)) | ||
| 228 | php-project-php-executable) | ||
| 229 | ((boundp 'php-executable) php-executable) | ||
| 230 | (t (executable-find "php")))) | ||
| 231 | |||
| 232 | (defun php-project-get-phan-executable () | ||
| 233 | "Return path to phan executable file." | ||
| 234 | (or (car-safe (php-project--eval-bootstrap-scripts | ||
| 235 | (list php-project-phan-executable | ||
| 236 | (cons 'root "vendor/bin/phan")))) | ||
| 237 | (executable-find "phan"))) | ||
| 238 | |||
| 239 | (defun php-project-get-file-html-template-type (filename) | ||
| 240 | "Return symbol T, NIL or `auto' by `FILENAME'." | ||
| 241 | (cond | ||
| 242 | ((not php-project-php-file-as-template) nil) | ||
| 243 | ((eq t php-project-php-file-as-template) t) | ||
| 244 | ((eq 'auto php-project-php-file-as-template) 'auto) | ||
| 245 | ((listp php-project-php-file-as-template) | ||
| 246 | (assoc-default filename php-project-php-file-as-template #'string-match-p)) | ||
| 247 | (t (prog1 nil | ||
| 248 | (warn "php-project-php-file-as-template is unexpected format"))))) | ||
| 249 | |||
| 250 | (defun php-project-apply-local-variables () | ||
| 251 | "Apply php-project variables to local variables." | ||
| 252 | (when (null tags-file-name) | ||
| 253 | (when (or (and php-project-auto-detect-etags-file | ||
| 254 | (null php-project-etags-file)) | ||
| 255 | (eq php-project-etags-file t)) | ||
| 256 | (let ((tags-file (expand-file-name "TAGS" (php-project-get-root-dir)))) | ||
| 257 | (when (file-exists-p tags-file) | ||
| 258 | (setq-local php-project-etags-file tags-file)))) | ||
| 259 | (when php-project-etags-file | ||
| 260 | (setq-local tags-file-name (php-project--eval-bootstrap-scripts php-project-etags-file))))) | ||
| 261 | ;;;###autoload | ||
| 262 | (defun php-project-get-bootstrap-scripts () | ||
| 263 | "Return list of bootstrap script." | ||
| 264 | (let ((scripts (php-project--eval-bootstrap-scripts php-project-bootstrap-scripts))) | ||
| 265 | (if (stringp scripts) (list scripts) scripts))) | ||
| 266 | |||
| 267 | ;;;###autoload | ||
| 268 | (defun php-project-get-root-dir () | ||
| 269 | "Return path to current PHP project." | ||
| 270 | (if (and (stringp php-project-root) (file-directory-p php-project-root)) | ||
| 271 | php-project-root | ||
| 272 | (let ((detect-method | ||
| 273 | (cond | ||
| 274 | ((stringp php-project-root) (list php-project-root)) | ||
| 275 | ((eq php-project-root 'auto) | ||
| 276 | (cl-loop for m in php-project-available-root-files | ||
| 277 | append (cdr m))) | ||
| 278 | (t (cdr-safe (assq php-project-root php-project-available-root-files)))))) | ||
| 279 | (cl-loop for m in detect-method | ||
| 280 | thereis (locate-dominating-file default-directory m))))) | ||
| 281 | |||
| 282 | (provide 'php-project) | ||
| 283 | ;;; php-project.el ends here | ||
