From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.bugs Subject: bug#24240: 25.1.50; window-state-put, image-mode and window scrolling Date: Tue, 16 Aug 2016 01:05:11 +0200 Message-ID: <87bn0ttyzc.fsf@hochschule-trier.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1471302380 24724 195.159.176.226 (15 Aug 2016 23:06:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 15 Aug 2016 23:06:20 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) To: 24240@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 16 01:06:16 2016 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 1bZQxT-00065L-6s for geb-bug-gnu-emacs@m.gmane.org; Tue, 16 Aug 2016 01:06:15 +0200 Original-Received: from localhost ([::1]:39209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZQxQ-0008P8-EC for geb-bug-gnu-emacs@m.gmane.org; Mon, 15 Aug 2016 19:06:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZQxK-0008P0-SH for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2016 19:06:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZQxG-0002eG-Jk for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2016 19:06:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60932) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZQxG-0002eC-GS for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2016 19:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bZQxG-0004kD-8i for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2016 19:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andreas Politz Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Aug 2016 23:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 24240 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.147130233918202 (code B ref -1); Mon, 15 Aug 2016 23:06:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Aug 2016 23:05:39 +0000 Original-Received: from localhost ([127.0.0.1]:58644 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZQwt-0004jW-5T for submit@debbugs.gnu.org; Mon, 15 Aug 2016 19:05:39 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:60252) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZQwr-0004jI-5F for submit@debbugs.gnu.org; Mon, 15 Aug 2016 19:05:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZQwk-0002b8-TC for submit@debbugs.gnu.org; Mon, 15 Aug 2016 19:05:31 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:43123) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZQwk-0002aT-Qp for submit@debbugs.gnu.org; Mon, 15 Aug 2016 19:05:30 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZQwi-0008Mq-K0 for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2016 19:05:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZQwe-0002ZD-Bz for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2016 19:05:27 -0400 Original-Received: from gateway-a.fh-trier.de ([143.93.54.181]:59821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZQwe-0002Z3-24 for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2016 19:05:24 -0400 X-Virus-Scanned: by Amavisd-new + McAfee uvscan + ClamAV [Rechenzentrum Hochschule Trier (RZ/HT)] Original-Received: from localhost (ip5f5bdf4d.dynamic.kabel-deutschland.de [95.91.223.77]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: politza) by gateway-a.fh-trier.de (Postfix) with ESMTPSA id 91FF21797D0F for ; Tue, 16 Aug 2016 01:05:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha1; c=simple/simple; d=hochschule-trier.de; s=default; t=1471302311; bh=H3/b0cN8hYRuRajMe51ybHbTJ4U=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=oQDoAQDBeC78JsxQHBEz4+PPG487uy7+NmL249QJ5UVlx5Ig8YkmmMXCb7zc2Rph3 IU8Fx/DdMxUdNX9HXUjOgDsnqO+2b/dKxEBn26fJv6qWqMoWu7o7pJ50RdiRH7cMg3 25L712hbqAXWPmSqVztMy6qpSRQzzC4TIR/Pnyd4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:122260 Archived-At: --=-=-= Content-Type: text/plain There is a conflict between window-state-put and image-mode and maybe other modes. The function image-mode-reapply-winprops gets called as soon as window-state-put displays the image buffer in some window via window-configuration-change-hook and applies the image's previously stored scroll-values. But window-state-put is not done yet and it has it's own understanding of how the window should be scrolled, thereby overriding images-mode's scrolling. I guess ideally window-state-put should be atomic in the sense that it delays these kinds of hooks until the window is completely restored. Below is a recipe and I attached a workaround. -ap -- Let's start with emacs -Q and find some image file: C-x C-f foo.png RET Maybe enlarge the image, such that it can be scrolled. Move the image (C-n), such that vscroll is greater 0. (window-vscroll) => 37 Save the window state, (setq wst (window-state-get)) and switch to the *scratch* buffer. (current-buffer) => # Now restore the previously saved window state (window-state-put wst) ,which should bring back the image buffer. But notice, how vscroll seems to be 0, i.e. display starts at the top of image. Finally evaluate any expression in the mini-buffer M-: t RET which triggers image-mode-reapply-winprops scrolling the image as expected. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=window-state-put-workaround.el Content-Transfer-Encoding: quoted-printable ;; Workaround 1 (does not work, why ?) (defun window-state-put-workaround (fn &rest args) (let (window-configuration-change-hook) (apply fn args)) (run-window-configuration-change-hook)) (advice-add 'window-state-put :around #'window-state-put-workaround) ;; Workaround 2 (does work) (defun window-state-put-workaround (&rest _args) (run-with-idle-timer 0 nil #'run-window-configuration-change-hook)) (advice-add 'window-state-put :after #'window-state-put-workaround) --=-=-=--