mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
; Add some notes about narrowing, font-lock cc-mode issues
* yasnippet-tests.el (yas--with-font-locked-temp-buffer) (example-for-issue-474): * yasnippet.el (yas--snippet-create): Add commentary.
This commit is contained in:
parent
1cc1996074
commit
5b1217ab08
@ -855,6 +855,8 @@ mapconcat #'(lambda (arg)
|
|||||||
|
|
||||||
(defmacro yas--with-font-locked-temp-buffer (&rest body)
|
(defmacro yas--with-font-locked-temp-buffer (&rest body)
|
||||||
"Like `with-temp-buffer', but ensure `font-lock-mode'."
|
"Like `with-temp-buffer', but ensure `font-lock-mode'."
|
||||||
|
;; NOTE: Replace all uses of this with `font-lock-ensure' when we
|
||||||
|
;; drop support for Emacs 24.
|
||||||
(declare (indent 0) (debug t))
|
(declare (indent 0) (debug t))
|
||||||
(let ((temp-buffer (make-symbol "temp-buffer")))
|
(let ((temp-buffer (make-symbol "temp-buffer")))
|
||||||
;; NOTE: buffer name must not start with a space, otherwise
|
;; NOTE: buffer name must not start with a space, otherwise
|
||||||
@ -874,6 +876,8 @@ mapconcat #'(lambda (arg)
|
|||||||
(kill-buffer ,temp-buffer))))))))
|
(kill-buffer ,temp-buffer))))))))
|
||||||
|
|
||||||
(ert-deftest example-for-issue-474 ()
|
(ert-deftest example-for-issue-474 ()
|
||||||
|
;; This issue only reproduces in Emacs 24.3, most likely due to some
|
||||||
|
;; bug in the cc-mode included with that Emacs version.
|
||||||
(yas--with-font-locked-temp-buffer
|
(yas--with-font-locked-temp-buffer
|
||||||
(c-mode)
|
(c-mode)
|
||||||
(yas-minor-mode 1)
|
(yas-minor-mode 1)
|
||||||
|
@ -4178,9 +4178,10 @@ Returns the newly created snippet."
|
|||||||
(run-hook-with-args 'before-change-functions begin end)
|
(run-hook-with-args 'before-change-functions begin end)
|
||||||
(let ((before-change-functions nil)
|
(let ((before-change-functions nil)
|
||||||
(after-change-functions nil))
|
(after-change-functions nil))
|
||||||
;; Some versions of cc-mode fail when inserting snippet
|
;; Some versions of cc-mode (might be the one with Emacs
|
||||||
;; content in a narrowed buffer, so make sure to insert
|
;; 24.3 only) fail when inserting snippet content in a
|
||||||
;; before narrowing.
|
;; narrowed buffer, so make sure to insert before
|
||||||
|
;; narrowing.
|
||||||
(insert content)
|
(insert content)
|
||||||
(narrow-to-region begin (point))
|
(narrow-to-region begin (point))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user