From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: OGAWA Hirofumi Newsgroups: gmane.emacs.bugs Subject: bug#29734: 27.0.50; shr-insert-document modify point of buffer in corner case Date: Sat, 16 Dec 2017 21:47:07 +0900 Message-ID: <87shca7sc4.fsf@mail.parknet.co.jp> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1513428491 14416 195.159.176.226 (16 Dec 2017 12:48:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 16 Dec 2017 12:48:11 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: 29734@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 16 13:48:07 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQBss-0003NN-A2 for geb-bug-gnu-emacs@m.gmane.org; Sat, 16 Dec 2017 13:48:06 +0100 Original-Received: from localhost ([::1]:50440 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQBsz-0003jU-Cj for geb-bug-gnu-emacs@m.gmane.org; Sat, 16 Dec 2017 07:48:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQBst-0003jD-Mc for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2017 07:48:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQBso-0002IM-Qd for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2017 07:48:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56041) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eQBso-0002IG-MJ for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2017 07:48:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eQBso-0006Md-Fm for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2017 07:48:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: OGAWA Hirofumi Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Dec 2017 12:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 29734 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.151342844724413 (code B ref -1); Sat, 16 Dec 2017 12:48:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Dec 2017 12:47:27 +0000 Original-Received: from localhost ([127.0.0.1]:36489 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQBsE-0006Lh-Sl for submit@debbugs.gnu.org; Sat, 16 Dec 2017 07:47:27 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:48292) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQBsD-0006LU-Ar for submit@debbugs.gnu.org; Sat, 16 Dec 2017 07:47:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQBs6-0001t2-QL for submit@debbugs.gnu.org; Sat, 16 Dec 2017 07:47:20 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:60715) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eQBs6-0001sn-NU for submit@debbugs.gnu.org; Sat, 16 Dec 2017 07:47:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQBs5-0003fK-Ed for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2017 07:47:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQBs0-0001pW-Fw for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2017 07:47:17 -0500 Original-Received: from mail.parknet.co.jp ([210.171.160.6]:35267) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQBrz-0001p1-Ts for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2017 07:47:12 -0500 Original-Received: from ibmpc.myhome.or.jp (server.parknet.ne.jp [210.171.168.39]) by mail.parknet.co.jp (Postfix) with ESMTP id 81FBC1E0018 for ; Sat, 16 Dec 2017 21:47:09 +0900 (JST) Original-Received: from devron.myhome.or.jp (root@devron.myhome.or.jp [192.168.0.3]) by ibmpc.myhome.or.jp (8.15.2/8.15.2/Debian-9) with ESMTPS id vBGCl8Ap012687 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 16 Dec 2017 21:47:09 +0900 Original-Received: from devron.myhome.or.jp (hirofumi@localhost [127.0.0.1]) by devron.myhome.or.jp (8.15.2/8.15.2/Debian-9) with ESMTPS id vBGCl8OB022557 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 16 Dec 2017 21:47:08 +0900 Original-Received: (from hirofumi@localhost) by devron.myhome.or.jp (8.15.2/8.15.2/Submit) id vBGCl79D022556; Sat, 16 Dec 2017 21:47:07 +0900 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:141152 Archived-At: Hi, The following is the reproduce code of issue, (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. --- lisp/net/shr.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff -puN lisp/net/shr.el~shr-fix-point-modification lisp/net/shr.el --- emacs/lisp/net/shr.el~shr-fix-point-modification 2017-12-16 07:32:47.777230050 +0900 +++ emacs-hirofumi/lisp/net/shr.el 2017-12-16 07:35:48.083847035 +0900 @@ -591,9 +591,10 @@ size, and full-buffer size." (defun shr-string-pixel-width (string) (if (not shr-use-fonts) (length string) - (with-temp-buffer - (insert string) - (shr-pixel-column)))) + (save-excursion + (with-temp-buffer + (insert string) + (shr-pixel-column))))) (defsubst shr--translate-insertion-chars () ;; Remove soft hyphens. _ In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.24) of 2017-12-12 built on devron Repository revision: 786907238bcb86ab9e0e2e9ebcc91c52a6eb024c Windowing system distributor 'The X.Org Foundation', version 11.0.11905000 System Description: Debian GNU/Linux testing (buster) Configured using: 'configure --libexecdir=/usr/local/lib --with-x --with-x-toolkit=gtk3 --without-xim --with-xpm --with-jpeg --with-tiff --with-gif --with-png --with-rsvg --with-dbus --with-wide-int --with-modules' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES JSON LCMS2 Important settings: value of $LANG: ja_JP.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix -- OGAWA Hirofumi