116
116
; ; be undone via tab.
117
117
118
118
(when (looking-at (concat " \s *\. " rust-re-ident))
119
- (previous-line )
119
+ (previous-logical- line )
120
120
(end-of-line )
121
121
122
122
(let
131
131
; ;
132
132
((skip-dot-identifier
133
133
(lambda ()
134
- (when (looking-back (concat " \. " rust-re-ident))
134
+ (when (looking-back (concat " \\ ." rust-re-ident))
135
135
(backward-word 1 )
136
136
(backward-char )
137
137
(- (current-column ) rust-indent-offset)))))
311
311
(" fn" . font-lock-function-name-face )
312
312
(" static" . font-lock-constant-face )))))
313
313
314
+ (defvar rust-mode-font-lock-syntactic-keywords
315
+ (mapcar (lambda (re ) (list re '(1 " \" " ) '(2 " \" " )))
316
+ '(" \\ ('\\ )[^']\\ ('\\ )"
317
+ " \\ ('\\ )\\\\ ['nrt]\\ ('\\ )"
318
+ " \\ ('\\ )\\\\ x[[:xdigit:]]\\ {2\\ }\\ ('\\ )"
319
+ " \\ ('\\ )\\\\ u[[:xdigit:]]\\ {4\\ }\\ ('\\ )"
320
+ " \\ ('\\ )\\\\ U[[:xdigit:]]\\ {8\\ }\\ ('\\ )" )))
321
+
314
322
(defun rust-fill-prefix-for-comment-start (line-start )
315
323
" Determine what to use for `fill-prefix' based on what is at the beginning of a line."
316
324
(let ((result
@@ -569,7 +577,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
569
577
(setq-local indent-line-function 'rust-mode-indent-line )
570
578
571
579
; ; Fonts
572
- (setq-local font-lock-defaults '(rust-mode-font-lock-keywords nil nil nil nil ))
580
+ (setq-local font-lock-defaults '(rust-mode-font-lock-keywords nil nil nil nil (font-lock-syntactic-keywords . rust-mode-font-lock-syntactic-keywords) ))
573
581
574
582
; ; Misc
575
583
(setq-local comment-start " // " )
@@ -591,33 +599,8 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
591
599
(setq-local beginning-of-defun-function 'rust-beginning-of-defun )
592
600
(setq-local end-of-defun-function 'rust-end-of-defun )
593
601
(setq-local parse-sexp-lookup-properties t )
594
- (add-hook 'syntax-propertize-extend-region-functions 'rust-syntax-propertize-extend-region )
595
- (add-hook 'post-self-insert-hook 'rust-match-angle-bracket-hook )
596
- (setq-local syntax-propertize-function 'rust-syntax-propertize ))
597
-
598
- (defun rust-syntax-propertize-extend-region (start end )
599
- (save-excursion
600
- (goto-char start)
601
- (beginning-of-defun )
602
- (cons
603
- (point )
604
- (progn
605
- (goto-char end)
606
- (end-of-defun )
607
- (point )))))
608
-
609
- (defun rust-syntax-propertize (start end )
610
- ; ; Find character literals and make the syntax table recognize the single quote as the string delimiter
611
- (dolist (char-lit-re
612
- '(" '[^']'"
613
- " '\\\\ ['nrt]'"
614
- " '\\\\ x[[:xdigit:]]\\ {2\\ }'"
615
- " '\\\\ u[[:xdigit:]]\\ {4\\ }'"
616
- " '\\\\ U[[:xdigit:]]\\ {8\\ }'" ))
617
- (save-excursion
618
- (goto-char start)
619
- (while (re-search-forward char-lit-re end t )
620
- (put-text-property (match-beginning 0 ) (match-end 0 ) 'syntax-table rust-mode-character-literal-syntax-table)))))
602
+ (setq-local syntax-begin-function 'beginning-of-defun )
603
+ (add-hook 'post-self-insert-hook 'rust-match-angle-bracket-hook ))
621
604
622
605
;;;### autoload
623
606
(add-to-list 'auto-mode-alist '(" \\ .rs\\ '" . rust-mode))
0 commit comments