diff options
| author | Simeon Simeonov | 2017-04-24 12:23:56 +0200 |
|---|---|---|
| committer | Simeon Simeonov | 2017-04-24 12:23:56 +0200 |
| commit | 633aa066a900607361b85b110db9ac387b5f258b (patch) | |
| tree | 2617f1f46d1d19a70eee2731e8970e19e1d107c0 /.emacs.d | |
| parent | 489e9034087868a46dc9a3f6c4298090cb4395ea (diff) | |
php-mode yasnippet upgrade
Diffstat (limited to '.emacs.d')
| -rw-r--r-- | .emacs.d/lisp/php-mode.el | 158 | ||||
| -rw-r--r-- | .emacs.d/lisp/yasnippet.el | 84 |
2 files changed, 159 insertions, 83 deletions
diff --git a/.emacs.d/lisp/php-mode.el b/.emacs.d/lisp/php-mode.el index 9498d4d..12aa8c0 100644 --- a/.emacs.d/lisp/php-mode.el +++ b/.emacs.d/lisp/php-mode.el | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | (defconst php-mode-version-number "1.18.3" | 12 | (defconst php-mode-version-number "1.18.3" |
| 13 | "PHP Mode version number.") | 13 | "PHP Mode version number.") |
| 14 | 14 | ||
| 15 | (defconst php-mode-modified "2017-04-04" | 15 | (defconst php-mode-modified "2017-04-19" |
| 16 | "PHP Mode build date.") | 16 | "PHP Mode build date.") |
| 17 | 17 | ||
| 18 | ;;; License | 18 | ;;; License |
| @@ -179,11 +179,11 @@ of constants when set." | |||
| 179 | ;; remove old keywords | 179 | ;; remove old keywords |
| 180 | (when (boundp 'php-extra-constants) | 180 | (when (boundp 'php-extra-constants) |
| 181 | (font-lock-remove-keywords | 181 | (font-lock-remove-keywords |
| 182 | 'php-mode `((,(php-mode-extra-constants-create-regexp php-extra-constants) 1 php-constant-face)))) | 182 | 'php-mode `((,(php-mode-extra-constants-create-regexp php-extra-constants) 1 'php-constant)))) |
| 183 | ;; add new keywords | 183 | ;; add new keywords |
| 184 | (when value | 184 | (when value |
| 185 | (font-lock-add-keywords | 185 | (font-lock-add-keywords |
| 186 | 'php-mode `((,(php-mode-extra-constants-create-regexp value) 1 php-constant-face)))) | 186 | 'php-mode `((,(php-mode-extra-constants-create-regexp value) 1 'php-constant)))) |
| 187 | (set sym value)) | 187 | (set sym value)) |
| 188 | 188 | ||
| 189 | (defcustom php-lineup-cascaded-calls nil | 189 | (defcustom php-lineup-cascaded-calls nil |
| @@ -490,7 +490,7 @@ This variable can take one of the following symbol values: | |||
| 490 | 490 | ||
| 491 | (c-lang-defconst c-primitive-type-kwds | 491 | (c-lang-defconst c-primitive-type-kwds |
| 492 | php '("int" "integer" "bool" "boolean" "float" "double" "real" | 492 | php '("int" "integer" "bool" "boolean" "float" "double" "real" |
| 493 | "string" "object")) | 493 | "string" "object" "void")) |
| 494 | 494 | ||
| 495 | (c-lang-defconst c-class-decl-kwds | 495 | (c-lang-defconst c-class-decl-kwds |
| 496 | "Keywords introducing declarations where the following block (if any) | 496 | "Keywords introducing declarations where the following block (if any) |
| @@ -552,7 +552,6 @@ PHP does not have an \"enum\"-like keyword." | |||
| 552 | "array" | 552 | "array" |
| 553 | "callable" | 553 | "callable" |
| 554 | "iterable" | 554 | "iterable" |
| 555 | "void" | ||
| 556 | "as" | 555 | "as" |
| 557 | "break" | 556 | "break" |
| 558 | "catch all" | 557 | "catch all" |
| @@ -1006,58 +1005,95 @@ PHP heredoc." | |||
| 1006 | :group 'php | 1005 | :group 'php |
| 1007 | :group 'faces) | 1006 | :group 'faces) |
| 1008 | 1007 | ||
| 1009 | (defvar php-string-face 'php-string-face) | 1008 | (defface php-string '((t (:inherit font-lock-string-face))) |
| 1010 | (defvar php-keyword-face 'php-keyword-face) | ||
| 1011 | (defvar php-builtin-face 'php-builtin-face) | ||
| 1012 | (defvar php-function-name-face 'php-function-name-face) | ||
| 1013 | (defvar php-variable-name-face 'php-variable-name-face) | ||
| 1014 | (defvar php-type-face 'php-type-face) | ||
| 1015 | (defvar php-constant-face 'php-constant-face) | ||
| 1016 | (defvar php-php-tag-face 'php-php-tag-face) | ||
| 1017 | (defvar php-doc-annotation-tag-face 'php-doc-annotation-tag-face) | ||
| 1018 | (defvar php-doc-class-name-face 'php-doc-class-name-face) | ||
| 1019 | |||
| 1020 | (defface php-string-face '((t (:inherit font-lock-string-face))) | ||
| 1021 | "PHP Mode face used to highlight string literals." | 1009 | "PHP Mode face used to highlight string literals." |
| 1022 | :group 'php-faces) | 1010 | :group 'php-faces) |
| 1023 | 1011 | ||
| 1024 | (defface php-keyword-face '((t (:inherit font-lock-keyword-face))) | 1012 | (defface php-keyword '((t (:inherit font-lock-keyword-face))) |
| 1025 | "PHP Mode face used to highlight keywords." | 1013 | "PHP Mode face used to highlight keywords." |
| 1026 | :group 'php-faces) | 1014 | :group 'php-faces) |
| 1027 | 1015 | ||
| 1028 | (defface php-builtin-face '((t (:inherit font-lock-builtin-face))) | 1016 | (defface php-builtin '((t (:inherit font-lock-builtin-face))) |
| 1029 | "PHP Mode face used to highlight builtins." | 1017 | "PHP Mode face used to highlight builtins." |
| 1030 | :group 'php-faces) | 1018 | :group 'php-faces) |
| 1031 | 1019 | ||
| 1032 | (defface php-function-name-face '((t (:inherit font-lock-function-name-face))) | 1020 | (defface php-function-name '((t (:inherit font-lock-function-name-face))) |
| 1033 | "PHP Mode face used to highlight function names." | 1021 | "PHP Mode face used to highlight function names." |
| 1034 | :group 'php-faces) | 1022 | :group 'php-faces) |
| 1035 | 1023 | ||
| 1036 | (defface php-variable-name-face '((t (:inherit font-lock-variable-name-face))) | 1024 | (defface php-function-call '((t (:inherit default))) |
| 1025 | "PHP Mode face used to highlight function names in calles." | ||
| 1026 | :group 'php-faces) | ||
| 1027 | |||
| 1028 | (defface php-method-call '((t (:inherit php-function-call))) | ||
| 1029 | "PHP Mode face used to highlight method names in calles." | ||
| 1030 | :group 'php-faces) | ||
| 1031 | |||
| 1032 | (defface php-static-method-call '((t (:inherit php-method-call))) | ||
| 1033 | "PHP Mode face used to highlight static method names in calles." | ||
| 1034 | :group 'php-faces) | ||
| 1035 | |||
| 1036 | (defface php-variable-name '((t (:inherit font-lock-variable-name-face))) | ||
| 1037 | "PHP Mode face used to highlight variable names." | 1037 | "PHP Mode face used to highlight variable names." |
| 1038 | :group 'php-faces) | 1038 | :group 'php-faces) |
| 1039 | 1039 | ||
| 1040 | (defface php-type-face '((t (:inherit font-lock-type-face))) | 1040 | (defface php-property-name '((t (:inherit php-variable-name-face))) |
| 1041 | "PHP Mode face used to highlight property names." | ||
| 1042 | :group 'php-faces) | ||
| 1043 | |||
| 1044 | (defface php-variable-sigil '((t (:inherit default))) | ||
| 1045 | "PHP Mode face used to highlight variable sigils ($)." | ||
| 1046 | :group 'php-faces) | ||
| 1047 | |||
| 1048 | (defface php-object-op '((t (:inherit default))) | ||
| 1049 | "PHP Mode face used to object operators (->)." | ||
| 1050 | :group 'php-faces) | ||
| 1051 | |||
| 1052 | (defface php-paamayim-nekudotayim '((t (:inherit default))) | ||
| 1053 | "PHP Mode face used to highlight \"Paamayim Nekudotayim\" scope resolution operators (::)." | ||
| 1054 | :group 'php-faces) | ||
| 1055 | |||
| 1056 | (defface php-type '((t (:inherit font-lock-type-face))) | ||
| 1041 | "PHP Mode face used to highlight types." | 1057 | "PHP Mode face used to highlight types." |
| 1042 | :group 'php-faces) | 1058 | :group 'php-faces) |
| 1043 | 1059 | ||
| 1044 | (defface php-constant-face '((t (:inherit font-lock-constant-face))) | 1060 | (defface php-constant '((t (:inherit font-lock-constant-face))) |
| 1045 | "PHP Mode face used to highlight constants." | 1061 | "PHP Mode face used to highlight constants." |
| 1046 | :group 'php-faces) | 1062 | :group 'php-faces) |
| 1047 | 1063 | ||
| 1048 | (defface php-php-tag-face '((t (:inherit font-lock-constant-face))) | 1064 | (defface php-$this '((t (:inherit php-constant))) |
| 1065 | "PHP Mode face used to highlight $this variables." | ||
| 1066 | :group 'php-faces) | ||
| 1067 | |||
| 1068 | (defface php-$this-sigil '((t (:inherit php-constant))) | ||
| 1069 | "PHP Mode face used to highlight sigils($) of $this variable." | ||
| 1070 | :group 'php-faces) | ||
| 1071 | |||
| 1072 | (defface php-php-tag '((t (:inherit font-lock-constant-face))) | ||
| 1049 | "PHP Mode face used to highlight PHP tags." | 1073 | "PHP Mode face used to highlight PHP tags." |
| 1050 | :group 'php-faces) | 1074 | :group 'php-faces) |
| 1051 | 1075 | ||
| 1052 | (defface php-doc-annotation-tag-face '((t . (:inherit font-lock-constant-face))) | 1076 | (defface php-doc-annotation-tag '((t . (:inherit font-lock-constant-face))) |
| 1053 | "Face used to highlight annotation tags in doc-comment." | 1077 | "Face used to highlight annotation tags in doc-comment." |
| 1054 | :group 'php-faces) | 1078 | :group 'php-faces) |
| 1055 | 1079 | ||
| 1056 | (defface php-doc-class-name-face '((t (:inherit php-string-face))) | 1080 | (defface php-doc-variable-sigil '((t (:inherit font-lock-variable-name-face))) |
| 1081 | "PHP Mode face used to highlight variable sigils($)." | ||
| 1082 | :group 'php-faces) | ||
| 1083 | |||
| 1084 | (defface php-doc-$this '((t (:inherit php-type))) | ||
| 1085 | "PHP Mode face used to highlight $this variable in doc-comment." | ||
| 1086 | :group 'php-faces) | ||
| 1087 | |||
| 1088 | (defface php-doc-$this-sigil '((t (:inherit php-type))) | ||
| 1089 | "PHP Mode face used to highlight sigil of $this variable in doc-comment." | ||
| 1090 | :group 'php-faces) | ||
| 1091 | |||
| 1092 | (defface php-doc-class-name '((t (:inherit php-string))) | ||
| 1057 | "Face used to class names in doc-comment." | 1093 | "Face used to class names in doc-comment." |
| 1058 | :group 'php-faces) | 1094 | :group 'php-faces) |
| 1059 | 1095 | ||
| 1060 | (define-obsolete-face-alias 'php-annotations-annotation-face 'php-doc-annotation-tag-face "1.19.0") | 1096 | (define-obsolete-face-alias 'php-annotations-annotation-face 'php-doc-annotation-tag "1.19.0") |
| 1061 | 1097 | ||
| 1062 | 1098 | ||
| 1063 | ;;;###autoload | 1099 | ;;;###autoload |
| @@ -1070,12 +1106,12 @@ PHP heredoc." | |||
| 1070 | (c-init-language-vars php-mode) | 1106 | (c-init-language-vars php-mode) |
| 1071 | (c-common-init 'php-mode) | 1107 | (c-common-init 'php-mode) |
| 1072 | 1108 | ||
| 1073 | (set (make-local-variable font-lock-string-face) php-string-face) | 1109 | (set (make-local-variable font-lock-string-face) 'php-string) |
| 1074 | (set (make-local-variable font-lock-keyword-face) php-keyword-face) | 1110 | (set (make-local-variable font-lock-keyword-face) 'php-keyword) |
| 1075 | (set (make-local-variable font-lock-builtin-face) php-builtin-face) | 1111 | (set (make-local-variable font-lock-builtin-face) 'php-builtin) |
| 1076 | (set (make-local-variable font-lock-function-name-face) php-function-name-face) | 1112 | (set (make-local-variable font-lock-function-name-face) 'php-function-name) |
| 1077 | (set (make-local-variable font-lock-variable-name-face) php-variable-name-face) | 1113 | (set (make-local-variable font-lock-variable-name-face) 'php-variable-name) |
| 1078 | (set (make-local-variable font-lock-constant-face) php-constant-face) | 1114 | (set (make-local-variable font-lock-constant-face) 'php-constant) |
| 1079 | 1115 | ||
| 1080 | (modify-syntax-entry ?_ "_" php-mode-syntax-table) | 1116 | (modify-syntax-entry ?_ "_" php-mode-syntax-table) |
| 1081 | (modify-syntax-entry ?` "\"" php-mode-syntax-table) | 1117 | (modify-syntax-entry ?` "\"" php-mode-syntax-table) |
| @@ -1435,7 +1471,7 @@ a completion list." | |||
| 1435 | ;; Font Lock | 1471 | ;; Font Lock |
| 1436 | (defconst php-phpdoc-type-keywords | 1472 | (defconst php-phpdoc-type-keywords |
| 1437 | (list "string" "integer" "int" "boolean" "bool" "float" | 1473 | (list "string" "integer" "int" "boolean" "bool" "float" |
| 1438 | "double" "object" "mixed" "array" "resource" "$this" | 1474 | "double" "object" "mixed" "array" "resource" |
| 1439 | "void" "null" "false" "true" "self" "static" | 1475 | "void" "null" "false" "true" "self" "static" |
| 1440 | "callable" "iterable" "number")) | 1476 | "callable" "iterable" "number")) |
| 1441 | 1477 | ||
| @@ -1444,13 +1480,15 @@ a completion list." | |||
| 1444 | 1480 | ||
| 1445 | (defconst php-phpdoc-font-lock-doc-comments | 1481 | (defconst php-phpdoc-font-lock-doc-comments |
| 1446 | `(("{@[-[:alpha:]]+\\s-\\([^}]*\\)}" ; "{@foo ...}" markup. | 1482 | `(("{@[-[:alpha:]]+\\s-\\([^}]*\\)}" ; "{@foo ...}" markup. |
| 1447 | (0 php-doc-annotation-tag-face prepend nil) | 1483 | (0 'php-doc-annotation-tag prepend nil) |
| 1448 | (1 php-string-face prepend nil)) | 1484 | (1 'php-string prepend nil)) |
| 1449 | (,(rx "$" (in "A-Za-z_") (* (in "0-9A-Za-z_"))) | 1485 | (,(rx (group "$") (group (in "A-Za-z_") (* (in "0-9A-Za-z_")))) |
| 1450 | 0 php-variable-name-face prepend nil) | 1486 | (1 'php-doc-variable-sigil prepend nil) |
| 1487 | (2 'php-variable-name prepend nil)) | ||
| 1488 | ("\\(\\$\\)\\(this\\)\\>" (1 'php-doc-$this-sigil prepend nil) (2 'php-doc-$this prepend nil)) | ||
| 1451 | (,(concat "\\s-@" (regexp-opt php-phpdoc-type-tags) "\\s-+" | 1489 | (,(concat "\\s-@" (regexp-opt php-phpdoc-type-tags) "\\s-+" |
| 1452 | "\\(" (rx (+ (? "?") (? "\\") (+ (in "0-9A-Z_a-z")) (? "[]") (? "|"))) "\\)+") | 1490 | "\\(" (rx (+ (? "?") (? "\\") (+ (in "0-9A-Z_a-z")) (? "[]") (? "|"))) "\\)+") |
| 1453 | 1 php-string-face prepend nil) | 1491 | 1 'php-string prepend nil) |
| 1454 | (,(concat "\\(?:|\\|\\?\\|\\s-\\)\\(" | 1492 | (,(concat "\\(?:|\\|\\?\\|\\s-\\)\\(" |
| 1455 | (regexp-opt php-phpdoc-type-keywords 'words) | 1493 | (regexp-opt php-phpdoc-type-keywords 'words) |
| 1456 | "\\)") | 1494 | "\\)") |
| @@ -1458,7 +1496,7 @@ a completion list." | |||
| 1458 | ("https?://[^\n\t ]+" | 1496 | ("https?://[^\n\t ]+" |
| 1459 | 0 'link prepend nil) | 1497 | 0 'link prepend nil) |
| 1460 | ("^\\(?:/\\*\\)?\\(?:\\s \\|\\*\\)*\\(@[[:alpha:]][-[:alpha:]\\]*\\)" ; "@foo ..." markup. | 1498 | ("^\\(?:/\\*\\)?\\(?:\\s \\|\\*\\)*\\(@[[:alpha:]][-[:alpha:]\\]*\\)" ; "@foo ..." markup. |
| 1461 | 1 php-doc-annotation-tag-face prepend nil))) | 1499 | 1 'php-doc-annotation-tag prepend nil))) |
| 1462 | 1500 | ||
| 1463 | (defvar php-phpdoc-font-lock-keywords | 1501 | (defvar php-phpdoc-font-lock-keywords |
| 1464 | `((,(lambda (limit) | 1502 | `((,(lambda (limit) |
| @@ -1480,27 +1518,32 @@ a completion list." | |||
| 1480 | '( | 1518 | '( |
| 1481 | ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but | 1519 | ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but |
| 1482 | ;; not in $obj->var() | 1520 | ;; not in $obj->var() |
| 1483 | ("->\\(\\sw+\\)\\s-*(" 1 'default) | 1521 | ("\\(->\\)\\(\\sw+\\)\\s-*(" (1 'php-object-op) (2 'php-method-call)) |
| 1484 | 1522 | ||
| 1485 | ;; Highlight special variables | 1523 | ;; Highlight special variables |
| 1486 | ("\\$\\(this\\|that\\)\\_>" 1 php-constant-face) | 1524 | ("\\(\\$\\)\\(this\\|that\\)\\_>" (1 'php-$this-sigil) (2 'php-$this)) |
| 1487 | ("\\(\\$\\|->\\)\\([a-zA-Z0-9_]+\\)" 2 php-variable-name-face) | 1525 | ("\\(\\$\\)\\([a-zA-Z0-9_]+\\)" (1 'php-variable-sigil) (2 'php-variable-name)) |
| 1526 | ("\\(->\\)\\([a-zA-Z0-9_]+\\)" (1 'php-object-op) (2 'php-property-name)) | ||
| 1488 | 1527 | ||
| 1489 | ;; Highlight function/method names | 1528 | ;; Highlight function/method names |
| 1490 | ("\\<function\\s-+&?\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1 php-function-name-face) | 1529 | ("\\<function\\s-+&?\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1 'php-function-name) |
| 1491 | 1530 | ||
| 1492 | ;; The dollar sign should not get a variable-name face, below | 1531 | ;; The dollar sign should not get a variable-name face, below |
| 1493 | ;; pattern resets the face to default in case cc-mode sets the | 1532 | ;; pattern resets the face to default in case cc-mode sets the |
| 1494 | ;; variable-name face (cc-mode does this for variables prefixed | 1533 | ;; variable-name face (cc-mode does this for variables prefixed |
| 1495 | ;; with type, like in arglist) | 1534 | ;; with type, like in arglist) |
| 1496 | ("\\(\\$\\)\\(\\sw+\\)" 1 'default) | 1535 | ("\\(\\$\\)\\(\\sw+\\)" 1 'php-variable-sigil) |
| 1497 | 1536 | ||
| 1498 | ;; Array is a keyword, except when used as cast, so that (int) | 1537 | ;; Array is a keyword, except in the following situations: |
| 1499 | ;; and (array) look the same | 1538 | ;; - when used as cast, so that (int) and (array) look the same |
| 1539 | ;; - when used as a type hint | ||
| 1540 | ;; - when used as a return type | ||
| 1500 | ("(\\(array\\))" 1 font-lock-type-face) | 1541 | ("(\\(array\\))" 1 font-lock-type-face) |
| 1542 | ("\\b\\(array\\)\\s-+\\$" 1 font-lock-type-face) | ||
| 1543 | (")\\s-*:\\s-*\\??\\(array\\)\\b" 1 font-lock-type-face) | ||
| 1501 | 1544 | ||
| 1502 | ;; Support the ::class constant in PHP5.6 | 1545 | ;; Support the ::class constant in PHP5.6 |
| 1503 | ("\\sw+::\\(class\\)" 1 php-constant-face)) | 1546 | ("\\sw+\\(::\\)\\(class\\)\\b" (1 'php-paamayim-nekudotayim) (2 'php-constant))) |
| 1504 | 1547 | ||
| 1505 | ;; cc-mode patterns | 1548 | ;; cc-mode patterns |
| 1506 | (c-lang-const c-matchers-3 php) | 1549 | (c-lang-const c-matchers-3 php) |
| @@ -1512,17 +1555,17 @@ a completion list." | |||
| 1512 | `( | 1555 | `( |
| 1513 | ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but | 1556 | ;; Highlight variables, e.g. 'var' in '$var' and '$obj->var', but |
| 1514 | ;; not in $obj->var() | 1557 | ;; not in $obj->var() |
| 1515 | ("->\\(\\sw+\\)\\s-*(" 1 'default) | 1558 | ("->\\(\\sw+\\)\\s-*(" 1 'php-method-call) |
| 1516 | 1559 | ||
| 1517 | ("\\(\\$\\|->\\)\\([a-zA-Z0-9_]+\\)" 2 php-variable-name-face) | 1560 | ("\\(\\$\\|->\\)\\([a-zA-Z0-9_]+\\)" 2 'php-property-name) |
| 1518 | 1561 | ||
| 1519 | ;; Highlight all upper-cased symbols as constant | 1562 | ;; Highlight all upper-cased symbols as constant |
| 1520 | ("\\<\\([A-Z_][A-Z0-9_]+\\)\\>" 1 php-constant-face) | 1563 | ("\\<\\([A-Z_][A-Z0-9_]+\\)\\>" 1 'php-constant) |
| 1521 | 1564 | ||
| 1522 | ;; Highlight all statically accessed class names as constant, | 1565 | ;; Highlight all statically accessed class names as constant, |
| 1523 | ;; another valid option would be using type-face, but using | 1566 | ;; another valid option would be using type-face, but using |
| 1524 | ;; constant-face because this is how it works in c++-mode. | 1567 | ;; constant-face because this is how it works in c++-mode. |
| 1525 | ("\\(\\sw+\\)::" 1 php-constant-face) | 1568 | ("\\(\\sw+\\)\\(::\\)" (1 'php-constant) (2 'php-paamayim-nekudotayim)) |
| 1526 | 1569 | ||
| 1527 | ;; Highlight class name after "use .. as" | 1570 | ;; Highlight class name after "use .. as" |
| 1528 | ("\\<as\\s-+\\(\\sw+\\)" 1 font-lock-type-face) | 1571 | ("\\<as\\s-+\\(\\sw+\\)" 1 font-lock-type-face) |
| @@ -1541,7 +1584,10 @@ a completion list." | |||
| 1541 | 1 font-lock-type-face) | 1584 | 1 font-lock-type-face) |
| 1542 | 1585 | ||
| 1543 | ;; Highlight return types in functions and methods. | 1586 | ;; Highlight return types in functions and methods. |
| 1544 | ("function.+:\\s-?\\(\\(?:\\sw\\|\\s_\\)+\\)" 1 font-lock-type-face) | 1587 | ("function.+:\\s-?\\??\\(\\(?:\\sw\\|\\s_\\)+\\)" 1 font-lock-type-face) |
| 1588 | |||
| 1589 | ;; Highlight class names used as nullable type hints | ||
| 1590 | ("\\?\\(\\(:?\\sw\\|\\s_\\)+\\)\\s-+\\$" 1 font-lock-type-face) | ||
| 1545 | 1591 | ||
| 1546 | ;; While c-opt-cpp-* highlights the <?php opening tags, it is not | 1592 | ;; While c-opt-cpp-* highlights the <?php opening tags, it is not |
| 1547 | ;; possible to make it highlight short open tags and closing tags | 1593 | ;; possible to make it highlight short open tags and closing tags |
| @@ -1550,7 +1596,7 @@ a completion list." | |||
| 1550 | ;; | 1596 | ;; |
| 1551 | ;; Note that starting a file with <% breaks indentation, a | 1597 | ;; Note that starting a file with <% breaks indentation, a |
| 1552 | ;; limitation we can/should live with. | 1598 | ;; limitation we can/should live with. |
| 1553 | (,(regexp-opt '("?>" "<?" "<%" "%>")) 0 php-php-tag-face))) | 1599 | (,(regexp-opt '("?>" "<?" "<%" "%>")) 0 'php-php-tag))) |
| 1554 | "Detailed highlighting for PHP mode.") | 1600 | "Detailed highlighting for PHP mode.") |
| 1555 | 1601 | ||
| 1556 | (defvar php-font-lock-keywords php-font-lock-keywords-3 | 1602 | (defvar php-font-lock-keywords php-font-lock-keywords-3 |
| @@ -1600,7 +1646,7 @@ The output will appear in the buffer *PHP*." | |||
| 1600 | (let ((quoted-stuff (nth 3 (syntax-ppss)))) | 1646 | (let ((quoted-stuff (nth 3 (syntax-ppss)))) |
| 1601 | (when (and quoted-stuff (member quoted-stuff '(?\" ?`))) | 1647 | (when (and quoted-stuff (member quoted-stuff '(?\" ?`))) |
| 1602 | (put-text-property (match-beginning 0) (match-end 0) | 1648 | (put-text-property (match-beginning 0) (match-end 0) |
| 1603 | 'face 'php-variable-name-face)))) | 1649 | 'face 'php-variable-name)))) |
| 1604 | nil) | 1650 | nil) |
| 1605 | 1651 | ||
| 1606 | (eval-after-load 'php-mode | 1652 | (eval-after-load 'php-mode |
| @@ -1635,7 +1681,7 @@ The output will appear in the buffer *PHP*." | |||
| 1635 | ;; Special care is taken to restore the original syntax, because we | 1681 | ;; Special care is taken to restore the original syntax, because we |
| 1636 | ;; want \ not to be word for functions like forward-word. | 1682 | ;; want \ not to be word for functions like forward-word. |
| 1637 | (defadvice font-lock-fontify-keywords-region (around backslash-as-word activate) | 1683 | (defadvice font-lock-fontify-keywords-region (around backslash-as-word activate) |
| 1638 | "Fontify keywords with backslash as word character" | 1684 | "Fontify keywords with backslash as word character." |
| 1639 | (let ((old-syntax (string (char-syntax ?\\)))) | 1685 | (let ((old-syntax (string (char-syntax ?\\)))) |
| 1640 | (modify-syntax-entry ?\\ "w") | 1686 | (modify-syntax-entry ?\\ "w") |
| 1641 | ad-do-it | 1687 | ad-do-it |
diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el index 47b8ff5..a3a1eaa 100644 --- a/.emacs.d/lisp/yasnippet.el +++ b/.emacs.d/lisp/yasnippet.el | |||
| @@ -152,10 +152,13 @@ | |||
| 152 | :prefix "yas-" | 152 | :prefix "yas-" |
| 153 | :group 'editing) | 153 | :group 'editing) |
| 154 | 154 | ||
| 155 | (defconst yas--loaddir | ||
| 156 | (file-name-directory (or load-file-name buffer-file-name)) | ||
| 157 | "Directory that yasnippet was loaded from.") | ||
| 158 | |||
| 155 | (defvar yas-installed-snippets-dir nil) | 159 | (defvar yas-installed-snippets-dir nil) |
| 156 | (setq yas-installed-snippets-dir | 160 | (setq yas-installed-snippets-dir |
| 157 | (when load-file-name | 161 | (expand-file-name "snippets" yas--loaddir)) |
| 158 | (expand-file-name "snippets" (file-name-directory load-file-name)))) | ||
| 159 | 162 | ||
| 160 | (defconst yas--default-user-snippets-dir | 163 | (defconst yas--default-user-snippets-dir |
| 161 | (expand-file-name "snippets" user-emacs-directory)) | 164 | (expand-file-name "snippets" user-emacs-directory)) |
| @@ -577,7 +580,9 @@ conditions. | |||
| 577 | "Holds the YASnippet menu.") | 580 | "Holds the YASnippet menu.") |
| 578 | 581 | ||
| 579 | (defun yas--maybe-expand-key-filter (cmd) | 582 | (defun yas--maybe-expand-key-filter (cmd) |
| 580 | (if (yas--templates-for-key-at-point) cmd)) | 583 | (when (let ((yas--condition-cache-timestamp (current-time))) |
| 584 | (yas--templates-for-key-at-point)) | ||
| 585 | cmd)) | ||
| 581 | 586 | ||
| 582 | (defconst yas-maybe-expand | 587 | (defconst yas-maybe-expand |
| 583 | '(menu-item "" yas-expand :filter yas--maybe-expand-key-filter) | 588 | '(menu-item "" yas-expand :filter yas--maybe-expand-key-filter) |
| @@ -1977,9 +1982,24 @@ This works by stubbing a few functions, then calling | |||
| 1977 | 1982 | ||
| 1978 | (defun yas-about () | 1983 | (defun yas-about () |
| 1979 | (interactive) | 1984 | (interactive) |
| 1980 | (message (concat "yasnippet (version " | 1985 | (message "yasnippet (version %s) -- pluskid/joaotavora/npostavs" |
| 1981 | yas--version | 1986 | (or (ignore-errors (car (let ((default-directory yas--loaddir)) |
| 1982 | ") -- pluskid/joaotavora/npostavs"))) | 1987 | (process-lines "git" "describe" |
| 1988 | "--tags" "--dirty")))) | ||
| 1989 | (when (and (featurep 'package) | ||
| 1990 | (fboundp 'package-desc-version) | ||
| 1991 | (fboundp 'package-version-join)) | ||
| 1992 | (defvar package-alist) | ||
| 1993 | (ignore-errors | ||
| 1994 | (let* ((yas-pkg (cdr (assq 'yasnippet package-alist))) | ||
| 1995 | (version (package-version-join | ||
| 1996 | (package-desc-version (car yas-pkg))))) | ||
| 1997 | ;; Special case for MELPA's bogus version numbers. | ||
| 1998 | (if (string-match "\\`20..[01][0-9][0-3][0-9][.][0-9]\\{3,4\\}\\'" | ||
| 1999 | version) | ||
| 2000 | (concat yas--version "-snapshot" version) | ||
| 2001 | version)))) | ||
| 2002 | yas--version))) | ||
| 1983 | 2003 | ||
| 1984 | 2004 | ||
| 1985 | ;;; Apropos snippet menu: | 2005 | ;;; Apropos snippet menu: |
| @@ -2212,7 +2232,8 @@ object satisfying `yas--field-p' to restrict the expansion to." | |||
| 2212 | (yas--fallback)))) | 2232 | (yas--fallback)))) |
| 2213 | 2233 | ||
| 2214 | (defun yas--maybe-expand-from-keymap-filter (cmd) | 2234 | (defun yas--maybe-expand-from-keymap-filter (cmd) |
| 2215 | (let* ((vec (cl-subseq (this-command-keys-vector) | 2235 | (let* ((yas--condition-cache-timestamp (current-time)) |
| 2236 | (vec (cl-subseq (this-command-keys-vector) | ||
| 2216 | (if current-prefix-arg | 2237 | (if current-prefix-arg |
| 2217 | (length (this-command-keys)) | 2238 | (length (this-command-keys)) |
| 2218 | 0))) | 2239 | 0))) |
| @@ -3272,7 +3293,8 @@ This renders the snippet as ordinary text." | |||
| 3272 | (overlay-buffer control-overlay)) | 3293 | (overlay-buffer control-overlay)) |
| 3273 | (setq yas-snippet-beg (overlay-start control-overlay)) | 3294 | (setq yas-snippet-beg (overlay-start control-overlay)) |
| 3274 | (setq yas-snippet-end (overlay-end control-overlay)) | 3295 | (setq yas-snippet-end (overlay-end control-overlay)) |
| 3275 | (delete-overlay control-overlay)) | 3296 | (delete-overlay control-overlay) |
| 3297 | (setf (yas--snippet-control-overlay snippet) nil)) | ||
| 3276 | 3298 | ||
| 3277 | (let ((yas--inhibit-overlay-hooks t)) | 3299 | (let ((yas--inhibit-overlay-hooks t)) |
| 3278 | (when yas--active-field-overlay | 3300 | (when yas--active-field-overlay |
| @@ -3427,8 +3449,9 @@ If so cleans up the whole snippet up." | |||
| 3427 | ;; | 3449 | ;; |
| 3428 | ;; This was found useful for performance reasons, so that an excessive | 3450 | ;; This was found useful for performance reasons, so that an excessive |
| 3429 | ;; number of live markers aren't kept around in the | 3451 | ;; number of live markers aren't kept around in the |
| 3430 | ;; `buffer-undo-list'. We reuse the original marker object, although | 3452 | ;; `buffer-undo-list'. We don't reuse the original marker object |
| 3431 | ;; that's probably not necessary. | 3453 | ;; because that leaves an unreadable object in the history list and |
| 3454 | ;; undo-tree persistence has trouble with that. | ||
| 3432 | ;; | 3455 | ;; |
| 3433 | ;; This shouldn't bring horrible problems with undo/redo, but you | 3456 | ;; This shouldn't bring horrible problems with undo/redo, but you |
| 3434 | ;; never know. | 3457 | ;; never know. |
| @@ -3436,16 +3459,13 @@ If so cleans up the whole snippet up." | |||
| 3436 | (defun yas--markers-to-points (snippet) | 3459 | (defun yas--markers-to-points (snippet) |
| 3437 | "Save all markers of SNIPPET as positions." | 3460 | "Save all markers of SNIPPET as positions." |
| 3438 | (yas--snippet-map-markers (lambda (m) | 3461 | (yas--snippet-map-markers (lambda (m) |
| 3439 | (prog1 (cons (marker-position m) m) | 3462 | (prog1 (marker-position m) |
| 3440 | (set-marker m nil))) | 3463 | (set-marker m nil))) |
| 3441 | snippet)) | 3464 | snippet)) |
| 3442 | 3465 | ||
| 3443 | (defun yas--points-to-markers (snippet) | 3466 | (defun yas--points-to-markers (snippet) |
| 3444 | "Restore SNIPPET's marker positions, saved by `yas--markers-to-points'." | 3467 | "Restore SNIPPET's marker positions, saved by `yas--markers-to-points'." |
| 3445 | (yas--snippet-map-markers (lambda (p-m) | 3468 | (yas--snippet-map-markers #'copy-marker snippet)) |
| 3446 | (set-marker (cdr p-m) (car p-m)) | ||
| 3447 | (cdr p-m)) | ||
| 3448 | snippet)) | ||
| 3449 | 3469 | ||
| 3450 | (defun yas--maybe-move-to-active-field (snippet) | 3470 | (defun yas--maybe-move-to-active-field (snippet) |
| 3451 | "Try to move to SNIPPET's active (or first) field and return it if found." | 3471 | "Try to move to SNIPPET's active (or first) field and return it if found." |
| @@ -3588,7 +3608,8 @@ field start. This hook does nothing if an undo is in progress." | |||
| 3588 | (reoverlays nil)) | 3608 | (reoverlays nil)) |
| 3589 | (dolist (snippet snippets) | 3609 | (dolist (snippet snippets) |
| 3590 | (dolist (m (yas--collect-snippet-markers snippet)) | 3610 | (dolist (m (yas--collect-snippet-markers snippet)) |
| 3591 | (push (yas--snapshot-marker-location m beg end) remarkers)) | 3611 | (when (and (<= beg m) (<= m end)) |
| 3612 | (push (yas--snapshot-marker-location m beg end) remarkers))) | ||
| 3592 | (push (yas--snapshot-overlay-location | 3613 | (push (yas--snapshot-overlay-location |
| 3593 | (yas--snippet-control-overlay snippet) beg end) | 3614 | (yas--snippet-control-overlay snippet) beg end) |
| 3594 | reoverlays)) | 3615 | reoverlays)) |
| @@ -3790,6 +3811,7 @@ considered when expanding the snippet." | |||
| 3790 | (yas--letenv (yas--snippet-expand-env snippet) | 3811 | (yas--letenv (yas--snippet-expand-env snippet) |
| 3791 | (yas--move-to-field snippet first-field)))) | 3812 | (yas--move-to-field snippet first-field)))) |
| 3792 | (yas--message 4 "snippet expanded.") | 3813 | (yas--message 4 "snippet expanded.") |
| 3814 | (setq deactivate-mark nil) | ||
| 3793 | t)))) | 3815 | t)))) |
| 3794 | 3816 | ||
| 3795 | (defun yas--take-care-of-redo (_beg _end snippet) | 3817 | (defun yas--take-care-of-redo (_beg _end snippet) |
| @@ -4111,15 +4133,21 @@ The returned value is a list of the form (MARKER REGEXP WS-COUNT)." | |||
| 4111 | (nconc before (list marker) after) | 4133 | (nconc before (list marker) after) |
| 4112 | "[[:space:]\n]*")) | 4134 | "[[:space:]\n]*")) |
| 4113 | (progn (goto-char marker) | 4135 | (progn (goto-char marker) |
| 4114 | (skip-syntax-forward " " end) | 4136 | (skip-chars-forward "[:space:]\n" end) |
| 4115 | (- (point) marker))))) | 4137 | (- (point) marker))))) |
| 4116 | 4138 | ||
| 4117 | (defun yas--snapshot-overlay-location (overlay beg end) | 4139 | (defun yas--snapshot-overlay-location (overlay beg end) |
| 4118 | "Like `yas--snapshot-marker-location' for overlays. | 4140 | "Like `yas--snapshot-marker-location' for overlays. |
| 4119 | The returned format is (OVERLAY (RE WS) (RE WS))." | 4141 | The returned format is (OVERLAY (RE WS) (RE WS)). Either of |
| 4120 | (list overlay | 4142 | the (RE WS) lists may be nil if the start or end, respectively, |
| 4121 | (cdr (yas--snapshot-marker-location (overlay-start overlay) beg end)) | 4143 | of the overlay is outside the range BEG .. END." |
| 4122 | (cdr (yas--snapshot-marker-location (overlay-end overlay) beg end)))) | 4144 | (let ((obeg (overlay-start overlay)) |
| 4145 | (oend (overlay-end overlay))) | ||
| 4146 | (list overlay | ||
| 4147 | (when (and (<= beg obeg) (< obeg end)) | ||
| 4148 | (cdr (yas--snapshot-marker-location obeg beg end))) | ||
| 4149 | (when (and (<= beg oend) (< oend end)) | ||
| 4150 | (cdr (yas--snapshot-marker-location oend beg end)))))) | ||
| 4123 | 4151 | ||
| 4124 | (defun yas--snapshot-overlay-line-location (overlay) | 4152 | (defun yas--snapshot-overlay-line-location (overlay) |
| 4125 | "Return info for restoring OVERLAY's line based location. | 4153 | "Return info for restoring OVERLAY's line based location. |
| @@ -4142,8 +4170,8 @@ Buffer must be narrowed to BEG..END used to create the snapshot info." | |||
| 4142 | (lwarn '(yasnippet re-marker) :warning | 4170 | (lwarn '(yasnippet re-marker) :warning |
| 4143 | "Couldn't find: %S" regexp) | 4171 | "Couldn't find: %S" regexp) |
| 4144 | (goto-char (match-beginning 1)) | 4172 | (goto-char (match-beginning 1)) |
| 4145 | (skip-syntax-forward " ") | 4173 | (skip-chars-forward "[:space:]\n") |
| 4146 | (skip-syntax-backward " " (- (point) ws-count)))) | 4174 | (skip-chars-backward "[:space:]\n" (- (point) ws-count)))) |
| 4147 | 4175 | ||
| 4148 | (defun yas--restore-marker-location (re-marker) | 4176 | (defun yas--restore-marker-location (re-marker) |
| 4149 | "Restores marker based on info from `yas--snapshot-marker-location'. | 4177 | "Restores marker based on info from `yas--snapshot-marker-location'. |
| @@ -4156,10 +4184,12 @@ Buffer must be narrowed to BEG..END used to create the snapshot info." | |||
| 4156 | Buffer must be narrowed to BEG..END used to create the snapshot info." | 4184 | Buffer must be narrowed to BEG..END used to create the snapshot info." |
| 4157 | (cl-destructuring-bind (overlay loc-beg loc-end) ov-locations | 4185 | (cl-destructuring-bind (overlay loc-beg loc-end) ov-locations |
| 4158 | (move-overlay overlay | 4186 | (move-overlay overlay |
| 4159 | (progn (apply #'yas--goto-saved-location loc-beg) | 4187 | (if (not loc-beg) (overlay-start overlay) |
| 4160 | (point)) | 4188 | (apply #'yas--goto-saved-location loc-beg) |
| 4161 | (progn (apply #'yas--goto-saved-location loc-end) | 4189 | (point)) |
| 4162 | (point))))) | 4190 | (if (not loc-end) (overlay-end overlay) |
| 4191 | (apply #'yas--goto-saved-location loc-end) | ||
| 4192 | (point))))) | ||
| 4163 | 4193 | ||
| 4164 | 4194 | ||
| 4165 | (defun yas--restore-overlay-line-location (ov-locations) | 4195 | (defun yas--restore-overlay-line-location (ov-locations) |
