[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#36897: 27.0.50; [CC Mode] c-after-change may signal error in narrowe
From: |
Alan Mackenzie |
Subject: |
bug#36897: 27.0.50; [CC Mode] c-after-change may signal error in narrowed buffer |
Date: |
2 Aug 2019 08:41:21 -0000 |
User-agent: |
tin/2.4.2-20171224 ("Lochhead") (UNIX) (FreeBSD/11.2-RELEASE-p9 (amd64)) |
Hello, Noam.
In article <mailman.507.1564705872.1985.bug-gnu-emacs@gnu.org> you wrote:
> [-- text/plain, encoding 7bit, charset: US-ASCII, 31 lines --]
> Package: emacs, cc-mode
>>From 'emacs -Q', eval the following:
> (with-current-buffer (get-buffer-create "*test*")
> (erase-buffer)
> (insert "int main()\n{\n \n}\n")
> (search-backward "\n}")
> (c-mode)
> (save-restriction
> (narrow-to-region (point) (point))
> (insert "foo")))
> Gives the backtrace:
> Debugger entered--Lisp error: (args-out-of-range 1 1)
> get-text-property(1 c-fl-syn-tab)
> c-clear-string-fences()
> #f(compiled-function () #<bytecode 0xbb39fd>)()
> c-after-change(16 19 0)
> insert("foo")
> (save-restriction (narrow-to-region (point) (point)) (insert "foo"))
> (save-current-buffer (set-buffer (get-buffer-create "*test*"))
> (erase-buffer) (insert "int main()\n{\n \n}\n") (search-backward "\n}")
> (c-mode) (save-restriction (narrow-to-region (point) (point)) (insert "foo")))
Yes, thanks. I've known about this for around a week, and I have a patch
for it prepared. I was just giving the OP who reported it to me an extra
day or two to comment on it.
> This is a reduced test case from
> https://github.com/joaotavora/eglot/issues/291.
> I think the obvious fix is to extend the save-restriction just a bit
> further to cover c-clear-string-fences, patch attached.
Yes. The "same" problem also happened in c-before-change, and my patch
fixes that, too. (Otherwise, it's pretty much the same as your patch, as
far as c-after-change is concerned.)
I'll commit my patch soon, hopefully today.
[ .... ]
--
Alan Mackenzie (Nuremberg, Germany).