diff options
| author | Simeon Simeonov | 2017-11-30 19:35:22 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2017-11-30 19:35:22 +0100 |
| commit | 33b5952ddc7ce1be3561f3a19e5f64aee72eea05 (patch) | |
| tree | 9939b14383d72436c4807271becec9daaf6817bc /.emacs.d | |
| parent | 131a54ee37028f709a5f77e04513e9a80535e8c7 (diff) | |
Upgrade php-mode.el
Diffstat (limited to '.emacs.d')
| -rw-r--r-- | .emacs.d/lisp/php-mode.el | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/.emacs.d/lisp/php-mode.el b/.emacs.d/lisp/php-mode.el index 9413fce..5cbc0d1 100644 --- a/.emacs.d/lisp/php-mode.el +++ b/.emacs.d/lisp/php-mode.el | |||
| @@ -429,34 +429,6 @@ This variable can take one of the following symbol values: | |||
| 429 | map) | 429 | map) |
| 430 | "Keymap for `php-mode'") | 430 | "Keymap for `php-mode'") |
| 431 | 431 | ||
| 432 | (c-lang-defconst c-get-state-before-change-functions | ||
| 433 | ;; const might be a symbol in older versions | ||
| 434 | php (let ((const (c-lang-const c-get-state-before-change-functions))) | ||
| 435 | (cl-set-difference (if (listp const) const (list const)) | ||
| 436 | '(c-parse-quotes-before-change)))) | ||
| 437 | |||
| 438 | (defun php-unescape-identifiers (beg end &optional old-len) | ||
| 439 | "Change syntax of backslashes in identifiers between BEG and END, ignore OLD-LEN." | ||
| 440 | (c-save-buffer-state (num-beg num-end) | ||
| 441 | (save-restriction | ||
| 442 | (goto-char c-new-BEG) | ||
| 443 | (while (and (< (point) c-new-END) | ||
| 444 | (search-forward "\\" c-new-END 'limit)) | ||
| 445 | (if (and (not (php-in-string-p)) | ||
| 446 | (looking-at-p c-identifier-key)) | ||
| 447 | ;; within function `c-forward-name' when looking at | ||
| 448 | ;; `c-identifier-key' ensure that `c-simple-skip-symbol-backward' | ||
| 449 | ;; skips over backslashes too in making it at word entry. | ||
| 450 | (c-put-char-property (1- (point)) 'syntax-table '(2))))))) | ||
| 451 | |||
| 452 | (c-lang-defconst c-before-font-lock-functions | ||
| 453 | ;; const might be a symbol in older versions | ||
| 454 | php (let ((const (c-lang-const c-before-font-lock-functions))) | ||
| 455 | (append (cl-set-difference (if (listp const) const (list const)) | ||
| 456 | '(c-restore-<>-properties | ||
| 457 | c-parse-quotes-after-change)) | ||
| 458 | '(php-unescape-identifiers)))) | ||
| 459 | |||
| 460 | (c-lang-defconst c-mode-menu | 432 | (c-lang-defconst c-mode-menu |
| 461 | php (append '(["Complete function name" php-complete-function t] | 433 | php (append '(["Complete function name" php-complete-function t] |
| 462 | ["Browse manual" php-browse-manual t] | 434 | ["Browse manual" php-browse-manual t] |
| @@ -957,8 +929,9 @@ the string HEREDOC-START." | |||
| 957 | 929 | ||
| 958 | (defun php-syntax-propertize-function (start end) | 930 | (defun php-syntax-propertize-function (start end) |
| 959 | "Apply propertize rules from START to END." | 931 | "Apply propertize rules from START to END." |
| 960 | ;; versions < git-snapshot as of 2017-10 need this here | 932 | ;; (defconst php-syntax-propertize-function |
| 961 | (php-unescape-identifiers start end) | 933 | ;; (syntax-propertize-rules |
| 934 | ;; (php-heredoc-start-re (0 (ignore (php-heredoc-syntax)))))) | ||
| 962 | (goto-char start) | 935 | (goto-char start) |
| 963 | (while (and (< (point) end) | 936 | (while (and (< (point) end) |
| 964 | (re-search-forward php-heredoc-start-re end t)) | 937 | (re-search-forward php-heredoc-start-re end t)) |
| @@ -1150,10 +1123,16 @@ After setting the stylevars run hooks according to STYLENAME | |||
| 1150 | (set (make-local-variable font-lock-constant-face) 'php-constant) | 1123 | (set (make-local-variable font-lock-constant-face) 'php-constant) |
| 1151 | 1124 | ||
| 1152 | (modify-syntax-entry ?_ "_" php-mode-syntax-table) | 1125 | (modify-syntax-entry ?_ "_" php-mode-syntax-table) |
| 1126 | (modify-syntax-entry ?` "\"" php-mode-syntax-table) | ||
| 1127 | (modify-syntax-entry ?\" "\"" php-mode-syntax-table) | ||
| 1153 | (modify-syntax-entry ?# "< b" php-mode-syntax-table) | 1128 | (modify-syntax-entry ?# "< b" php-mode-syntax-table) |
| 1154 | (modify-syntax-entry ?\n "> b" php-mode-syntax-table) | 1129 | (modify-syntax-entry ?\n "> b" php-mode-syntax-table) |
| 1155 | (modify-syntax-entry ?$ "'" php-mode-syntax-table) | 1130 | (modify-syntax-entry ?$ "'" php-mode-syntax-table) |
| 1156 | 1131 | ||
| 1132 | (set (make-local-variable 'syntax-propertize-via-font-lock) | ||
| 1133 | '(("\\(\"\\)\\(\\\\.\\|[^\"\n\\]\\)*\\(\"\\)" (1 "\"") (3 "\"")) | ||
| 1134 | ("\\(\'\\)\\(\\\\.\\|[^\'\n\\]\\)*\\(\'\\)" (1 "\"") (3 "\"")))) | ||
| 1135 | |||
| 1157 | (add-to-list (make-local-variable 'syntax-propertize-extend-region-functions) | 1136 | (add-to-list (make-local-variable 'syntax-propertize-extend-region-functions) |
| 1158 | #'php-syntax-propertize-extend-region) | 1137 | #'php-syntax-propertize-extend-region) |
| 1159 | (set (make-local-variable 'syntax-propertize-function) | 1138 | (set (make-local-variable 'syntax-propertize-function) |
| @@ -1680,6 +1659,19 @@ The output will appear in the buffer *PHP*." | |||
| 1680 | 1659 | ||
| 1681 | (ad-activate 'fixup-whitespace) | 1660 | (ad-activate 'fixup-whitespace) |
| 1682 | 1661 | ||
| 1662 | ;; Advice `font-lock-fontify-keywords-region' to support namespace | ||
| 1663 | ;; separators in class names. Use word syntax for backslashes when | ||
| 1664 | ;; doing keyword fontification, but not when doing syntactic | ||
| 1665 | ;; fontification because that breaks \ as escape character in strings. | ||
| 1666 | ;; | ||
| 1667 | ;; Special care is taken to restore the original syntax, because we | ||
| 1668 | ;; want \ not to be word for functions like forward-word. | ||
| 1669 | (defadvice font-lock-fontify-keywords-region (around backslash-as-word activate) | ||
| 1670 | "Fontify keywords with backslash as word character." | ||
| 1671 | (let ((old-syntax (string (char-syntax ?\\)))) | ||
| 1672 | (modify-syntax-entry ?\\ "w") | ||
| 1673 | ad-do-it | ||
| 1674 | (modify-syntax-entry ?\\ old-syntax))) | ||
| 1683 | 1675 | ||
| 1684 | 1676 | ||
| 1685 | (defcustom php-class-suffix-when-insert "::" | 1677 | (defcustom php-class-suffix-when-insert "::" |
