branch: master
commit 763f5faa14614b207d65e03594b80ba662f47efc
Author: Noam Postavsky <[email protected]>
Commit: Noam Postavsky <[email protected]>
Closes #474: fix more cc-mode font-lock conflicts
* yasnippet-tests.el (example-for-issue-474): Don't call insert from
within backquotes, it's redundant and prevents proper testing of
backquote expansion.
* yasnippet.el (yas--restore-backquotes, yas--save-backquotes): Ensure
the buffer isn't narrowed while modifying it to avoid conflicting with
cc-mode fontification.
---
yasnippet-tests.el | 2 +-
yasnippet.el | 16 ++++++++++------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index f87b3d4..c6b878d 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -229,7 +229,7 @@
(c-mode)
(yas-minor-mode 1)
(insert "#include <foo>\n")
- (let ((yas-good-grace nil)) (yas-expand-snippet "`(insert \"TODO: \")`"))
+ (let ((yas-good-grace nil)) (yas-expand-snippet "`\"TODO: \"`"))
(should (string= (yas--buffer-contents) "#include <foo>\nTODO: "))))
(ert-deftest example-for-issue-404 ()
diff --git a/yasnippet.el b/yasnippet.el
index 43564ff..b4432b8 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -3911,9 +3911,11 @@ with their evaluated value into
`yas--backquote-markers-and-strings'."
(goto-char (match-beginning 0))
(when transformed
(let ((marker (make-marker)))
- (insert "Y") ;; quite horrendous, I love it :)
- (set-marker marker (point))
- (insert "Y")
+ (save-restriction
+ (widen)
+ (insert "Y") ;; quite horrendous, I love it :)
+ (set-marker marker (point))
+ (insert "Y"))
(push (cons marker transformed)
yas--backquote-markers-and-strings))))))
(defun yas--restore-backquotes ()
@@ -3924,9 +3926,11 @@ with their evaluated value into
`yas--backquote-markers-and-strings'."
(string (cdr marker-and-string)))
(save-excursion
(goto-char marker)
- (delete-char -1)
- (insert string)
- (delete-char 1)
+ (save-restriction
+ (widen)
+ (delete-char -1)
+ (insert string)
+ (delete-char 1))
(set-marker marker nil)))))
(defun yas--scan-sexps (from count)