GNU bug report logs - #29734
27.0.50; shr-insert-document modify point of buffer in corner case

Previous Next

Package: emacs;

Reported by: OGAWA Hirofumi <hirofumi <at> mail.parknet.co.jp>

Date: Sat, 16 Dec 2017 12:48:02 UTC

Severity: normal

Found in version 27.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 29734 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: OGAWA Hirofumi <hirofumi <at> mail.parknet.co.jp>
Cc: 29734 <at> debbugs.gnu.org
Subject: Re: bug#29734: 27.0.50;
 shr-insert-document modify point of buffer in corner case
Date: Sat, 16 Dec 2017 16:12:26 +0200
> From: OGAWA Hirofumi <hirofumi <at> mail.parknet.co.jp>
> Date: Sat, 16 Dec 2017 21:47:07 +0900
> 
> (let ((buf (get-buffer-create "test-case")))
>   (display-buffer buf)
>   (with-current-buffer buf
>     (erase-buffer)
>     (insert "1\n")
>     (shr-insert-document
>      '(html nil (body nil (a ((href . "http://example.org")) "example"))))
>     (insert "\n")
>     (insert "2\n")))
> 
> and expected result is
> 
> 	1
> 	example
> 	2
> 
> But actual result is
> 
> 	example
> 	2
> 	1
> 
> Like above example, `shr-insert-document' modify the point
> of "test-case" buffer. (display-buffer is important to
> reproduce. If commented out display-buffer line, the issue
> disappear.)
> 
> With some debugging I noticed, the usage of `with-temp-buffer' of
> `shr-string-pixel-width' modify the point. Simplified version of
> `shr-string-pixel-width' to reproduce the issue is the following,
> 
>     (with-temp-buffer
>       (save-window-excursion
> 	(set-window-buffer nil (current-buffer))))
> 
> In this conbination, `with-temp-buffer' seems to fail to restore
> the point.
> 
> So the patch seems to save and restore the point correctly.

Thanks.

I think save-excursion is too heavy in this case, so I installed a
change to only preserve point.

Please try the recent emacs-26 branch, it should now be fixed there.




This bug report was last modified 7 years and 243 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.