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: Wed, 21 Feb 2024 19:18:17 +0200 Organization: LINKOV.NET Message-ID: <86v86hwxbe.fsf@mail.linkov.net> References: <87bm59mglk.fsf@mail.linkov.net> <86zgmsne32.fsf@mail.linkov.net> <86sfsi29yc.fsf@mail.linkov.net> <1830e7af-27a8-ac7f-ba6f-fa2006139208@gmx.at> <86fsohmqn9.fsf@mail.linkov.net> <9df28298-fedc-0cfe-7243-c04868115e90@gmx.at> <86fsoezsw3.fsf@mail.linkov.net> <86sfsewvxr.fsf@mail.linkov.net> <9d741b43-e3bb-669b-b345-6b877c902b33@gmx.at> <86fsoaq4lo.fsf@mail.linkov.net> <86tucp7dbp.fsf@mail.linkov.net> <37e2129c-464f-7f0a-0870-f7360ca21dc3@gmx.at> <86zfw07tbw.fsf@mail.linkov.net> <96fd3170-e5d2-4d16-93ec-c6fff3efb787@gmx.at> <86wmr2w7to.fsf@mail.linkov.net> <3808f9f8-624a-449c-8572-085582395859@gmx.at> <86y1bffvya.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28815"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 33871@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 21 18:40:23 2024 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 1rcqZz-0007Ob-0l for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 21 Feb 2024 18:40:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcqZK-0000zZ-PC; Wed, 21 Feb 2024 12:39:42 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcqZJ-0000q1-4T for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2024 12:39:41 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rcqZI-0003J3-SW for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2024 12:39:40 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rcqZf-0003s7-8V for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2024 12:40:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Feb 2024 17:40:03 +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.170853719014811 (code B ref 33871); Wed, 21 Feb 2024 17:40:03 +0000 Original-Received: (at 33871) by debbugs.gnu.org; 21 Feb 2024 17:39:50 +0000 Original-Received: from localhost ([127.0.0.1]:57165 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcqZR-0003qn-Ha for submit@debbugs.gnu.org; Wed, 21 Feb 2024 12:39:49 -0500 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:56325) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcqZP-0003q3-0s for 33871@debbugs.gnu.org; Wed, 21 Feb 2024 12:39:47 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 396CF1C0007; Wed, 21 Feb 2024 17:38:55 +0000 (UTC) In-Reply-To: (martin rudalics's message of "Wed, 21 Feb 2024 10:05:11 +0100") X-GND-Sasl: juri@linkov.net 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:280409 Archived-At: >> (setq-default window-use-context-function >> (lambda (w context) >> (let ((point (window-point w))) >> (with-current-buffer (window-buffer w) > > I suppose that in the general case you need a > > (save-excursion Thanks. I just noticed this is broken in two windows case, and your suggestion fixed it. > Probably something similar is needed for dired, for example to handle > the case where its buffer is simultaneously shown in two windows with > their points on different lines. So here is the same for dired: diff --git a/lisp/dired.el b/lisp/dired.el index 9e3b888df14..0510db1c409 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2743,6 +2745,26 @@ dired-mode '(dired-font-lock-keywords t nil nil beginning-of-line)) (setq-local desktop-save-buffer 'dired-desktop-buffer-misc-data) (setq-local grep-read-files-function #'dired-grep-read-files) + (setq-local window-set-context-function + (lambda (w) + (let ((point (window-point w))) + (with-current-buffer (window-buffer w) + (save-excursion + (goto-char point) + (if-let ((f (dired-get-filename nil t))) + `((dired-filename . ,f)) + `((position . ,(point))))))))) + (setq-local window-use-context-function + (lambda (w context) + (let ((point (window-point w))) + (with-current-buffer (window-buffer w) + (save-excursion + (if-let ((f (alist-get 'dired-filename context))) + (dired-goto-file f) + (when-let ((p (alist-get 'position context))) + (goto-char p))) + (setq point (point)))) + (set-window-point w point)))) (setq dired-switches-alist nil) (hack-dir-local-variables-non-file-buffer) ; before sorting (dired-sort-other dired-actual-switches t)