|
| 1 | +;;; php-mode.el --- major mode for editing PHP code |
| 2 | + |
| 3 | +;; Copyright (C) 1999, 2000, 2001, 2003, 2004 Turadg Aleahmad |
| 4 | +;; 2008 Aaron S. Hawley |
| 5 | + |
| 6 | +;; Maintainer: Aaron S. Hawley <ashawley at users.sourceforge.net> |
| 7 | +;; Author: Turadg Aleahmad, 1999-2004 |
| 8 | +;; Keywords: php languages oop |
| 9 | +;; Created: 1999-05-17 |
| 10 | +;; Modified: 2008-11-04 |
| 11 | +;; X-URL: http://php-mode.sourceforge.net/ |
| 12 | + |
| 13 | +(defconst php-mode-version-number "1.5.0" |
| 14 | + "PHP Mode version number.") |
| 15 | + |
| 16 | +;;; License |
| 17 | + |
| 18 | +;; This file is free software; you can redistribute it and/or |
| 19 | +;; modify it under the terms of the GNU General Public License |
| 20 | +;; as published by the Free Software Foundation; either version 3 |
| 21 | +;; of the License, or (at your option) any later version. |
| 22 | + |
| 23 | +;; This file is distributed in the hope that it will be useful, |
| 24 | +;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 | +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 | +;; GNU General Public License for more details. |
| 27 | + |
| 28 | +;; You should have received a copy of the GNU General Public License |
| 29 | +;; along with this file; if not, write to the Free Software |
| 30 | +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 31 | +;; 02110-1301, USA. |
| 32 | + |
| 33 | +;;; Usage |
| 34 | + |
| 35 | +;; Put this file in your Emacs lisp path (eg. site-lisp) and add to |
| 36 | +;; your .emacs file: |
| 37 | +;; |
| 38 | +;; (require 'php-mode) |
| 39 | + |
| 40 | +;; To use abbrev-mode, add lines like this: |
| 41 | +;; (add-hook 'php-mode-hook |
| 42 | +;; '(lambda () (define-abbrev php-mode-abbrev-table "ex" "extends"))) |
| 43 | + |
| 44 | +;; To make php-mode compatible with html-mode, see http://php-mode.sf.net |
| 45 | + |
| 46 | +;; Many options available under Help:Customize |
| 47 | +;; Options specific to php-mode are in |
| 48 | +;; Programming/Languages/Php |
| 49 | +;; Since it inherits much functionality from c-mode, look there too |
| 50 | +;; Programming/Languages/C |
| 51 | + |
| 52 | +;;; Commentary: |
| 53 | + |
| 54 | +;; PHP mode is a major mode for editing PHP 3 and 4 source code. It's |
| 55 | +;; an extension of C mode; thus it inherits all C mode's navigation |
| 56 | +;; functionality. But it colors according to the PHP grammar and indents |
| 57 | +;; according to the PEAR coding guidelines. It also includes a couple |
| 58 | +;; handy IDE-type features such as documentation search and a source |
| 59 | +;; and class browser. |
| 60 | + |
| 61 | +;;; Contributors: (in chronological order) |
| 62 | + |
| 63 | +;; Juanjo, Torsten Martinsen, Vinai Kopp, Sean Champ, Doug Marcey, |
| 64 | +;; Kevin Blake, Rex McMaster, Mathias Meyer, Boris Folgmann, Roland |
| 65 | +;; Rosenfeld, Fred Yankowski, Craig Andrews, John Keller, Ryan |
| 66 | +;; Sammartino, ppercot, Valentin Funk, Stig Bakken, Gregory Stark, |
| 67 | +;; Chris Morris, Nils Rennebarth, Gerrit Riessen, Eric Mc Sween, |
| 68 | +;; Ville Skytta, Giacomo Tesio, Lennart Borgman, Stefan Monnier, |
| 69 | +;; Aaron S. Hawley, Ian Eure, Bill Lovett, Dias Badekas, David House |
| 70 | + |
| 71 | +;;; Changelog: |
| 72 | + |
| 73 | +;; 1.5 |
| 74 | +;; Support function keywords like public, private and the ampersand |
| 75 | +;; character for function-based commands. Support abstract, final, |
| 76 | +;; static, public, private and protected keywords in Imenu. Fix |
| 77 | +;; reversed order of Imenu entries. Use font-lock-preprocessor-face |
| 78 | +;; for PHP and ASP tags. Make php-mode-modified a literal value |
| 79 | +;; rather than a computed string. Add date and time constants of |
| 80 | +;; PHP. (Dias Badekas) Fix false syntax highlighting of keywords |
| 81 | +;; because of underscore character. Change HTML indentation warning |
| 82 | +;; to match only HTML at the beginning of the line. Fix |
| 83 | +;; byte-compiler warnings. Clean-up whitespace and audited style |
| 84 | +;; consistency of code. Remove conditional bindings and XEmacs code |
| 85 | +;; that likely does nothing. |
| 86 | +;; |
| 87 | +;; 1.4 |
| 88 | +;; Updated GNU GPL to version 3. Ported to Emacs 22 (CC mode |
| 89 | +;; 5.31). M-x php-mode-version shows version. Provide end-of-defun |
| 90 | +;; beginning-of-defun functionality. Support add-log library. |
| 91 | +;; Fix __CLASS__ constant (Ian Eure). Allow imenu to see visibility |
| 92 | +;; declarations -- "private", "public", "protected". (Bill Lovett) |
| 93 | +;; |
| 94 | +;; 1.3 |
| 95 | +;; Changed the definition of # using a tip from Stefan |
| 96 | +;; Monnier to correct highlighting and indentation. (Lennart Borgman) |
| 97 | +;; Changed the highlighting of the HTML part. (Lennart Borgman) |
| 98 | +;; |
| 99 | +;; See the ChangeLog file included with the source package. |
| 100 | + |
| 101 | + |
| 102 | +;;; Code: |
| 103 | + |
| 104 | +(require 'speedbar) |
| 105 | +(require 'font-lock) |
| 106 | +(require 'cc-mode) |
| 107 | +(require 'cc-langs) |
| 108 | +(require 'custom) |
| 109 | +(require 'etags) |
| 110 | +(eval-when-compile |
| 111 | + (require 'regexp-opt)) |
| 112 | + |
| 113 | +;; Local variables |
| 114 | +(defgroup php nil |
| 115 | + "Major mode `php-mode' for editing PHP code." |
| 116 | + :prefix "php-" |
| 117 | + :group 'languages) |
| 118 | + |
| 119 | +(defcustom php-default-face 'default |
| 120 | + "Default face in `php-mode' buffers." |
| 121 | + :type 'face |
| 122 | + :group 'php) |
| 123 | + |
| 124 | +(defcustom php-speedbar-config t |
| 125 | + "When set to true automatically configures Speedbar to observe PHP files. |
| 126 | +Ignores php-file patterns option; fixed to expression \"\\.\\(inc\\|php[s34]?\\)\"" |
| 127 | + :type 'boolean |
| 128 | + :set (lambda (sym val) |
| 129 | + (set-default sym val) |
| 130 | + (if (and val (boundp 'speedbar)) |
| 131 | + (speedbar-add-supported-extension |
| 132 | + "\\.\\(inc\\|php[s34]?\\|phtml\\)"))) |
| 133 | + :group 'php) |
| 134 | + |
| 135 | +(defcustom php-mode-speedbar-open nil |
| 136 | + "Normally `php-mode' starts with the speedbar closed. |
| 137 | +Turning this on will open it whenever `php-mode' is loaded." |
| 138 | + :type 'boolean |
| 139 | + :set (lambda (sym val) |
| 140 | + (set-default sym val) |
| 141 | + (when val |
| 142 | + (speedbar 1))) |
| 143 | + :group 'php) |
| 144 | + |
| 145 | +(defvar php-imenu-generic-expression |
| 146 | + '( |
| 147 | + ("Private Methods" |
| 148 | + "^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?private\\s-+\\(?:static\\s-+\\)?function\\s-+\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1) |
| 149 | + ("Protected Methods" |
| 150 | + "^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?protected\\s-+\\(?:static\\s-+\\)?function\\s-+\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1) |
| 151 | + ("Public Methods" |
| 152 | + "^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?public\\s-+\\(?:static\\s-+\\)?function\\s-+\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1) |
| 153 | + ("Classes" |
| 154 | + "^\\s-*class\\s-+\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*" 1) |
| 155 | + ("All Functions" |
| 156 | + "^\\s-*\\(?:\\(?:abstract\\|final\\|private\\|protected\\|public\\|static\\)\\s-+\\)*function\\s-+\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1) |
| 157 | + ) |
| 158 | + "Imenu generic expression for PHP Mode. See `imenu-generic-expression'." |
| 159 | + ) |
| 160 | + |
| 161 | +(defcustom php-manual-url "http://www.php.net/manual/en/" |
| 162 | + "URL at which to find PHP manual. |
| 163 | +You can replace \"en\" with your ISO language code." |
| 164 | + :type 'string |
| 165 | + :group 'php) |
| 166 | + |
| 167 | +(defcustom php-search-url "http://www.php.net/" |
| 168 | + "URL at which to search for documentation on a word." |
| 169 | + :type 'string |
| 170 | + :group 'php) |
| 171 | + |
| 172 | +(defcustom php-completion-file "" |
| 173 | + "Path to the file which contains the function names known to PHP." |
| 174 | + :type 'string |
| 175 | + :group 'php) |
| 176 | + |
| 177 | +(defcustom php-manual-path "" |
| 178 | + "Path to the directory which contains the PHP manual." |
| 179 | + :type 'string |
| 180 | + :group 'php) |
| 181 | + |
| 182 | +;;;###autoload |
| 183 | +(defcustom php-file-patterns '("\\.php[s34]?\\'" "\\.phtml\\'" "\\.inc\\'") |
| 184 | + "List of file patterns for which to automatically invoke `php-mode'." |
| 185 | + :type '(repeat (regexp :tag "Pattern")) |
| 186 | + :set (lambda (sym val) |
| 187 | + (set-default sym val) |
| 188 | + (let ((php-file-patterns-temp val)) |
| 189 | + (while php-file-patterns-temp |
| 190 | + (add-to-list 'auto-mode-alist |
| 191 | + (cons (car php-file-patterns-temp) 'php-mode)) |
| 192 | + (setq php-file-patterns-temp (cdr php-file-patterns-temp))))) |
| 193 | + :group 'php) |
| 194 | + |
| 195 | +(defcustom php-mode-hook nil |
| 196 | + "List of functions to be executed on entry to `php-mode'." |
| 197 | + :type 'hook |
| 198 | + :group 'php) |
| 199 | + |
| 200 | +(defcustom php-mode-pear-hook nil |
| 201 | + "Hook called when a PHP PEAR file is opened with `php-mode'." |
| 202 | + :type 'hook |
| 203 | + :group 'php) |
| 204 | + |
| 205 | +(defcustom php-mode-force-pear nil |
| 206 | + "Normally PEAR coding rules are enforced only when the filename contains \"PEAR.\" |
| 207 | +Turning this on will force PEAR rules on all PHP files." |
| 208 | + :type 'boolean |
| 209 | + :group 'php) |
| 210 | + |
| 211 | +(defconst php-mode-modified "2008-11-04" |
| 212 | + "PHP Mode build date.") |
| 213 | + |
| 214 | +(defun php-mode-version () |
| 215 | + "Display string describing the version of PHP mode." |
| 216 | + (interactive) |
| 217 | + (message "PHP mode %s of %s" |
| 218 | + php-mode-version-number php-mode-modified)) |
| 219 | + |
| 220 | +(defconst php-beginning-of-defun-regexp |
| 221 | + "^\\s-*\\(?:\\(?:abstract\\|final\\|private\\|protected\\|public\\|static\\)\\s-+\\)*function\\s-+&?\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" |
| 222 | + "Regular expression for a PHP function.") |
| 223 | + |
| 224 | +(defun php-beginning-of-defun (&optional arg) |
| 225 | + "Move to the beginning of the ARGth PHP function from point. |
| 226 | +Implements PHP version of `beginning-of-defun-function'." |
| 227 | + (interactive "p") |
| 228 | + (let ((arg (or arg 1))) |
| 229 | + (while (> arg 0) |
| 230 | + (re-search-backward php-beginning-of-defun-regexp |
| 231 | + nil 'noerror) |
| 232 | + (setq arg (1- arg))) |
| 233 | + (while (< arg 0) |
| 234 | + (end-of-line 1) |
| 235 | + (let ((opoint (point))) |
| 236 | + (beginning-of-defun 1) |
| 237 | + (forward-list 2) |
| 238 | + (forward-line 1) |
| 239 | + (if (eq opoint (point)) |
| 240 | + (re-search-forward php-beginning-of-defun-regexp |
| 241 | + nil 'noerror)) |
| 242 | + (setq arg (1+ arg)))))) |
| 243 | + |
| 244 | +(defun php-end-of-defun (&optional arg) |
| 245 | + "Move the end of the ARGth PHP function from point. |
| 246 | +Implements PHP befsion of `end-of-defun-function' |
| 247 | +
|
| 248 | +See `php-beginning-of-defun'." |
| 249 | + (interactive "p") |
| 250 | + (php-beginning-of-defun (- (or arg 1)))) |
| 251 | + |
| 252 | + |
| 253 | +(defvar php-warned-bad-indent nil) |
| 254 | +(make-variable-buffer-local 'php-warned-bad-indent) |
| 255 | + |
| 256 | +;; Do it but tell it is not good if html tags in buffer. |
| 257 | +(defun php-check-html-for-indentation () |
| 258 | + (let ((html-tag-re "^\\s-*</?\\sw+.*?>") |
| 259 | + (here (point))) |
| 260 | + (if (not (or (re-search-forward html-tag-re (line-end-position) t) |
| 261 | + (re-search-backward html-tag-re (line-beginning-position) t))) |
| 262 | + t |
| 263 | + (goto-char here) |
| 264 | + (setq php-warned-bad-indent t) |
| 265 | + (lwarn 'php-indent :warning |
| 266 | + "\n\t%s\n\t%s\n\t%s\n" |
| 267 | + "Indentation fails badly with mixed HTML and PHP." |
| 268 | + "Look for an Emacs Lisp library that supports \"multiple" |
| 269 | + "major modes\" like mumamo, mmm-mode or multi-mode.") |
| 270 | + nil))) |
| 271 | + |
| 272 | +(defun php-cautious-indent-region (start end &optional quiet) |
| 273 | + (if (or php-warned-bad-indent |
| 274 | + (php-check-html-for-indentation)) |
| 275 | + (funcall 'c-indent-region start end quiet))) |
| 276 | + |
| 277 | +(defun php-cautious-indent-line () |
| 278 | + (if (or php-warned-bad-indent |
| 279 | + (php-check-html-for-indentation)) |
| 280 | + (funcall 'c-indent-line))) |
| 281 | + |
| 282 | +(defconst php-tags '("<?php" "?>" "<?" "<?=")) |
| 283 | +(defconst php-tags-key (regexp-opt php-tags)) |
| 284 | + |
| 285 | +(defconst php-block-stmt-1-kwds '("do" "else" "finally" "try")) |
| 286 | +(defconst php-block-stmt-2-kwds |
| 287 | + '("for" "if" "while" "switch" "foreach" "elseif" "catch all")) |
| 288 | + |
| 289 | +(defconst php-block-stmt-1-key |
| 290 | + (regexp-opt php-block-stmt-1-kwds)) |
| 291 | +(defconst php-block-stmt-2-key |
| 292 | + (regexp-opt php-block-stmt-2-kwds)) |
| 293 | + |
| 294 | +(defconst php-class-decl-kwds '("class" "interface")) |
| 295 | + |
| 296 | +(defconst php-class-key |
| 297 | + (concat |
| 298 | + "\\(" (regexp-opt php-class-decl-kwds) "\\)\\s-+" |
| 299 | + (c-lang-const c-symbol-key c) ;; Class name. |
| 300 | + "\\(\\s-+extends\\s-+" (c-lang-const c-symbol-key c) "\\)?" ;; Name of superclass. |
| 301 | + "\\(\\s-+implements\\s-+[^{]+{\\)?")) ;; List of any adopted protocols. |
| 302 | + |
| 303 | +;;;###autoload |
| 304 | +(define-derived-mode php-mode c-mode "PHP" |
| 305 | + "Major mode for editing PHP code.\n\n\\{php-mode-map}" |
| 306 | + (c-add-language 'php-mode 'c-mode) |
| 307 | + |
| 308 | +;; PHP doesn't have C-style macros. |
| 309 | +;; HACK: Overwrite this syntax with rules to match <?php and others. |
| 310 | +;; (c-lang-defconst c-opt-cpp-start php php-tags-key) |
| 311 | +;; (c-lang-defvar c-opt-cpp-start (c-lang-const c-opt-cpp-start)) |
| 312 | + (set (make-local-variable 'c-opt-cpp-start) php-tags-key) |
| 313 | +;; (c-lang-defconst c-opt-cpp-start php php-tags-key) |
| 314 | +;; (c-lang-defvar c-opt-cpp-start (c-lang-const c-opt-cpp-start)) |
| 315 | + (set (make-local-variable 'c-opt-cpp-prefix) php-tags-key) |
| 316 | + |
| 317 | + (c-set-offset 'cpp-macro 0) |
| 318 | + |
| 319 | +;; (c-lang-defconst c-block-stmt-1-kwds php php-block-stmt-1-kwds) |
| 320 | +;; (c-lang-defvar c-block-stmt-1-kwds (c-lang-const c-block-stmt-1-kwds)) |
| 321 | + (set (make-local-variable 'c-block-stmt-1-key) php-block-stmt-1-key) |
| 322 | + |
| 323 | +;; (c-lang-defconst c-block-stmt-2-kwds php php-block-stmt-2-kwds) |
| 324 | +;; (c-lang-defvar c-block-stmt-2-kwds (c-lang-const c-block-stmt-2-kwds)) |
| 325 | + (set (make-local-variable 'c-block-stmt-2-key) php-block-stmt-2-key) |
| 326 | + |
| 327 | + ;; Specify that cc-mode recognize Javadoc comment style |
| 328 | + (set (make-local-variable 'c-doc-comment-style) |
| 329 | + '((php-mode . javadoc))) |
| 330 | + |
| 331 | +;; (c-lang-defconst c-class-decl-kwds |
| 332 | +;; php php-class-decl-kwds) |
| 333 | + (set (make-local-variable 'c-class-key) php-class-key) |
| 334 | + |
| 335 | + (make-local-variable 'font-lock-defaults) |
| 336 | + (setq font-lock-defaults |
| 337 | + '((php-font-lock-keywords-1 |
| 338 | + php-font-lock-keywords-2 |
| 339 | + ;; Comment-out the next line if the font-coloring is too |
| 340 | + ;; extreme/ugly for you. |
| 341 | + php-font-lock-keywords-3) |
| 342 | + nil ; KEYWORDS-ONLY |
| 343 | + t ; CASE-FOLD |
| 344 | + (("_" . "w")) ; SYNTAX-ALIST |
| 345 | + nil)) ; SYNTAX-BEGIN |
| 346 | + |
| 347 | + ;; Electric behaviour must be turned off, they do not work since |
| 348 | + ;; they can not find the correct syntax in embedded PHP. |
| 349 | + ;; |
| 350 | + ;; Seems to work with narrowing so let it be on if the user prefers it. |
| 351 | + ;;(setq c-electric-flag nil) |
| 352 | + |
| 353 | + (setq font-lock-maximum-decoration t |
| 354 | + case-fold-search t ; PHP vars are case-sensitive |
| 355 | + imenu-generic-expression php-imenu-generic-expression) |
| 356 | + |
| 357 | + ;; Do not force newline at end of file. Such newlines can cause |
| 358 | + ;; trouble if the PHP file is included in another file before calls |
| 359 | + ;; to header() or cookie(). |
| 360 | + (set (make-local-variable 'require-final-newline) nil) |
| 361 | + (set (make-local-variable 'next-line-add-newlines) nil) |
| 362 | + |
| 363 | + ;; PEAR coding standards |
| 364 | + (add-hook 'php-mode-pear-hook |
| 365 | + (lambda () |
| 366 | + (set (make-local-variable 'tab-width) 4) |
| 367 | + (set (make-local-variable 'c-basic-offset) 4) |
| 368 | + (set (make-local-variable 'indent-tabs-mode) nil) |
| 369 | + (c-set-offset 'block-open' - ) |
| 370 | + (c-set-offset 'block-close' 0 )) nil t) |
| 371 | + |
| 372 | + (if (or php-mode-force-pear |
| 373 | + (and (stringp buffer-file-name) |
| 374 | + (string-match "PEAR\\|pear" |
| 375 | + (buffer-file-name)) |
| 376 | + (string-match "\\.php$" (buffer-file-name)))) |
| 377 | + (run-hooks 'php-mode-pear-hook)) |
| 378 | + |
| 379 | + (setq indent-line-function 'php-cautious-indent-line) |
| 380 | + (setq indent-region-function 'php-cautious-indent-region) |
| 381 | + (setq c-special-indent-hook nil) |
| 382 | + |
| 383 | + (set (make-local-variable 'beginning-of-defun-function) |
| 384 | + 'php-beginning-of-defun) |
| 385 | + (set (make-local-variable 'end-of-defun-function) |
| 386 | + 'php-end-of-defun) |
| 387 | + (set (make-local-variable 'open-paren-in-column-0-is-defun-start) |
| 388 | + nil) |
| 389 | + (set (make-local-variable 'defun-prompt-regexp) |
| 390 | + "^\\s-*function\\s-+&?\\s-*\\(\\(\\sw\\|\\s_\\)+\\)\\s-*") |
| 391 | + (set (make-local-variable 'add-log-current-defun-header-regexp) |
| 392 | + php-beginning-of-defun-regexp) |
| 393 | + |
| 394 | + (run-hooks 'php-mode-hook)) |
| 395 | + |
| 396 | +;; Make a menu keymap (with a prompt string) |
| 397 | +;; and make it the menu bar item's definition. |
| 398 | +(define-key php-mode-map [menu-bar] (make-sparse-keymap)) |
| 399 | +(define-key php-mode-map [menu-bar php] |
| 400 | + (cons "PHP" (make-sparse-keymap "PHP"))) |
| 401 | + |
| 402 | +;; Define specific subcommands in this menu. |
| 403 | +(define-key php-mode-map [menu-bar php complete-function] |
| 404 | + '("Complete function name" . php-complete-function)) |
| 405 | +(define-key php-mode-map |
| 406 | + [menu-bar php browse-manual] |
| 407 | + '("Browse manual" . php-browse-manual)) |
| 408 | +(define-key php-mode-map |
| 409 | + [menu-bar php search-documentation] |
| 410 | + '("Search documentation" . php-search-documentation)) |
| 411 | + |
| 412 | +;; Define function name completion function |
| 413 | +(defvar php-completion-table nil |
| 414 | + "Obarray of tag names defined in current tags table and functions known to PHP.") |
| 415 | + |
| 416 | +(defun php-complete-function () |
| 417 | + "Perform function completion on the text around point. |
| 418 | +Completes to the set of names listed in the current tags table |
| 419 | +and the standard php functions. |
| 420 | +The string to complete is chosen in the same way as the default |
| 421 | +for \\[find-tag] (which see)." |
| 422 | + (interactive) |
| 423 | + (let ((pattern (php-get-pattern)) |
| 424 | + beg |
| 425 | + completion |
| 426 | + (php-functions (php-completion-table))) |
| 427 | + (if (not pattern) (message "Nothing to complete") |
| 428 | + (search-backward pattern) |
| 429 | + (setq beg (point)) |
| 430 | + (forward-char (length pattern)) |
| 431 | + (setq completion (try-completion pattern php-functions nil)) |
| 432 | + (cond ((eq completion t)) |
| 433 | + ((null completion) |
| 434 | + (message "Can't find completion for \"%s\"" pattern) |
| 435 | + (ding)) |
| 436 | + ((not (string= pattern completion)) |
| 437 | + (delete-region beg (point)) |
| 438 | + (insert completion)) |
| 439 | + (t |
| 440 | + (message "Making completion list...") |
| 441 | + (with-output-to-temp-buffer "*Completions*" |
| 442 | + (display-completion-list |
| 443 | + (all-completions pattern php-functions))) |
| 444 | + (message "Making completion list...%s" "done")))))) |
| 445 | + |
| 446 | +(defun php-completion-table () |
| 447 | + "Build variable `php-completion-table' on demand. |
| 448 | +The table includes the PHP functions and the tags from the |
| 449 | +current `tags-file-name'." |
| 450 | + (or (and tags-file-name |
| 451 | + (save-excursion (tags-verify-table tags-file-name)) |
| 452 | + php-completion-table) |
| 453 | + (let ((tags-table |
| 454 | + (if (and tags-file-name |
| 455 | + (functionp 'etags-tags-completion-table)) |
| 456 | + (with-current-buffer (get-file-buffer tags-file-name) |
| 457 | + (etags-tags-completion-table)) |
| 458 | + nil)) |
| 459 | + (php-table |
| 460 | + (cond ((and (not (string= "" php-completion-file)) |
| 461 | + (file-readable-p php-completion-file)) |
| 462 | + (php-build-table-from-file php-completion-file)) |
| 463 | + (php-manual-path |
| 464 | + (php-build-table-from-path php-manual-path)) |
| 465 | + (t nil)))) |
| 466 | + (unless (or php-table tags-table) |
| 467 | + (error |
| 468 | + (concat "No TAGS file active nor are " |
| 469 | + "`php-completion-file' or `php-manual-path' set"))) |
| 470 | + (when tags-table |
| 471 | + ;; Combine the tables. |
| 472 | + (mapatoms (lambda (sym) (intern (symbol-name sym) php-table)) |
| 473 | + tags-table)) |
| 474 | + (setq php-completion-table php-table)))) |
| 475 | + |
| 476 | +(defun php-build-table-from-file (filename) |
| 477 | + (let ((table (make-vector 1022 0)) |
| 478 | + (buf (find-file-noselect filename))) |
| 479 | + (save-excursion |
| 480 | + (set-buffer buf) |
| 481 | + (goto-char (point-min)) |
| 482 | + (while (re-search-forward |
| 483 | + "^\\([-a-zA-Z0-9_.]+\\)\n" |
| 484 | + nil t) |
| 485 | + (intern (buffer-substring (match-beginning 1) (match-end 1)) |
| 486 | + table))) |
| 487 | + (kill-buffer buf) |
| 488 | + table)) |
| 489 | + |
| 490 | +(defun php-build-table-from-path (path) |
| 491 | + (let ((table (make-vector 1022 0)) |
| 492 | + (files (directory-files |
| 493 | + path |
| 494 | + nil |
| 495 | + "^function\\..+\\.html$"))) |
| 496 | + (mapc (lambda (file) |
| 497 | + (string-match "\\.\\([-a-zA-Z_0-9]+\\)\\.html$" file) |
| 498 | + (intern |
| 499 | + (replace-regexp-in-string |
| 500 | + "-" "_" (substring file (match-beginning 1) (match-end 1)) t) |
| 501 | + table)) |
| 502 | + files) |
| 503 | + table)) |
| 504 | + |
| 505 | +;; Find the pattern we want to complete |
| 506 | +;; find-tag-default from GNU Emacs etags.el |
| 507 | +(defun php-get-pattern () |
| 508 | + (save-excursion |
| 509 | + (while (looking-at "\\sw\\|\\s_") |
| 510 | + (forward-char 1)) |
| 511 | + (if (or (re-search-backward "\\sw\\|\\s_" |
| 512 | + (save-excursion (beginning-of-line) (point)) |
| 513 | + t) |
| 514 | + (re-search-forward "\\(\\sw\\|\\s_\\)+" |
| 515 | + (save-excursion (end-of-line) (point)) |
| 516 | + t)) |
| 517 | + (progn (goto-char (match-end 0)) |
| 518 | + (buffer-substring-no-properties |
| 519 | + (point) |
| 520 | + (progn (forward-sexp -1) |
| 521 | + (while (looking-at "\\s'") |
| 522 | + (forward-char 1)) |
| 523 | + (point)))) |
| 524 | + nil))) |
| 525 | + |
| 526 | +(defun php-show-arglist () |
| 527 | + (interactive) |
| 528 | + (let* ((tagname (php-get-pattern)) |
| 529 | + (buf (find-tag-noselect tagname nil nil)) |
| 530 | + arglist) |
| 531 | + (save-excursion |
| 532 | + (set-buffer buf) |
| 533 | + (goto-char (point-min)) |
| 534 | + (when (re-search-forward |
| 535 | + (format "function\\s-+%s\\s-*(\\([^{]*\\))" tagname) |
| 536 | + nil t) |
| 537 | + (setq arglist (buffer-substring-no-properties |
| 538 | + (match-beginning 1) (match-end 1))))) |
| 539 | + (if arglist |
| 540 | + (message "Arglist for %s: %s" tagname arglist) |
| 541 | + (message "Unknown function: %s" tagname)))) |
| 542 | + |
| 543 | +;; Define function documentation function |
| 544 | +(defun php-search-documentation () |
| 545 | + "Search PHP documentation for the word at point." |
| 546 | + (interactive) |
| 547 | + (browse-url (concat php-search-url (current-word t)))) |
| 548 | + |
| 549 | +;; Define function for browsing manual |
| 550 | +(defun php-browse-manual () |
| 551 | + "Bring up manual for PHP." |
| 552 | + (interactive) |
| 553 | + (browse-url php-manual-url)) |
| 554 | + |
| 555 | +;; Define shortcut |
| 556 | +(define-key php-mode-map |
| 557 | + "\C-c\C-f" |
| 558 | + 'php-search-documentation) |
| 559 | + |
| 560 | +;; Define shortcut |
| 561 | +(define-key php-mode-map |
| 562 | + [(meta tab)] |
| 563 | + 'php-complete-function) |
| 564 | + |
| 565 | +;; Define shortcut |
| 566 | +(define-key php-mode-map |
| 567 | + "\C-c\C-m" |
| 568 | + 'php-browse-manual) |
| 569 | + |
| 570 | +;; Define shortcut |
| 571 | +(define-key php-mode-map |
| 572 | + '[(control .)] |
| 573 | + 'php-show-arglist) |
| 574 | + |
| 575 | +(defconst php-constants |
| 576 | + (eval-when-compile |
| 577 | + (regexp-opt |
| 578 | + '(;; core constants |
| 579 | + "__LINE__" "__FILE__" |
| 580 | + "__FUNCTION__" "__CLASS__" "__METHOD__" |
| 581 | + "PHP_OS" "PHP_VERSION" |
| 582 | + "TRUE" "FALSE" "NULL" |
| 583 | + "E_ERROR" "E_NOTICE" "E_PARSE" "E_WARNING" "E_ALL" "E_STRICT" |
| 584 | + "E_USER_ERROR" "E_USER_WARNING" "E_USER_NOTICE" |
| 585 | + "DEFAULT_INCLUDE_PATH" "PEAR_INSTALL_DIR" "PEAR_EXTENSION_DIR" |
| 586 | + "PHP_BINDIR" "PHP_LIBDIR" "PHP_DATADIR" "PHP_SYSCONFDIR" |
| 587 | + "PHP_LOCALSTATEDIR" "PHP_CONFIG_FILE_PATH" |
| 588 | + "PHP_EOL" |
| 589 | + |
| 590 | + ;; date and time constants |
| 591 | + "DATE_ATOM" "DATE_COOKIE" "DATE_ISO8601" |
| 592 | + "DATE_RFC822" "DATE_RFC850" "DATE_RFC1036" "DATE_RFC1123" |
| 593 | + "DATE_RFC2822" "DATE_RFC3339" |
| 594 | + "DATE_RSS" "DATE_W3C" |
| 595 | + |
| 596 | + ;; from ext/standard: |
| 597 | + "EXTR_OVERWRITE" "EXTR_SKIP" "EXTR_PREFIX_SAME" |
| 598 | + "EXTR_PREFIX_ALL" "EXTR_PREFIX_INVALID" "SORT_ASC" "SORT_DESC" |
| 599 | + "SORT_REGULAR" "SORT_NUMERIC" "SORT_STRING" "ASSERT_ACTIVE" |
| 600 | + "ASSERT_CALLBACK" "ASSERT_BAIL" "ASSERT_WARNING" |
| 601 | + "ASSERT_QUIET_EVAL" "CONNECTION_ABORTED" "CONNECTION_NORMAL" |
| 602 | + "CONNECTION_TIMEOUT" "M_E" "M_LOG2E" "M_LOG10E" "M_LN2" |
| 603 | + "M_LN10" "M_PI" "M_PI_2" "M_PI_4" "M_1_PI" "M_2_PI" |
| 604 | + "M_2_SQRTPI" "M_SQRT2" "M_SQRT1_2" "CRYPT_SALT_LENGTH" |
| 605 | + "CRYPT_STD_DES" "CRYPT_EXT_DES" "CRYPT_MD5" "CRYPT_BLOWFISH" |
| 606 | + "DIRECTORY_SEPARATOR" "SEEK_SET" "SEEK_CUR" "SEEK_END" |
| 607 | + "LOCK_SH" "LOCK_EX" "LOCK_UN" "LOCK_NB" "HTML_SPECIALCHARS" |
| 608 | + "HTML_ENTITIES" "ENT_COMPAT" "ENT_QUOTES" "ENT_NOQUOTES" |
| 609 | + "INFO_GENERAL" "INFO_CREDITS" "INFO_CONFIGURATION" |
| 610 | + "INFO_ENVIRONMENT" "INFO_VARIABLES" "INFO_LICENSE" "INFO_ALL" |
| 611 | + "CREDITS_GROUP" "CREDITS_GENERAL" "CREDITS_SAPI" |
| 612 | + "CREDITS_MODULES" "CREDITS_DOCS" "CREDITS_FULLPAGE" |
| 613 | + "CREDITS_QA" "CREDITS_ALL" "PHP_OUTPUT_HANDLER_START" |
| 614 | + "PHP_OUTPUT_HANDLER_CONT" "PHP_OUTPUT_HANDLER_END" |
| 615 | + "STR_PAD_LEFT" "STR_PAD_RIGHT" "STR_PAD_BOTH" |
| 616 | + "PATHINFO_DIRNAME" "PATHINFO_BASENAME" "PATHINFO_EXTENSION" |
| 617 | + "CHAR_MAX" "LC_CTYPE" "LC_NUMERIC" "LC_TIME" "LC_COLLATE" |
| 618 | + "LC_MONETARY" "LC_ALL" "LC_MESSAGES" "LOG_EMERG" "LOG_ALERT" |
| 619 | + "LOG_CRIT" "LOG_ERR" "LOG_WARNING" "LOG_NOTICE" "LOG_INFO" |
| 620 | + "LOG_DEBUG" "LOG_KERN" "LOG_USER" "LOG_MAIL" "LOG_DAEMON" |
| 621 | + "LOG_AUTH" "LOG_SYSLOG" "LOG_LPR" "LOG_NEWS" "LOG_UUCP" |
| 622 | + "LOG_CRON" "LOG_AUTHPRIV" "LOG_LOCAL0" "LOG_LOCAL1" |
| 623 | + "LOG_LOCAL2" "LOG_LOCAL3" "LOG_LOCAL4" "LOG_LOCAL5" |
| 624 | + "LOG_LOCAL6" "LOG_LOCAL7" "LOG_PID" "LOG_CONS" "LOG_ODELAY" |
| 625 | + "LOG_NDELAY" "LOG_NOWAIT" "LOG_PERROR" |
| 626 | + |
| 627 | + ;; Disabled by default because they slow buffer loading |
| 628 | + ;; If you have use for them, uncomment the strings |
| 629 | + ;; that you want colored. |
| 630 | + ;; To compile, you may have to increase 'max-specpdl-size' |
| 631 | + |
| 632 | + ;; from other bundled extensions: |
| 633 | +; "CAL_EASTER_TO_xxx" "VT_NULL" "VT_EMPTY" "VT_UI1" "VT_I2" |
| 634 | +; "VT_I4" "VT_R4" "VT_R8" "VT_BOOL" "VT_ERROR" "VT_CY" "VT_DATE" |
| 635 | +; "VT_BSTR" "VT_DECIMAL" "VT_UNKNOWN" "VT_DISPATCH" "VT_VARIANT" |
| 636 | +; "VT_I1" "VT_UI2" "VT_UI4" "VT_INT" "VT_UINT" "VT_ARRAY" |
| 637 | +; "VT_BYREF" "CP_ACP" "CP_MACCP" "CP_OEMCP" "CP_SYMBOL" |
| 638 | +; "CP_THREAD_ACP" "CP_UTF7" "CP_UTF8" "CPDF_PM_NONE" |
| 639 | +; "CPDF_PM_OUTLINES" "CPDF_PM_THUMBS" "CPDF_PM_FULLSCREEN" |
| 640 | +; "CPDF_PL_SINGLE" "CPDF_PL_1COLUMN" "CPDF_PL_2LCOLUMN" |
| 641 | +; "CPDF_PL_2RCOLUMN" "CURLOPT_PORT" "CURLOPT_FILE" |
| 642 | +; "CURLOPT_INFILE" "CURLOPT_INFILESIZE" "CURLOPT_URL" |
| 643 | +; "CURLOPT_PROXY" "CURLOPT_VERBOSE" "CURLOPT_HEADER" |
| 644 | +; "CURLOPT_HTTPHEADER" "CURLOPT_NOPROGRESS" "CURLOPT_NOBODY" |
| 645 | +; "CURLOPT_FAILONERROR" "CURLOPT_UPLOAD" "CURLOPT_POST" |
| 646 | +; "CURLOPT_FTPLISTONLY" "CURLOPT_FTPAPPEND" "CURLOPT_NETRC" |
| 647 | +; "CURLOPT_FOLLOWLOCATION" "CURLOPT_FTPASCII" "CURLOPT_PUT" |
| 648 | +; "CURLOPT_MUTE" "CURLOPT_USERPWD" "CURLOPT_PROXYUSERPWD" |
| 649 | +; "CURLOPT_RANGE" "CURLOPT_TIMEOUT" "CURLOPT_POSTFIELDS" |
| 650 | +; "CURLOPT_REFERER" "CURLOPT_USERAGENT" "CURLOPT_FTPPORT" |
| 651 | +; "CURLOPT_LOW_SPEED_LIMIT" "CURLOPT_LOW_SPEED_TIME" |
| 652 | +; "CURLOPT_RESUME_FROM" "CURLOPT_COOKIE" "CURLOPT_SSLCERT" |
| 653 | +; "CURLOPT_SSLCERTPASSWD" "CURLOPT_WRITEHEADER" |
| 654 | +; "CURLOPT_COOKIEFILE" "CURLOPT_SSLVERSION" |
| 655 | +; "CURLOPT_TIMECONDITION" "CURLOPT_TIMEVALUE" |
| 656 | +; "CURLOPT_CUSTOMREQUEST" "CURLOPT_STDERR" "CURLOPT_TRANSFERTEXT" |
| 657 | +; "CURLOPT_RETURNTRANSFER" "CURLOPT_QUOTE" "CURLOPT_POSTQUOTE" |
| 658 | +; "CURLOPT_INTERFACE" "CURLOPT_KRB4LEVEL" |
| 659 | +; "CURLOPT_HTTPPROXYTUNNEL" "CURLOPT_FILETIME" |
| 660 | +; "CURLOPT_WRITEFUNCTION" "CURLOPT_READFUNCTION" |
| 661 | +; "CURLOPT_PASSWDFUNCTION" "CURLOPT_HEADERFUNCTION" |
| 662 | +; "CURLOPT_MAXREDIRS" "CURLOPT_MAXCONNECTS" "CURLOPT_CLOSEPOLICY" |
| 663 | +; "CURLOPT_FRESH_CONNECT" "CURLOPT_FORBID_REUSE" |
| 664 | +; "CURLOPT_RANDOM_FILE" "CURLOPT_EGDSOCKET" |
| 665 | +; "CURLOPT_CONNECTTIMEOUT" "CURLOPT_SSL_VERIFYPEER" |
| 666 | +; "CURLOPT_CAINFO" "CURLOPT_BINARYTRANSER" |
| 667 | +; "CURLCLOSEPOLICY_LEAST_RECENTLY_USED" "CURLCLOSEPOLICY_OLDEST" |
| 668 | +; "CURLINFO_EFFECTIVE_URL" "CURLINFO_HTTP_CODE" |
| 669 | +; "CURLINFO_HEADER_SIZE" "CURLINFO_REQUEST_SIZE" |
| 670 | +; "CURLINFO_TOTAL_TIME" "CURLINFO_NAMELOOKUP_TIME" |
| 671 | +; "CURLINFO_CONNECT_TIME" "CURLINFO_PRETRANSFER_TIME" |
| 672 | +; "CURLINFO_SIZE_UPLOAD" "CURLINFO_SIZE_DOWNLOAD" |
| 673 | +; "CURLINFO_SPEED_DOWNLOAD" "CURLINFO_SPEED_UPLOAD" |
| 674 | +; "CURLINFO_FILETIME" "CURLE_OK" "CURLE_UNSUPPORTED_PROTOCOL" |
| 675 | +; "CURLE_FAILED_INIT" "CURLE_URL_MALFORMAT" |
| 676 | +; "CURLE_URL_MALFORMAT_USER" "CURLE_COULDNT_RESOLVE_PROXY" |
| 677 | +; "CURLE_COULDNT_RESOLVE_HOST" "CURLE_COULDNT_CONNECT" |
| 678 | +; "CURLE_FTP_WEIRD_SERVER_REPLY" "CURLE_FTP_ACCESS_DENIED" |
| 679 | +; "CURLE_FTP_USER_PASSWORD_INCORRECT" |
| 680 | +; "CURLE_FTP_WEIRD_PASS_REPLY" "CURLE_FTP_WEIRD_USER_REPLY" |
| 681 | +; "CURLE_FTP_WEIRD_PASV_REPLY" "CURLE_FTP_WEIRD_227_FORMAT" |
| 682 | +; "CURLE_FTP_CANT_GET_HOST" "CURLE_FTP_CANT_RECONNECT" |
| 683 | +; "CURLE_FTP_COULDNT_SET_BINARY" "CURLE_PARTIAL_FILE" |
| 684 | +; "CURLE_FTP_COULDNT_RETR_FILE" "CURLE_FTP_WRITE_ERROR" |
| 685 | +; "CURLE_FTP_QUOTE_ERROR" "CURLE_HTTP_NOT_FOUND" |
| 686 | +; "CURLE_WRITE_ERROR" "CURLE_MALFORMAT_USER" |
| 687 | +; "CURLE_FTP_COULDNT_STOR_FILE" "CURLE_READ_ERROR" |
| 688 | +; "CURLE_OUT_OF_MEMORY" "CURLE_OPERATION_TIMEOUTED" |
| 689 | +; "CURLE_FTP_COULDNT_SET_ASCII" "CURLE_FTP_PORT_FAILED" |
| 690 | +; "CURLE_FTP_COULDNT_USE_REST" "CURLE_FTP_COULDNT_GET_SIZE" |
| 691 | +; "CURLE_HTTP_RANGE_ERROR" "CURLE_HTTP_POST_ERROR" |
| 692 | +; "CURLE_SSL_CONNECT_ERROR" "CURLE_FTP_BAD_DOWNLOAD_RESUME" |
| 693 | +; "CURLE_FILE_COULDNT_READ_FILE" "CURLE_LDAP_CANNOT_BIND" |
| 694 | +; "CURLE_LDAP_SEARCH_FAILED" "CURLE_LIBRARY_NOT_FOUND" |
| 695 | +; "CURLE_FUNCTION_NOT_FOUND" "CURLE_ABORTED_BY_CALLBACK" |
| 696 | +; "CURLE_BAD_FUNCTION_ARGUMENT" "CURLE_BAD_CALLING_ORDER" |
| 697 | +; "CURLE_HTTP_PORT_FAILED" "CURLE_BAD_PASSWORD_ENTERED" |
| 698 | +; "CURLE_TOO_MANY_REDIRECTS" "CURLE_UNKOWN_TELNET_OPTION" |
| 699 | +; "CURLE_TELNET_OPTION_SYNTAX" "CURLE_ALREADY_COMPLETE" |
| 700 | +; "DBX_MYSQL" "DBX_ODBC" "DBX_PGSQL" "DBX_MSSQL" "DBX_PERSISTENT" |
| 701 | +; "DBX_RESULT_INFO" "DBX_RESULT_INDEX" "DBX_RESULT_ASSOC" |
| 702 | +; "DBX_CMP_TEXT" "DBX_CMP_NUMBER" "XML_ELEMENT_NODE" |
| 703 | +; "XML_ATTRIBUTE_NODE" "XML_TEXT_NODE" "XML_CDATA_SECTION_NODE" |
| 704 | +; "XML_ENTITY_REF_NODE" "XML_ENTITY_NODE" "XML_PI_NODE" |
| 705 | +; "XML_COMMENT_NODE" "XML_DOCUMENT_NODE" "XML_DOCUMENT_TYPE_NODE" |
| 706 | +; "XML_DOCUMENT_FRAG_NODE" "XML_NOTATION_NODE" |
| 707 | +; "XML_HTML_DOCUMENT_NODE" "XML_DTD_NODE" "XML_ELEMENT_DECL_NODE" |
| 708 | +; "XML_ATTRIBUTE_DECL_NODE" "XML_ENTITY_DECL_NODE" |
| 709 | +; "XML_NAMESPACE_DECL_NODE" "XML_GLOBAL_NAMESPACE" |
| 710 | +; "XML_LOCAL_NAMESPACE" "XML_ATTRIBUTE_CDATA" "XML_ATTRIBUTE_ID" |
| 711 | +; "XML_ATTRIBUTE_IDREF" "XML_ATTRIBUTE_IDREFS" |
| 712 | +; "XML_ATTRIBUTE_ENTITY" "XML_ATTRIBUTE_NMTOKEN" |
| 713 | +; "XML_ATTRIBUTE_NMTOKENS" "XML_ATTRIBUTE_ENUMERATION" |
| 714 | +; "XML_ATTRIBUTE_NOTATION" "XPATH_UNDEFINED" "XPATH_NODESET" |
| 715 | +; "XPATH_BOOLEAN" "XPATH_NUMBER" "XPATH_STRING" "XPATH_POINT" |
| 716 | +; "XPATH_RANGE" "XPATH_LOCATIONSET" "XPATH_USERS" "FBSQL_ASSOC" |
| 717 | +; "FBSQL_NUM" "FBSQL_BOTH" "FDFValue" "FDFStatus" "FDFFile" |
| 718 | +; "FDFID" "FDFFf" "FDFSetFf" "FDFClearFf" "FDFFlags" "FDFSetF" |
| 719 | +; "FDFClrF" "FDFAP" "FDFAS" "FDFAction" "FDFAA" "FDFAPRef" |
| 720 | +; "FDFIF" "FDFEnter" "FDFExit" "FDFDown" "FDFUp" "FDFFormat" |
| 721 | +; "FDFValidate" "FDFKeystroke" "FDFCalculate" |
| 722 | +; "FRIBIDI_CHARSET_UTF8" "FRIBIDI_CHARSET_8859_6" |
| 723 | +; "FRIBIDI_CHARSET_8859_8" "FRIBIDI_CHARSET_CP1255" |
| 724 | +; "FRIBIDI_CHARSET_CP1256" "FRIBIDI_CHARSET_ISIRI_3342" |
| 725 | +; "FTP_ASCII" "FTP_BINARY" "FTP_IMAGE" "FTP_TEXT" "IMG_GIF" |
| 726 | +; "IMG_JPG" "IMG_JPEG" "IMG_PNG" "IMG_WBMP" "IMG_COLOR_TILED" |
| 727 | +; "IMG_COLOR_STYLED" "IMG_COLOR_BRUSHED" |
| 728 | +; "IMG_COLOR_STYLEDBRUSHED" "IMG_COLOR_TRANSPARENT" |
| 729 | +; "IMG_ARC_ROUNDED" "IMG_ARC_PIE" "IMG_ARC_CHORD" |
| 730 | +; "IMG_ARC_NOFILL" "IMG_ARC_EDGED" "GMP_ROUND_ZERO" |
| 731 | +; "GMP_ROUND_PLUSINF" "GMP_ROUND_MINUSINF" "HW_ATTR_LANG" |
| 732 | +; "HW_ATTR_NR" "HW_ATTR_NONE" "IIS_READ" "IIS_WRITE" |
| 733 | +; "IIS_EXECUTE" "IIS_SCRIPT" "IIS_ANONYMOUS" "IIS_BASIC" |
| 734 | +; "IIS_NTLM" "NIL" "OP_DEBUG" "OP_READONLY" "OP_ANONYMOUS" |
| 735 | +; "OP_SHORTCACHE" "OP_SILENT" "OP_PROTOTYPE" "OP_HALFOPEN" |
| 736 | +; "OP_EXPUNGE" "OP_SECURE" "CL_EXPUNGE" "FT_UID" "FT_PEEK" |
| 737 | +; "FT_NOT" "FT_INTERNAL" "FT_PREFETCHTEXT" "ST_UID" "ST_SILENT" |
| 738 | +; "ST_SET" "CP_UID" "CP_MOVE" "SE_UID" "SE_FREE" "SE_NOPREFETCH" |
| 739 | +; "SO_FREE" "SO_NOSERVER" "SA_MESSAGES" "SA_RECENT" "SA_UNSEEN" |
| 740 | +; "SA_UIDNEXT" "SA_UIDVALIDITY" "SA_ALL" "LATT_NOINFERIORS" |
| 741 | +; "LATT_NOSELECT" "LATT_MARKED" "LATT_UNMARKED" "SORTDATE" |
| 742 | +; "SORTARRIVAL" "SORTFROM" "SORTSUBJECT" "SORTTO" "SORTCC" |
| 743 | +; "SORTSIZE" "TYPETEXT" "TYPEMULTIPART" "TYPEMESSAGE" |
| 744 | +; "TYPEAPPLICATION" "TYPEAUDIO" "TYPEIMAGE" "TYPEVIDEO" |
| 745 | +; "TYPEOTHER" "ENC7BIT" "ENC8BIT" "ENCBINARY" "ENCBASE64" |
| 746 | +; "ENCQUOTEDPRINTABLE" "ENCOTHER" "INGRES_ASSOC" "INGRES_NUM" |
| 747 | +; "INGRES_BOTH" "IBASE_DEFAULT" "IBASE_TEXT" "IBASE_UNIXTIME" |
| 748 | +; "IBASE_READ" "IBASE_COMMITTED" "IBASE_CONSISTENCY" |
| 749 | +; "IBASE_NOWAIT" "IBASE_TIMESTAMP" "IBASE_DATE" "IBASE_TIME" |
| 750 | +; "LDAP_DEREF_NEVER" "LDAP_DEREF_SEARCHING" "LDAP_DEREF_FINDING" |
| 751 | +; "LDAP_DEREF_ALWAYS" "LDAP_OPT_DEREF" "LDAP_OPT_SIZELIMIT" |
| 752 | +; "LDAP_OPT_TIMELIMIT" "LDAP_OPT_PROTOCOL_VERSION" |
| 753 | +; "LDAP_OPT_ERROR_NUMBER" "LDAP_OPT_REFERRALS" "LDAP_OPT_RESTART" |
| 754 | +; "LDAP_OPT_HOST_NAME" "LDAP_OPT_ERROR_STRING" |
| 755 | +; "LDAP_OPT_MATCHED_DN" "LDAP_OPT_SERVER_CONTROLS" |
| 756 | +; "LDAP_OPT_CLIENT_CONTROLS" "GSLC_SSL_NO_AUTH" |
| 757 | +; "GSLC_SSL_ONEWAY_AUTH" "GSLC_SSL_TWOWAY_AUTH" "MCAL_SUNDAY" |
| 758 | +; "MCAL_MONDAY" "MCAL_TUESDAY" "MCAL_WEDNESDAY" "MCAL_THURSDAY" |
| 759 | +; "MCAL_FRIDAY" "MCAL_SATURDAY" "MCAL_JANUARY" "MCAL_FEBRUARY" |
| 760 | +; "MCAL_MARCH" "MCAL_APRIL" "MCAL_MAY" "MCAL_JUNE" "MCAL_JULY" |
| 761 | +; "MCAL_AUGUST" "MCAL_SEPTEMBER" "MCAL_OCTOBER" "MCAL_NOVEMBER" |
| 762 | +; "MCAL_RECUR_NONE" "MCAL_RECUR_DAILY" "MCAL_RECUR_WEEKLY" |
| 763 | +; "MCAL_RECUR_MONTHLY_MDAY" "MCAL_RECUR_MONTHLY_WDAY" |
| 764 | +; "MCAL_RECUR_YEARLY" "MCAL_M_SUNDAY" "MCAL_M_MONDAY" |
| 765 | +; "MCAL_M_TUESDAY" "MCAL_M_WEDNESDAY" "MCAL_M_THURSDAY" |
| 766 | +; "MCAL_M_FRIDAY" "MCAL_M_SATURDAY" "MCAL_M_WEEKDAYS" |
| 767 | +; "MCAL_M_WEEKEND" "MCAL_M_ALLDAYS" "MCRYPT_" "MCRYPT_" |
| 768 | +; "MCRYPT_ENCRYPT" "MCRYPT_DECRYPT" "MCRYPT_DEV_RANDOM" |
| 769 | +; "MCRYPT_DEV_URANDOM" "MCRYPT_RAND" "SWFBUTTON_HIT" |
| 770 | +; "SUNFUNCS_RET_STRING" "SUNFUNCS_RET_DOUBLE" |
| 771 | +; "SWFBUTTON_DOWN" "SWFBUTTON_OVER" "SWFBUTTON_UP" |
| 772 | +; "SWFBUTTON_MOUSEUPOUTSIDE" "SWFBUTTON_DRAGOVER" |
| 773 | +; "SWFBUTTON_DRAGOUT" "SWFBUTTON_MOUSEUP" "SWFBUTTON_MOUSEDOWN" |
| 774 | +; "SWFBUTTON_MOUSEOUT" "SWFBUTTON_MOUSEOVER" |
| 775 | +; "SWFFILL_RADIAL_GRADIENT" "SWFFILL_LINEAR_GRADIENT" |
| 776 | +; "SWFFILL_TILED_BITMAP" "SWFFILL_CLIPPED_BITMAP" |
| 777 | +; "SWFTEXTFIELD_HASLENGTH" "SWFTEXTFIELD_NOEDIT" |
| 778 | +; "SWFTEXTFIELD_PASSWORD" "SWFTEXTFIELD_MULTILINE" |
| 779 | +; "SWFTEXTFIELD_WORDWRAP" "SWFTEXTFIELD_DRAWBOX" |
| 780 | +; "SWFTEXTFIELD_NOSELECT" "SWFTEXTFIELD_HTML" |
| 781 | +; "SWFTEXTFIELD_ALIGN_LEFT" "SWFTEXTFIELD_ALIGN_RIGHT" |
| 782 | +; "SWFTEXTFIELD_ALIGN_CENTER" "SWFTEXTFIELD_ALIGN_JUSTIFY" |
| 783 | +; "UDM_FIELD_URLID" "UDM_FIELD_URL" "UDM_FIELD_CONTENT" |
| 784 | +; "UDM_FIELD_TITLE" "UDM_FIELD_KEYWORDS" "UDM_FIELD_DESC" |
| 785 | +; "UDM_FIELD_DESCRIPTION" "UDM_FIELD_TEXT" "UDM_FIELD_SIZE" |
| 786 | +; "UDM_FIELD_RATING" "UDM_FIELD_SCORE" "UDM_FIELD_MODIFIED" |
| 787 | +; "UDM_FIELD_ORDER" "UDM_FIELD_CRC" "UDM_FIELD_CATEGORY" |
| 788 | +; "UDM_PARAM_PAGE_SIZE" "UDM_PARAM_PAGE_NUM" |
| 789 | +; "UDM_PARAM_SEARCH_MODE" "UDM_PARAM_CACHE_MODE" |
| 790 | +; "UDM_PARAM_TRACK_MODE" "UDM_PARAM_PHRASE_MODE" |
| 791 | +; "UDM_PARAM_CHARSET" "UDM_PARAM_STOPTABLE" |
| 792 | +; "UDM_PARAM_STOP_TABLE" "UDM_PARAM_STOPFILE" |
| 793 | +; "UDM_PARAM_STOP_FILE" "UDM_PARAM_WEIGHT_FACTOR" |
| 794 | +; "UDM_PARAM_WORD_MATCH" "UDM_PARAM_MAX_WORD_LEN" |
| 795 | +; "UDM_PARAM_MAX_WORDLEN" "UDM_PARAM_MIN_WORD_LEN" |
| 796 | +; "UDM_PARAM_MIN_WORDLEN" "UDM_PARAM_ISPELL_PREFIXES" |
| 797 | +; "UDM_PARAM_ISPELL_PREFIX" "UDM_PARAM_PREFIXES" |
| 798 | +; "UDM_PARAM_PREFIX" "UDM_PARAM_CROSS_WORDS" |
| 799 | +; "UDM_PARAM_CROSSWORDS" "UDM_LIMIT_CAT" "UDM_LIMIT_URL" |
| 800 | +; "UDM_LIMIT_TAG" "UDM_LIMIT_LANG" "UDM_LIMIT_DATE" |
| 801 | +; "UDM_PARAM_FOUND" "UDM_PARAM_NUM_ROWS" "UDM_PARAM_WORDINFO" |
| 802 | +; "UDM_PARAM_WORD_INFO" "UDM_PARAM_SEARCHTIME" |
| 803 | +; "UDM_PARAM_SEARCH_TIME" "UDM_PARAM_FIRST_DOC" |
| 804 | +; "UDM_PARAM_LAST_DOC" "UDM_MODE_ALL" "UDM_MODE_ANY" |
| 805 | +; "UDM_MODE_BOOL" "UDM_MODE_PHRASE" "UDM_CACHE_ENABLED" |
| 806 | +; "UDM_CACHE_DISABLED" "UDM_TRACK_ENABLED" "UDM_TRACK_DISABLED" |
| 807 | +; "UDM_PHRASE_ENABLED" "UDM_PHRASE_DISABLED" |
| 808 | +; "UDM_CROSS_WORDS_ENABLED" "UDM_CROSSWORDS_ENABLED" |
| 809 | +; "UDM_CROSS_WORDS_DISABLED" "UDM_CROSSWORDS_DISABLED" |
| 810 | +; "UDM_PREFIXES_ENABLED" "UDM_PREFIX_ENABLED" |
| 811 | +; "UDM_ISPELL_PREFIXES_ENABLED" "UDM_ISPELL_PREFIX_ENABLED" |
| 812 | +; "UDM_PREFIXES_DISABLED" "UDM_PREFIX_DISABLED" |
| 813 | +; "UDM_ISPELL_PREFIXES_DISABLED" "UDM_ISPELL_PREFIX_DISABLED" |
| 814 | +; "UDM_ISPELL_TYPE_AFFIX" "UDM_ISPELL_TYPE_SPELL" |
| 815 | +; "UDM_ISPELL_TYPE_DB" "UDM_ISPELL_TYPE_SERVER" "UDM_MATCH_WORD" |
| 816 | +; "UDM_MATCH_BEGIN" "UDM_MATCH_SUBSTR" "UDM_MATCH_END" |
| 817 | +; "MSQL_ASSOC" "MSQL_NUM" "MSQL_BOTH" "MYSQL_ASSOC" "MYSQL_NUM" |
| 818 | +; "MYSQL_BOTH" "MYSQL_USE_RESULT" "MYSQL_STORE_RESULT" |
| 819 | +; "OCI_DEFAULT" "OCI_DESCRIBE_ONLY" "OCI_COMMIT_ON_SUCCESS" |
| 820 | +; "OCI_EXACT_FETCH" "SQLT_BFILEE" "SQLT_CFILEE" "SQLT_CLOB" |
| 821 | +; "SQLT_BLOB" "SQLT_RDD" "OCI_B_SQLT_NTY" "OCI_SYSDATE" |
| 822 | +; "OCI_B_BFILE" "OCI_B_CFILEE" "OCI_B_CLOB" "OCI_B_BLOB" |
| 823 | +; "OCI_B_ROWID" "OCI_B_CURSOR" "OCI_B_BIN" "OCI_ASSOC" "OCI_NUM" |
| 824 | +; "OCI_BOTH" "OCI_RETURN_NULLS" "OCI_RETURN_LOBS" |
| 825 | +; "OCI_DTYPE_FILE" "OCI_DTYPE_LOB" "OCI_DTYPE_ROWID" "OCI_D_FILE" |
| 826 | +; "OCI_D_LOB" "OCI_D_ROWID" "ODBC_TYPE" "ODBC_BINMODE_PASSTHRU" |
| 827 | +; "ODBC_BINMODE_RETURN" "ODBC_BINMODE_CONVERT" "SQL_ODBC_CURSORS" |
| 828 | +; "SQL_CUR_USE_DRIVER" "SQL_CUR_USE_IF_NEEDED" "SQL_CUR_USE_ODBC" |
| 829 | +; "SQL_CONCURRENCY" "SQL_CONCUR_READ_ONLY" "SQL_CONCUR_LOCK" |
| 830 | +; "SQL_CONCUR_ROWVER" "SQL_CONCUR_VALUES" "SQL_CURSOR_TYPE" |
| 831 | +; "SQL_CURSOR_FORWARD_ONLY" "SQL_CURSOR_KEYSET_DRIVEN" |
| 832 | +; "SQL_CURSOR_DYNAMIC" "SQL_CURSOR_STATIC" "SQL_KEYSET_SIZE" |
| 833 | +; "SQL_CHAR" "SQL_VARCHAR" "SQL_LONGVARCHAR" "SQL_DECIMAL" |
| 834 | +; "SQL_NUMERIC" "SQL_BIT" "SQL_TINYINT" "SQL_SMALLINT" |
| 835 | +; "SQL_INTEGER" "SQL_BIGINT" "SQL_REAL" "SQL_FLOAT" "SQL_DOUBLE" |
| 836 | +; "SQL_BINARY" "SQL_VARBINARY" "SQL_LONGVARBINARY" "SQL_DATE" |
| 837 | +; "SQL_TIME" "SQL_TIMESTAMP" "SQL_TYPE_DATE" "SQL_TYPE_TIME" |
| 838 | +; "SQL_TYPE_TIMESTAMP" "SQL_BEST_ROWID" "SQL_ROWVER" |
| 839 | +; "SQL_SCOPE_CURROW" "SQL_SCOPE_TRANSACTION" "SQL_SCOPE_SESSION" |
| 840 | +; "SQL_NO_NULLS" "SQL_NULLABLE" "SQL_INDEX_UNIQUE" |
| 841 | +; "SQL_INDEX_ALL" "SQL_ENSURE" "SQL_QUICK" |
| 842 | +; "X509_PURPOSE_SSL_CLIENT" "X509_PURPOSE_SSL_SERVER" |
| 843 | +; "X509_PURPOSE_NS_SSL_SERVER" "X509_PURPOSE_SMIME_SIGN" |
| 844 | +; "X509_PURPOSE_SMIME_ENCRYPT" "X509_PURPOSE_CRL_SIGN" |
| 845 | +; "X509_PURPOSE_ANY" "PKCS7_DETACHED" "PKCS7_TEXT" |
| 846 | +; "PKCS7_NOINTERN" "PKCS7_NOVERIFY" "PKCS7_NOCHAIN" |
| 847 | +; "PKCS7_NOCERTS" "PKCS7_NOATTR" "PKCS7_BINARY" "PKCS7_NOSIGS" |
| 848 | +; "OPENSSL_PKCS1_PADDING" "OPENSSL_SSLV23_PADDING" |
| 849 | +; "OPENSSL_NO_PADDING" "OPENSSL_PKCS1_OAEP_PADDING" |
| 850 | +; "ORA_BIND_INOUT" "ORA_BIND_IN" "ORA_BIND_OUT" |
| 851 | +; "ORA_FETCHINTO_ASSOC" "ORA_FETCHINTO_NULLS" |
| 852 | +; "PREG_PATTERN_ORDER" "PREG_SET_ORDER" "PREG_SPLIT_NO_EMPTY" |
| 853 | +; "PREG_SPLIT_DELIM_CAPTURE" |
| 854 | +; "PGSQL_ASSOC" "PGSQL_NUM" "PGSQL_BOTH" |
| 855 | +; "PRINTER_COPIES" "PRINTER_MODE" "PRINTER_TITLE" |
| 856 | +; "PRINTER_DEVICENAME" "PRINTER_DRIVERVERSION" |
| 857 | +; "PRINTER_RESOLUTION_Y" "PRINTER_RESOLUTION_X" "PRINTER_SCALE" |
| 858 | +; "PRINTER_BACKGROUND_COLOR" "PRINTER_PAPER_LENGTH" |
| 859 | +; "PRINTER_PAPER_WIDTH" "PRINTER_PAPER_FORMAT" |
| 860 | +; "PRINTER_FORMAT_CUSTOM" "PRINTER_FORMAT_LETTER" |
| 861 | +; "PRINTER_FORMAT_LEGAL" "PRINTER_FORMAT_A3" "PRINTER_FORMAT_A4" |
| 862 | +; "PRINTER_FORMAT_A5" "PRINTER_FORMAT_B4" "PRINTER_FORMAT_B5" |
| 863 | +; "PRINTER_FORMAT_FOLIO" "PRINTER_ORIENTATION" |
| 864 | +; "PRINTER_ORIENTATION_PORTRAIT" "PRINTER_ORIENTATION_LANDSCAPE" |
| 865 | +; "PRINTER_TEXT_COLOR" "PRINTER_TEXT_ALIGN" "PRINTER_TA_BASELINE" |
| 866 | +; "PRINTER_TA_BOTTOM" "PRINTER_TA_TOP" "PRINTER_TA_CENTER" |
| 867 | +; "PRINTER_TA_LEFT" "PRINTER_TA_RIGHT" "PRINTER_PEN_SOLID" |
| 868 | +; "PRINTER_PEN_DASH" "PRINTER_PEN_DOT" "PRINTER_PEN_DASHDOT" |
| 869 | +; "PRINTER_PEN_DASHDOTDOT" "PRINTER_PEN_INVISIBLE" |
| 870 | +; "PRINTER_BRUSH_SOLID" "PRINTER_BRUSH_CUSTOM" |
| 871 | +; "PRINTER_BRUSH_DIAGONAL" "PRINTER_BRUSH_CROSS" |
| 872 | +; "PRINTER_BRUSH_DIAGCROSS" "PRINTER_BRUSH_FDIAGONAL" |
| 873 | +; "PRINTER_BRUSH_HORIZONTAL" "PRINTER_BRUSH_VERTICAL" |
| 874 | +; "PRINTER_FW_THIN" "PRINTER_FW_ULTRALIGHT" "PRINTER_FW_LIGHT" |
| 875 | +; "PRINTER_FW_NORMAL" "PRINTER_FW_MEDIUM" "PRINTER_FW_BOLD" |
| 876 | +; "PRINTER_FW_ULTRABOLD" "PRINTER_FW_HEAVY" "PRINTER_ENUM_LOCAL" |
| 877 | +; "PRINTER_ENUM_NAME" "PRINTER_ENUM_SHARED" |
| 878 | +; "PRINTER_ENUM_DEFAULT" "PRINTER_ENUM_CONNECTIONS" |
| 879 | +; "PRINTER_ENUM_NETWORK" "PRINTER_ENUM_REMOTE" "PSPELL_FAST" |
| 880 | +; "PSPELL_NORMAL" "PSPELL_BAD_SPELLERS" "PSPELL_RUN_TOGETHER" |
| 881 | +; "SID" "SID" "AF_UNIX" "AF_INET" "SOCK_STREAM" "SOCK_DGRAM" |
| 882 | +; "SOCK_RAW" "SOCK_SEQPACKET" "SOCK_RDM" "MSG_OOB" "MSG_WAITALL" |
| 883 | +; "MSG_PEEK" "MSG_DONTROUTE" "SO_DEBUG" "SO_REUSEADDR" |
| 884 | +; "SO_KEEPALIVE" "SO_DONTROUTE" "SO_LINGER" "SO_BROADCAST" |
| 885 | +; "SO_OOBINLINE" "SO_SNDBUF" "SO_RCVBUF" "SO_SNDLOWAT" |
| 886 | +; "SO_RCVLOWAT" "SO_SNDTIMEO" "SO_RCVTIMEO" "SO_TYPE" "SO_ERROR" |
| 887 | +; "SOL_SOCKET" "PHP_NORMAL_READ" "PHP_BINARY_READ" |
| 888 | +; "PHP_SYSTEM_READ" "SOL_TCP" "SOL_UDP" "MOD_COLOR" "MOD_MATRIX" |
| 889 | +; "TYPE_PUSHBUTTON" "TYPE_MENUBUTTON" "BSHitTest" "BSDown" |
| 890 | +; "BSOver" "BSUp" "OverDowntoIdle" "IdletoOverDown" |
| 891 | +; "OutDowntoIdle" "OutDowntoOverDown" "OverDowntoOutDown" |
| 892 | +; "OverUptoOverDown" "OverUptoIdle" "IdletoOverUp" "ButtonEnter" |
| 893 | +; "ButtonExit" "MenuEnter" "MenuExit" "XML_ERROR_NONE" |
| 894 | +; "XML_ERROR_NO_MEMORY" "XML_ERROR_SYNTAX" |
| 895 | +; "XML_ERROR_NO_ELEMENTS" "XML_ERROR_INVALID_TOKEN" |
| 896 | +; "XML_ERROR_UNCLOSED_TOKEN" "XML_ERROR_PARTIAL_CHAR" |
| 897 | +; "XML_ERROR_TAG_MISMATCH" "XML_ERROR_DUPLICATE_ATTRIBUTE" |
| 898 | +; "XML_ERROR_JUNK_AFTER_DOC_ELEMENT" "XML_ERROR_PARAM_ENTITY_REF" |
| 899 | +; "XML_ERROR_UNDEFINED_ENTITY" "XML_ERROR_RECURSIVE_ENTITY_REF" |
| 900 | +; "XML_ERROR_ASYNC_ENTITY" "XML_ERROR_BAD_CHAR_REF" |
| 901 | +; "XML_ERROR_BINARY_ENTITY_REF" |
| 902 | +; "XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF" |
| 903 | +; "XML_ERROR_MISPLACED_XML_PI" "XML_ERROR_UNKNOWN_ENCODING" |
| 904 | +; "XML_ERROR_INCORRECT_ENCODING" |
| 905 | +; "XML_ERROR_UNCLOSED_CDATA_SECTION" |
| 906 | +; "XML_ERROR_EXTERNAL_ENTITY_HANDLING" "XML_OPTION_CASE_FOLDING" |
| 907 | +; "XML_OPTION_TARGET_ENCODING" "XML_OPTION_SKIP_TAGSTART" |
| 908 | +; "XML_OPTION_SKIP_WHITE" "YPERR_BADARGS" "YPERR_BADDB" |
| 909 | +; "YPERR_BUSY" "YPERR_DOMAIN" "YPERR_KEY" "YPERR_MAP" |
| 910 | +; "YPERR_NODOM" "YPERR_NOMORE" "YPERR_PMAP" "YPERR_RESRC" |
| 911 | +; "YPERR_RPC" "YPERR_YPBIND" "YPERR_YPERR" "YPERR_YPSERV" |
| 912 | +; "YPERR_VERS" "FORCE_GZIP" "FORCE_DEFLATE" |
| 913 | + |
| 914 | + ;; PEAR constants |
| 915 | +; "PEAR_ERROR_RETURN" "PEAR_ERROR_PRINT" "PEAR_ERROR_TRIGGER" |
| 916 | +; "PEAR_ERROR_DIE" "PEAR_ERROR_CALLBACK" "OS_WINDOWS" "OS_UNIX" |
| 917 | +; "PEAR_OS" "DB_OK" "DB_ERROR" "DB_ERROR_SYNTAX" |
| 918 | +; "DB_ERROR_CONSTRAINT" "DB_ERROR_NOT_FOUND" |
| 919 | +; "DB_ERROR_ALREADY_EXISTS" "DB_ERROR_UNSUPPORTED" |
| 920 | +; "DB_ERROR_MISMATCH" "DB_ERROR_INVALID" "DB_ERROR_NOT_CAPABLE" |
| 921 | +; "DB_ERROR_TRUNCATED" "DB_ERROR_INVALID_NUMBER" |
| 922 | +; "DB_ERROR_INVALID_DATE" "DB_ERROR_DIVZERO" |
| 923 | +; "DB_ERROR_NODBSELECTED" "DB_ERROR_CANNOT_CREATE" |
| 924 | +; "DB_ERROR_CANNOT_DELETE" "DB_ERROR_CANNOT_DROP" |
| 925 | +; "DB_ERROR_NOSUCHTABLE" "DB_ERROR_NOSUCHFIELD" |
| 926 | +; "DB_ERROR_NEED_MORE_DATA" "DB_ERROR_NOT_LOCKED" |
| 927 | +; "DB_ERROR_VALUE_COUNT_ON_ROW" "DB_ERROR_INVALID_DSN" |
| 928 | +; "DB_ERROR_CONNECT_FAILED" "DB_WARNING" "DB_WARNING_READ_ONLY" |
| 929 | +; "DB_PARAM_SCALAR" "DB_PARAM_OPAQUE" "DB_BINMODE_PASSTHRU" |
| 930 | +; "DB_BINMODE_RETURN" "DB_BINMODE_CONVERT" "DB_FETCHMODE_DEFAULT" |
| 931 | +; "DB_FETCHMODE_ORDERED" "DB_FETCHMODE_ASSOC" |
| 932 | +; "DB_FETCHMODE_FLIPPED" "DB_GETMODE_ORDERED" "DB_GETMODE_ASSOC" |
| 933 | +; "DB_GETMODE_FLIPPED" "DB_TABLEINFO_ORDER" |
| 934 | +; "DB_TABLEINFO_ORDERTABLE" "DB_TABLEINFO_FULL" |
| 935 | + |
| 936 | + ))) |
| 937 | + "PHP constants.") |
| 938 | + |
| 939 | +(defconst php-keywords |
| 940 | + (eval-when-compile |
| 941 | + (regexp-opt |
| 942 | + ;; "class", "new" and "extends" get special treatment |
| 943 | + ;; "case" and "default" get special treatment elsewhere |
| 944 | + '("and" "as" "break" "continue" "declare" "do" "echo" "else" "elseif" |
| 945 | + "endfor" "endforeach" "endif" "endswitch" "endwhile" "exit" |
| 946 | + "extends" "for" "foreach" "global" "if" "include" "include_once" |
| 947 | + "next" "or" "require" "require_once" "return" "static" "switch" |
| 948 | + "then" "var" "while" "xor" "throw" "catch" "try" |
| 949 | + "instanceof" "catch all" "finally"))) |
| 950 | + "PHP keywords.") |
| 951 | + |
| 952 | +(defconst php-identifier |
| 953 | + (eval-when-compile |
| 954 | + '"[a-zA-Z\_\x7f-\xff][a-zA-Z0-9\_\x7f-\xff]*") |
| 955 | + "Characters in a PHP identifier.") |
| 956 | + |
| 957 | +(defconst php-types |
| 958 | + (eval-when-compile |
| 959 | + (regexp-opt '("array" "bool" "boolean" "char" "const" "double" "float" |
| 960 | + "int" "integer" "long" "mixed" "object" "real" |
| 961 | + "string"))) |
| 962 | + "PHP types.") |
| 963 | + |
| 964 | +(defconst php-superglobals |
| 965 | + (eval-when-compile |
| 966 | + (regexp-opt '("_GET" "_POST" "_COOKIE" "_SESSION" "_ENV" "GLOBALS" |
| 967 | + "_SERVER" "_FILES" "_REQUEST"))) |
| 968 | + "PHP superglobal variables.") |
| 969 | + |
| 970 | +;; Set up font locking |
| 971 | +(defconst php-font-lock-keywords-1 |
| 972 | + (list |
| 973 | + ;; Fontify constants |
| 974 | + (cons |
| 975 | + (concat "[^_$]?\\<\\(" php-constants "\\)\\>[^_]?") |
| 976 | + '(1 font-lock-constant-face)) |
| 977 | + |
| 978 | + ;; Fontify keywords |
| 979 | + (cons |
| 980 | + (concat "[^_$]?\\<\\(" php-keywords "\\)\\>[^_]?") |
| 981 | + '(1 font-lock-keyword-face)) |
| 982 | + |
| 983 | + ;; Fontify keywords and targets, and case default tags. |
| 984 | + (list "\\<\\(break\\|case\\|continue\\)\\>\\s-+\\(-?\\sw+\\)?" |
| 985 | + '(1 font-lock-keyword-face) '(2 font-lock-constant-face t t)) |
| 986 | + ;; This must come after the one for keywords and targets. |
| 987 | + '(":" ("^\\s-+\\(\\sw+\\)\\s-+\\s-+$" |
| 988 | + (beginning-of-line) (end-of-line) |
| 989 | + (1 font-lock-constant-face))) |
| 990 | + |
| 991 | + ;; treat 'print' as keyword only when not used like a function name |
| 992 | + '("\\<print\\s-*(" . php-default-face) |
| 993 | + '("\\<print\\>" . font-lock-keyword-face) |
| 994 | + |
| 995 | + ;; Fontify PHP tag |
| 996 | + (cons php-tags-key font-lock-preprocessor-face) |
| 997 | + |
| 998 | + ;; Fontify ASP-style tag |
| 999 | + '("<\\%\\(=\\)?" . font-lock-preprocessor-face) |
| 1000 | + '("\\%>" . font-lock-preprocessor-face) |
| 1001 | + |
| 1002 | + ) |
| 1003 | + "Subdued level highlighting for PHP mode.") |
| 1004 | + |
| 1005 | +(defconst php-font-lock-keywords-2 |
| 1006 | + (append |
| 1007 | + php-font-lock-keywords-1 |
| 1008 | + (list |
| 1009 | + |
| 1010 | + ;; class declaration |
| 1011 | + '("\\<\\(class\\|interface\\)\\s-+\\(\\sw+\\)?" |
| 1012 | + (1 font-lock-keyword-face) (2 font-lock-type-face nil t)) |
| 1013 | + ;; handle several words specially, to include following word, |
| 1014 | + ;; thereby excluding it from unknown-symbol checks later |
| 1015 | + ;; FIX to handle implementing multiple |
| 1016 | + ;; currently breaks on "class Foo implements Bar, Baz" |
| 1017 | + '("\\<\\(new\\|extends\\|implements\\)\\s-+\\$?\\(\\sw+\\)" |
| 1018 | + (1 font-lock-keyword-face) (2 font-lock-type-face)) |
| 1019 | + |
| 1020 | + ;; function declaration |
| 1021 | + '("\\<\\(function\\)\\s-+&?\\(\\sw+\\)\\s-*(" |
| 1022 | + (1 font-lock-keyword-face) |
| 1023 | + (2 font-lock-function-name-face nil t)) |
| 1024 | + |
| 1025 | + ;; class hierarchy |
| 1026 | + '("\\<\\(self\\|parent\\)\\>" (1 font-lock-constant-face nil nil)) |
| 1027 | + |
| 1028 | + ;; method and variable features |
| 1029 | + '("\\<\\(private\\|protected\\|public\\)\\s-+\\$?\\sw+" |
| 1030 | + (1 font-lock-keyword-face)) |
| 1031 | + |
| 1032 | + ;; method features |
| 1033 | + '("^\\s-*\\(abstract\\|static\\|final\\)\\s-+\\$?\\sw+" |
| 1034 | + (1 font-lock-keyword-face)) |
| 1035 | + |
| 1036 | + ;; variable features |
| 1037 | + '("^\\s-*\\(static\\|const\\)\\s-+\\$?\\sw+" |
| 1038 | + (1 font-lock-keyword-face)) |
| 1039 | + )) |
| 1040 | + "Medium level highlighting for PHP mode.") |
| 1041 | + |
| 1042 | +(defconst php-font-lock-keywords-3 |
| 1043 | + (append |
| 1044 | + php-font-lock-keywords-2 |
| 1045 | + (list |
| 1046 | + |
| 1047 | + ;; <word> or </word> for HTML |
| 1048 | + ;;'("</?\\sw+[^> ]*>" . font-lock-constant-face) |
| 1049 | + ;;'("</?\\sw+[^>]*" . font-lock-constant-face) |
| 1050 | + ;;'("<!DOCTYPE" . font-lock-constant-face) |
| 1051 | + '("</?[a-z!:]+" . font-lock-constant-face) |
| 1052 | + |
| 1053 | + ;; HTML > |
| 1054 | + '("<[^>]*\\(>\\)" (1 font-lock-constant-face)) |
| 1055 | + |
| 1056 | + ;; HTML tags |
| 1057 | + '("\\(<[a-z]+\\)[[:space:]]+\\([a-z:]+=\\)[^>]*?" (1 font-lock-constant-face) (2 font-lock-constant-face) ) |
| 1058 | + '("\"[[:space:]]+\\([a-z:]+=\\)" (1 font-lock-constant-face)) |
| 1059 | + |
| 1060 | + ;; HTML entities |
| 1061 | + ;;'("&\\w+;" . font-lock-variable-name-face) |
| 1062 | + |
| 1063 | + ;; warn about '$' immediately after -> |
| 1064 | + '("\\$\\sw+->\\s-*\\(\\$\\)\\(\\sw+\\)" |
| 1065 | + (1 font-lock-warning-face) (2 php-default-face)) |
| 1066 | + |
| 1067 | + ;; warn about $word.word -- it could be a valid concatenation, |
| 1068 | + ;; but without any spaces we'll assume $word->word was meant. |
| 1069 | + '("\\$\\sw+\\(\\.\\)\\sw" |
| 1070 | + 1 font-lock-warning-face) |
| 1071 | + |
| 1072 | + ;; Warn about ==> instead of => |
| 1073 | + '("==+>" . font-lock-warning-face) |
| 1074 | + |
| 1075 | + ;; exclude casts from bare-word treatment (may contain spaces) |
| 1076 | + `(,(concat "(\\s-*\\(" php-types "\\)\\s-*)") |
| 1077 | + 1 font-lock-type-face) |
| 1078 | + |
| 1079 | + ;; PHP5: function declarations may contain classes as parameters type |
| 1080 | + `(,(concat "[(,]\\s-*\\(\\sw+\\)\\s-+&?\\$\\sw+\\>") |
| 1081 | + 1 font-lock-type-face) |
| 1082 | + |
| 1083 | + ;; Fontify variables and function calls |
| 1084 | + '("\\$\\(this\\|that\\)\\W" (1 font-lock-constant-face nil nil)) |
| 1085 | + `(,(concat "\\$\\(" php-superglobals "\\)\\W") |
| 1086 | + (1 font-lock-constant-face nil nil)) ;; $_GET & co |
| 1087 | + '("\\$\\(\\sw+\\)" (1 font-lock-variable-name-face)) ;; $variable |
| 1088 | + '("->\\(\\sw+\\)" (1 font-lock-variable-name-face t t)) ;; ->variable |
| 1089 | + '("->\\(\\sw+\\)\\s-*(" . (1 php-default-face t t)) ;; ->function_call |
| 1090 | + '("\\(\\sw+\\)::\\sw+\\s-*(?" . (1 font-lock-type-face)) ;; class::member |
| 1091 | + '("::\\(\\sw+\\>[^(]\\)" . (1 php-default-face)) ;; class::constant |
| 1092 | + '("\\<\\sw+\\s-*[[(]" . php-default-face) ;; word( or word[ |
| 1093 | + '("\\<[0-9]+" . php-default-face) ;; number (also matches word) |
| 1094 | + |
| 1095 | + ;; Warn on any words not already fontified |
| 1096 | + '("\\<\\sw+\\>" . font-lock-warning-face) |
| 1097 | + |
| 1098 | + )) |
| 1099 | + "Gauchy level highlighting for PHP mode.") |
| 1100 | + |
| 1101 | +(provide 'php-mode) |
| 1102 | + |
| 1103 | +;;; php-mode.el ends here |
0 commit comments