From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#33871: 27.0.50; Revert Dired window saved in window configuration Date: Thu, 17 Feb 2022 19:28:18 +0200 Organization: LINKOV.NET Message-ID: <86fsohmqn9.fsf@mail.linkov.net> References: <87bm59mglk.fsf@mail.linkov.net> <87fsoo323s.fsf@gnus.org> <86h792x3wv.fsf@mail.linkov.net> <119a9c2c-e27f-6c3a-07ad-66bc76fc58cf@gmx.at> <861r05co9l.fsf@mail.linkov.net> <86zgmsne32.fsf@mail.linkov.net> <86sfsi29yc.fsf@mail.linkov.net> <1830e7af-27a8-ac7f-ba6f-fa2006139208@gmx.at> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39669"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 33871@debbugs.gnu.org, Lars Ingebrigtsen To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 17 18:58:10 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nKl2g-000A8i-Gg for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 17 Feb 2022 18:58:10 +0100 Original-Received: from localhost ([::1]:43886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKl2f-0003Ol-A6 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 17 Feb 2022 12:58:09 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:36518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKktq-0005B9-De for bug-gnu-emacs@gnu.org; Thu, 17 Feb 2022 12:49:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nKktq-0007W2-3L for bug-gnu-emacs@gnu.org; Thu, 17 Feb 2022 12:49:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nKktq-0007Um-3K for bug-gnu-emacs@gnu.org; Thu, 17 Feb 2022 12:49:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 17 Feb 2022 17:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33871 X-GNU-PR-Package: emacs Original-Received: via spool by 33871-submit@debbugs.gnu.org id=B33871.164512010728733 (code B ref 33871); Thu, 17 Feb 2022 17:49:02 +0000 Original-Received: (at 33871) by debbugs.gnu.org; 17 Feb 2022 17:48:27 +0000 Original-Received: from localhost ([127.0.0.1]:52636 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nKktH-0007TM-9V for submit@debbugs.gnu.org; Thu, 17 Feb 2022 12:48:27 -0500 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:60949) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nKktD-0007T4-DP for 33871@debbugs.gnu.org; Thu, 17 Feb 2022 12:48:25 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id AD23AE0006; Thu, 17 Feb 2022 17:48:15 +0000 (UTC) In-Reply-To: <1830e7af-27a8-ac7f-ba6f-fa2006139208@gmx.at> (martin rudalics's message of "Thu, 17 Feb 2022 11:05:56 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:227107 Archived-At: >> Instead of (goto-char p-m), after (set-window-configuration w-c) >> something like this should be performed: >> >> (dired-goto-file (car (cdr (assoc (current-buffer) >> (window-parameter nil 'dired-positions))))) > > Once more: Your scenario is > > (progn (dired "/tmp") (dired-next-line 1) > (split-window) (other-window 1) > (dired "/tmp") (dired-next-line 2) > (let ((w-c (current-window-configuration)) > (p-m (point-marker))) > (view-emacs-todo) (delete-other-windows) > (with-current-buffer (get-buffer "tmp") > (revert-buffer)) > (set-window-configuration w-c) > (goto-char p-m))) > > But this cannot work with dired buffers because they are reverted in a > special way that does not care about 'window-point' and the like. This > means that the value of 'point-marker' you saved in p-m has become just > meaningless after the 'revert-buffer' call. > > Basically, this is a hard problem we'll probably never be able to solve > satisfactorily. But this works fine: (progn (dired "/tmp") (dired-next-line 1) (split-window) (other-window 1) (dired "/tmp") (dired-next-line 2) (walk-windows (lambda (w) (set-window-parameter w 'dired-positions (list (with-selected-window w (dired-get-filename nil t)) (window-start w) (window-point w))))) (let ((w-c (current-window-configuration))) (view-emacs-todo) (delete-other-windows) (with-current-buffer (get-buffer "tmp") (revert-buffer)) (set-window-configuration w-c) (walk-windows (lambda (w) (let ((pos (window-parameter w 'dired-positions))) (when pos (with-selected-window w (dired-goto-file (nth 0 pos))) (set-window-start w (nth 1 pos)) (set-window-point w (nth 2 pos)))))))) > We could handle 'window-point' separately when saving and restoring > window configurations and the window's buffer is a dired buffer. For > example, 'dired-revert' could call a function 'window-revert-timestamp' > to store the current time of the revert operation for this window and > 'current-window-configuration' (and 'window-state-get') would store > their current time stamp in the configuration (or state). Then > 'set-window-configuration' (and 'window-state-put') could check whether > a window's revert time stamp is larger than the time stamp stored in the > configuration and not set point for that window when the revert time > stamp is later. Is it worth the hassle? I think it's not worth the hassle. The above solution is simpler.