diff options
| author | Felix S Klock II <pnkfelix@pnkfx.org> | 2015-04-30 13:22:19 +0200 |
|---|---|---|
| committer | Felix S Klock II <pnkfelix@pnkfx.org> | 2015-04-30 13:22:19 +0200 |
| commit | 6d5b02e18a9c4ce327a15183ac1786d878acb646 (patch) | |
| tree | 3b9ebc48c98f14958f3e507d5e67506295ccfbd3 | |
| parent | 493cc99ecad9ee1890007c69d2b500156a78ceeb (diff) | |
| parent | 2e800ee9c8a38619dfdf58d03e6c4d5381f61196 (diff) | |
| download | rust-mode-6d5b02e18a9c4ce327a15183ac1786d878acb646.tar.gz | |
Merge pull request #56 from pnkfelix/pr=fix-word-syntax
Fix word and symbol syntax distinction, take 2
| -rw-r--r-- | rust-mode.el | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/rust-mode.el b/rust-mode.el index 290dd6b..27250a2 100644 --- a/rust-mode.el +++ b/rust-mode.el @@ -32,11 +32,6 @@ (modify-syntax-entry ?\" "\"" table) (modify-syntax-entry ?\\ "\\" table) - ;; mark _ as a word constituent so that identifiers - ;; such as xyz_type don't cause type to be highlighted - ;; as a keyword - (modify-syntax-entry ?_ "w" table) - ;; Comments (modify-syntax-entry ?/ ". 124b" table) (modify-syntax-entry ?* ". 23" table) @@ -145,7 +140,7 @@ ((skip-dot-identifier (lambda () (when (looking-back (concat "\\." rust-re-ident)) - (backward-word 1) + (forward-thing 'symbol -1) (backward-char) (- (current-column) rust-indent-offset))))) (cond @@ -331,14 +326,19 @@ (defun rust-re-item-def (itype) (concat (rust-re-word itype) "[[:space:]]+" (rust-re-grab rust-re-ident))) +;; (See PR #42 -- this is just like `(regexp-opt words 'symbols)` from +;; newer Emacs versions, but will work on Emacs 23.) +(defun regexp-opt-symbols (words) + (concat "\\_<" (regexp-opt words t) "\\_>")) + (defvar rust-mode-font-lock-keywords (append `( ;; Keywords proper - (,(regexp-opt rust-mode-keywords 'words) . font-lock-keyword-face) + (,(regexp-opt-symbols rust-mode-keywords) . font-lock-keyword-face) ;; Special types - (,(regexp-opt rust-special-types 'words) . font-lock-type-face) + (,(regexp-opt-symbols rust-special-types) . font-lock-type-face) ;; Attributes like `#[bar(baz)]` or `#![bar(baz)]` or `#[bar = "baz"]` (,(rust-re-grab (concat "#\\!?\\[" rust-re-ident "[^]]*\\]")) |
