[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Different fontification in temp buffer
From: |
Daniele Nicolodi |
Subject: |
Re: Different fontification in temp buffer |
Date: |
Sat, 19 Jan 2019 19:14:03 -0700 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 |
On 19/01/2019 17:48, Daniele Nicolodi wrote:
> Hello,
>
> I'm hacking on a minor mode and I'm writing unit tests for the
> fontification feature. I am encountering a strange issue: the
> fontification is different if execute in a temp buffer or in a regular
> buffer. In particular:
>
> (with-temp-buffer
> (insert string)
> (fundamental-mode)
> (beancount-mode)
> (font-lock-ensure)
> (buffer-string))
>
> and
>
> (with-current-buffer (generate-new-buffer "*test*")
> (insert string)
> (fundamental-mode)
> (beancount-mode)
> (font-lock-ensure)
> (buffer-string))
>
> strangely result in two different results. Why is it so?
Investigating further, the difference between the two cases is that
with-temp-buffer creates a buffer that does not keep undo information.
Surely enough, if I modify the second code to do the same (using a
buffer name starting with a space character) I obtain the same behavior.
What's left to understand is why this results in two different syntax
table being applied to the buffer.
Cheers,
Dan
Re: Different fontification in temp buffer, Stefan Monnier, 2019/01/20