From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: OGAWA Hirofumi Newsgroups: gmane.emacs.devel Subject: The issue with with-temp-buffer (or with-current-buffer) Date: Sat, 16 Dec 2017 03:25:58 +0900 Message-ID: <87d13f97bd.fsf@mail.parknet.co.jp> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1513364235 29593 195.159.176.226 (15 Dec 2017 18:57:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 15 Dec 2017 18:57:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 15 19:57:11 2017 Return-path: Envelope-to: ged-emacs-devel@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 1ePvAU-0007U3-To for ged-emacs-devel@m.gmane.org; Fri, 15 Dec 2017 19:57:11 +0100 Original-Received: from localhost ([::1]:48198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePvAb-0000Me-WF for ged-emacs-devel@m.gmane.org; Fri, 15 Dec 2017 13:57:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePugT-0006Dk-H5 for emacs-devel@gnu.org; Fri, 15 Dec 2017 13:26:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePugP-0005c3-FD for emacs-devel@gnu.org; Fri, 15 Dec 2017 13:26:09 -0500 Original-Received: from mail.parknet.co.jp ([210.171.160.6]:52510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePugP-0005ZK-4T for emacs-devel@gnu.org; Fri, 15 Dec 2017 13:26:05 -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 4DE83170001 for ; Sat, 16 Dec 2017 03:26:01 +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 vBFIPxBe030588 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 16 Dec 2017 03:26:01 +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 vBFIPxtI011731 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 16 Dec 2017 03:25:59 +0900 Original-Received: (from hirofumi@localhost) by devron.myhome.or.jp (8.15.2/8.15.2/Submit) id vBFIPwqi011728; Sat, 16 Dec 2017 03:25:58 +0900 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 210.171.160.6 X-Mailman-Approved-At: Fri, 15 Dec 2017 13:56:31 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221109 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") ;; start suspect (with-temp-buffer (save-window-excursion (set-window-buffer nil (current-buffer)))) ;; end suspect (insert "2\n"))) and expected result is ---- test-case ---- 2 1 ------------------- But actual result is ---- test-case ---- 1 2 ------------------- [The actual issue that I'm hitted was using `shr-insert-document' like following. And above is simplied version to reproduce the issue. (with-current-buffer buf (erase-buffer) (insert ...) (shr-insert-document '(html nil (body nil ...))) (insert ...))) ] After some debugging, I noticed `with-current-buffer' that is used in `with-temp-buffer' doesn't restore `point'. And if I replaced `with-current-buffer' with save-excursion+set-buffer, the issue is fixed. I.e. from (with-temp-buffer to (save-excursion (set-buffer ,temp-buffer) Well so, this behavior (doesn't restore point) of `with-temp-buffer' (or `with-current-buffer') is intented or bug? And to fix this issue, we should change which one of with-temp-buffer, with-current-buffer, shr-insert-document, or user of shr-insert-document? Thanks. -- OGAWA Hirofumi