summaryrefslogtreecommitdiff
path: root/.emacs.d/lisp/php-mode.el
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d/lisp/php-mode.el')
-rw-r--r--.emacs.d/lisp/php-mode.el63
1 files changed, 37 insertions, 26 deletions
diff --git a/.emacs.d/lisp/php-mode.el b/.emacs.d/lisp/php-mode.el
index 5db6f23..4284d43 100644
--- a/.emacs.d/lisp/php-mode.el
+++ b/.emacs.d/lisp/php-mode.el
@@ -6,13 +6,13 @@
6 6
7;; Author: Eric James Michael Ritz 7;; Author: Eric James Michael Ritz
8;; URL: https://github.com/ejmr/php-mode 8;; URL: https://github.com/ejmr/php-mode
9;; Version: 1.17.0 9;; Version: 1.18.0
10;; Package-Requires: ((emacs "24") (cl-lib "0.5")) 10;; Package-Requires: ((emacs "24") (cl-lib "0.5"))
11 11
12(defconst php-mode-version-number "1.17.0" 12(defconst php-mode-version-number "1.18.0"
13 "PHP Mode version number.") 13 "PHP Mode version number.")
14 14
15(defconst php-mode-modified "2016-08-31" 15(defconst php-mode-modified "2017-01-27"
16 "PHP Mode build date.") 16 "PHP Mode build date.")
17 17
18;;; License 18;;; License
@@ -603,7 +603,6 @@ but only if the setting is enabled"
603(c-add-style 603(c-add-style
604 "php" 604 "php"
605 '((c-basic-offset . 4) 605 '((c-basic-offset . 4)
606 (c-doc-comment-style . javadoc)
607 (c-offsets-alist . ((arglist-close . php-lineup-arglist-close) 606 (c-offsets-alist . ((arglist-close . php-lineup-arglist-close)
608 (arglist-cont . (first php-lineup-cascaded-calls 0)) 607 (arglist-cont . (first php-lineup-cascaded-calls 0))
609 (arglist-cont-nonempty . (first php-lineup-cascaded-calls c-lineup-arglist)) 608 (arglist-cont-nonempty . (first php-lineup-cascaded-calls c-lineup-arglist))
@@ -1334,6 +1333,39 @@ a completion list."
1334 (interactive) 1333 (interactive)
1335 (browse-url php-manual-url)) 1334 (browse-url php-manual-url))
1336 1335
1336(defconst php-phpdoc-type-keywords
1337 (list "string" "integer" "int" "boolean" "bool" "float"
1338 "double" "object" "mixed" "array" "resource" "$this"
1339 "void" "null" "false" "true" "self" "static"
1340 "callable" "iterable" "number"))
1341
1342(defconst php-phpdoc-type-tags
1343 (list "param" "property" "property-read" "property-write" "return" "var"))
1344
1345(defconst php-phpdoc-font-lock-doc-comments
1346 `(("{@[-[:alpha:]]+\\s-\\([^}]*\\)}" ; "{@foo ...}" markup.
1347 (0 'php-annotations-annotation-face prepend nil)
1348 (1 'font-lock-string-face prepend nil))
1349 (,(rx "$" (in "A-Za-z_") (* (in "0-9A-Za-z_")))
1350 0 font-lock-variable-name-face prepend nil)
1351 (,(concat "\\s-@" (regexp-opt php-phpdoc-type-tags) "\\s-+"
1352 "\\(" (rx (+ (? "\\") (+ (in "0-9A-Za-z")) (? "[]") (? "|"))) "\\)+"
1353 "\\(?:\\s-\\|$\\)")
1354 1 font-lock-string-face prepend nil)
1355 (,(concat "\\(?:|\\|\\s-\\)\\("
1356 (regexp-opt php-phpdoc-type-keywords)
1357 "\\)")
1358 1 font-lock-type-face prepend nil)
1359 ("https?://[^\n\t ]+"
1360 0 'link prepend nil)
1361 ("^\\(?:/\\*\\)?\\(?:\\s \\|\\*\\)*\\(@[[:alpha:]][-[:alpha:]\\]*\\)" ; "@foo ..." markup.
1362 1 'php-annotations-annotation-face prepend nil)))
1363
1364(defvar php-phpdoc-font-lock-keywords
1365 `((,(lambda (limit)
1366 (c-font-lock-doc-comments "/\\*\\*" limit
1367 php-phpdoc-font-lock-doc-comments)))))
1368
1337(defconst php-font-lock-keywords-1 (c-lang-const c-matchers-1 php) 1369(defconst php-font-lock-keywords-1 (c-lang-const c-matchers-1 php)
1338 "Basic highlighting for PHP mode.") 1370 "Basic highlighting for PHP mode.")
1339 1371
@@ -1342,6 +1374,7 @@ a completion list."
1342 1374
1343(defconst php-font-lock-keywords-3 1375(defconst php-font-lock-keywords-3
1344 (append 1376 (append
1377 php-phpdoc-font-lock-keywords
1345 ;; php-mode patterns *before* cc-mode: 1378 ;; php-mode patterns *before* cc-mode:
1346 ;; only add patterns here if you want to prevent cc-mode from applying 1379 ;; only add patterns here if you want to prevent cc-mode from applying
1347 ;; a different face. 1380 ;; a different face.
@@ -1463,25 +1496,6 @@ The output will appear in the buffer *PHP*."
1463(defface php-annotations-annotation-face '((t . (:inherit font-lock-constant-face))) 1496(defface php-annotations-annotation-face '((t . (:inherit font-lock-constant-face)))
1464 "Face used to highlight annotations.") 1497 "Face used to highlight annotations.")
1465 1498
1466(defconst php-annotations-re "\\(\\s-\\|{\\)\\(@[-\\[:alpha:]]+\\)")
1467
1468(defmacro php-annotations-inside-comment-p (pos)
1469 "Return non-nil if POS is inside a comment."
1470 `(or (eq (get-char-property ,pos 'face) 'font-lock-comment-face)
1471 (eq (get-char-property ,pos 'face) 'font-lock-comment-delimiter-face)))
1472
1473(defun php-annotations-font-lock-find-annotation (limit)
1474 (let ((match
1475 (catch 'match
1476 (save-match-data
1477 (while (re-search-forward php-annotations-re limit t)
1478 (when (php-annotations-inside-comment-p (match-beginning 0))
1479 (goto-char (match-end 0))
1480 (throw 'match (match-data))))))))
1481 (when match
1482 (set-match-data match)
1483 t)))
1484
1485(defconst php-string-interpolated-variable-regexp 1499(defconst php-string-interpolated-variable-regexp
1486 "{\\$[^}\n\\\\]*\\(?:\\\\.[^}\n\\\\]*\\)*}\\|\\${\\sw+}\\|\\$\\sw+") 1500 "{\\$[^}\n\\\\]*\\(?:\\\\.[^}\n\\\\]*\\)*}\\|\\${\\sw+}\\|\\$\\sw+")
1487 1501
@@ -1497,9 +1511,6 @@ The output will appear in the buffer *PHP*."
1497 '(progn 1511 '(progn
1498 (font-lock-add-keywords 1512 (font-lock-add-keywords
1499 'php-mode 1513 'php-mode
1500 '((php-annotations-font-lock-find-annotation (2 'php-annotations-annotation-face t))))
1501 (font-lock-add-keywords
1502 'php-mode
1503 `((php-string-intepolated-variable-font-lock-find)) 1514 `((php-string-intepolated-variable-font-lock-find))
1504 'append))) 1515 'append)))
1505 1516