[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 1ceac8b 212/486: Re-fontify buffer after it is r
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 1ceac8b 212/486: Re-fontify buffer after it is reverted |
Date: |
Sat, 7 Aug 2021 09:25:21 -0400 (EDT) |
branch: elpa/rust-mode
commit 1ceac8b6561c64a12f5e4781db1fa735ff48a201
Author: Micah Chalmer <micah@micahchalmer.net>
Commit: Micah Chalmer <micah@micahchalmer.net>
Re-fontify buffer after it is reverted
Fix #104
---
rust-mode-tests.el | 23 +++++++++++++++++++++++
rust-mode.el | 15 ++++++++++++++-
2 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index cbfde96..e7a0429 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -2427,6 +2427,29 @@ Fontification needs to include this whole string or none
of it.
(should (<= font-lock-beg 1))
(should (>= font-lock-end 12)))))
+(ert-deftest redo-syntax-after-change-far-from-point ()
+ (let*
+ ((tmp-file-name (make-temp-file "rust-mdoe-test-issue104"))
+ (base-contents (apply 'concat (append '("fn foo() {\n\n}\n") (make-list
500 "// More stuff...\n") '("fn bar() {\n\n}\n")))))
+ ;; Create the temp file...
+ (with-temp-file tmp-file-name
+ (insert base-contents))
+ (with-temp-buffer
+ (insert-file-contents tmp-file-name 'VISIT nil nil 'REPLACE)
+ (rust-mode)
+ (goto-char (point-max))
+ (should (= 0 (rust-paren-level)))
+ (with-temp-file tmp-file-name
+ (insert base-contents)
+ (goto-char 12) ;; On the blank line in the middle of fn foo
+ (insert " let z = 1 < 3;")
+ )
+ (revert-buffer 'IGNORE-AUTO 'NOCONFIRM 'PRESERVE-MODES)
+ (should (= 0 (rust-paren-level)))
+ )
+ )
+ )
+
;; If electric-pair-mode is available, load it and run the tests that use it.
If not,
;; no error--the tests will be skipped.
(require 'elec-pair nil t)
diff --git a/rust-mode.el b/rust-mode.el
index 1d39a54..a2c81f7 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1229,7 +1229,9 @@ This is written mainly to be used as
`end-of-defun-function' for Rust."
(setq-local beginning-of-defun-function 'rust-beginning-of-defun)
(setq-local end-of-defun-function 'rust-end-of-defun)
(setq-local parse-sexp-lookup-properties t)
- (setq-local electric-pair-inhibit-predicate
'rust-electric-pair-inhibit-predicate-wrap))
+ (setq-local electric-pair-inhibit-predicate
'rust-electric-pair-inhibit-predicate-wrap)
+ (add-hook 'after-revert-hook 'rust--after-revert-hook 'LOCAL)
+ )
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
@@ -1240,6 +1242,17 @@ This is written mainly to be used as
`end-of-defun-function' for Rust."
(require 'rust-mode)
(rust-mode))
+;; Issue #104: When reverting the buffer, make sure all fontification is redone
+;; so that we don't end up missing a non-angle-bracket '<' or '>' character.
+(defun rust--after-revert-hook ()
+ (let
+ ;; Newer emacs versions (25 and later) make `font-lock-fontify-buffer'
+ ;; interactive-only, and want lisp code to call `font-lock-flush' or
+ ;; `font-lock-ensure'. But those don't exist in emacs 24 and earlier.
+ ((font-lock-ensure-fn (if (fboundp 'font-lock-ensure) 'font-lock-ensure
'font-lock-fontify-buffer)))
+ (funcall font-lock-ensure-fn))
+ )
+
;; Issue #6887: Rather than inheriting the 'gnu compilation error
;; regexp (which is broken on a few edge cases), add our own 'rust
;; compilation error regexp and use it instead.
- [nongnu] elpa/rust-mode 58c47a3 021/486: add instructions for install from MELPA, (continued)
- [nongnu] elpa/rust-mode 58c47a3 021/486: add instructions for install from MELPA, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode bda009d 023/486: add auto-mode-alist to autoloads, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode aa3ee6a 026/486: rust-mode: Add pub and priv, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ac92ff6 037/486: etc: add the `in` keyword to the emacs mode., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9640fe8 051/486: Indent return type to align with arguments, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0256f02 302/486: Fix stupid mistake in rustfmt conditional, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 3220937 304/486: Merge pull request #209 from tromey/default-keyword, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode a33b684 207/486: Fix #103: comment indentation after struct members, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 339afba 206/486: Highlight the unsafe keyword, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode fa5b38f 218/486: Merge pull request #117 from TheBB/fix-closing-delim, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1ceac8b 212/486: Re-fontify buffer after it is reverted,
ELPA Syncer <=
- [nongnu] elpa/rust-mode 01db4cb 225/486: Fix font-locking for Unicode escapes in character literals., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b874bbe 213/486: Merge pull request #113 from MicahChalmer/fix-issue-104, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2cd3cf9 216/486: Merge pull request #116 from Wilfred/type_annotation_highlighting, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 3517321 230/486: Merge pull request #129 from MicahChalmer/fix-issue-127, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8400638 241/486: update README.md and Package-Requires to require emacs 24, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c3feac1 243/486: Fill regular block comments correctly too, in addition to rustdoc comments, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1587839 268/486: Merge pull request #169 from mrBliss/fix-168, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 664c7b0 277/486: improve position recovery in rust-format-buffer, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 46e7fc0 285/486: fix PR link in README, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 35298ed 288/486: Don't use "&optional &rest", ELPA Syncer, 2021/08/07