From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#65380: [PATCH] Add command to copy contents in a diff-mode buffer Date: Sun, 18 Aug 2024 18:43:36 +0300 Message-ID: <864j7hzviv.fsf@gnu.org> References: <87wmxrwe6h.fsf@posteo.net> <83o7j3z4wm.fsf@gnu.org> <87pm3jwboc.fsf@posteo.net> <83lee7z3xs.fsf@gnu.org> <87jztrvxx2.fsf@posteo.net> <83r0nyyhlz.fsf@gnu.org> <86o7j2qgmc.fsf@mail.linkov.net> <83cyzhwpcj.fsf@gnu.org> <87a5ultvuy.fsf@posteo.net> <83a5ulwos6.fsf@gnu.org> <87fs4bgwuj.fsf@posteo.net> <83fs4btiw1.fsf@gnu.org> <871q2n152u.fsf@posteo.net> <87frr1zw6i.fsf@posteo.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6298"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65380@debbugs.gnu.org, juri@linkov.net To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 18 17:44:35 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 1sfi54-0001Vp-KW for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Aug 2024 17:44:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sfi4t-0006ts-5W; Sun, 18 Aug 2024 11:44:23 -0400 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 1sfi4r-0006tL-TA for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 11:44:21 -0400 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 1sfi4r-0007qT-KQ for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 11:44:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=arIdTFGTgeutDG88AGgP06HLtPFZIy9An2AUONS1Lg0=; b=BEuHAKd/pI+K61bi1zF/K8bKaaP/WKWL2PeUr+rI3OY2US+I2+O8sQzTsg86oucATD9CamYcRqIirhTfSEMeMfDBJdkTRth2UaAJi7Wbgpws8d0Zx6RSSQ6LNrIVlMQWjbvV3WPIdAiF6axlcW5zJet+rcmm4hjXxzDw73pBC555syjrR2p0kxnqBigurrAGIbYwIXRGu3cTeXIVvm9Vp6jEf3LzTuREicmFhNQYRr80zAW19Yf4sTV/ffLwuVgA/x61GQCrl/PzNg2lYO1Euo6bbHxa0WpYi5D5uXoMgkYFVnwwJU62ksBrN4OmYWqkH5wRTbd1GOomHSkMXKBbWA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sfi5W-00020g-1C for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 11:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Aug 2024 15:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65380 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 65380-submit@debbugs.gnu.org id=B65380.17239958687668 (code B ref 65380); Sun, 18 Aug 2024 15:45:02 +0000 Original-Received: (at 65380) by debbugs.gnu.org; 18 Aug 2024 15:44:28 +0000 Original-Received: from localhost ([127.0.0.1]:56515 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfi4x-0001zc-IU for submit@debbugs.gnu.org; Sun, 18 Aug 2024 11:44:27 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39276) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfi4v-0001zO-PE for 65380@debbugs.gnu.org; Sun, 18 Aug 2024 11:44:26 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sfi4A-0007ne-Vv; Sun, 18 Aug 2024 11:43:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=arIdTFGTgeutDG88AGgP06HLtPFZIy9An2AUONS1Lg0=; b=noQYkeT5FrFM IaVbz/n8324Wk0dm+ef7B60e2lQjg/rRAuJkO9n9/y+laJNk6cqYgKy6wSQ4P0mM889nOcD4lgCzp c1ATk1ycRxkzmlSqP2/CoYl0HuZZys5dvAfxgnaJNloMeC+WRV8sjlcjKJUWCUbsw1my0jPgqEfg+ 6619ivD+e3lIedRwaSr/CvD5HYFYCjsHm8C6kOpvAW6I60iZRenv2mxtnfqiPsIh2RYgChjXZTyFf tPmsZlQKvQEEum28SdYMEIWlv/VEE2CS0YQReoPzbohW1e2+/804qBWYf3I4L9TCn3OujwdyeAcgY TiflaWDDU4RsftlxFRX7Dg==; In-Reply-To: <87frr1zw6i.fsf@posteo.net> (message from Philip Kaludercic on Sun, 18 Aug 2024 15:29:25 +0000) 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:290330 Archived-At: > From: Philip Kaludercic > Cc: juri@linkov.net, 65380@debbugs.gnu.org > Date: Sun, 18 Aug 2024 15:29:25 +0000 > > > + ;; copy the text between hunks > > + (let (start) > > + (save-window-excursion > > + (save-excursion > > + (forward-line -1) > > + (diff-goto-source) > > + (forward-line +1) > > + (setq start (point)))) > > One issue I still have here is that the `forwarad-line' might scroll the > window, which `save-window-excursion' doesn't restore. I don't understand what you are saying here. As long as a Lisp program runs and doesn't force redisplay (via sit-for or explicit calls to 'redisplay' or somesuch), forwarad-line cannot cause any scroll of the window, because what scrolls the window is redisplay when it kicks in and finds that point is outside of the window. So if the above code takes care to restore point before it finishes, the window won't scroll. Or what am I missing? > To fix this I have written a general macro for subr.el to restore > the scroll position: Let's first make sure we understand what happens here before we add such a macro. (It also has some conceptual problems of its own, but let's defer that until we actually sure it is needed.)