From: Philip Kaludercic <philipk@posteo.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 65380@debbugs.gnu.org, juri@linkov.net
Subject: bug#65380: [PATCH] Add command to copy contents in a diff-mode buffer
Date: Sun, 18 Aug 2024 16:20:52 +0000 [thread overview]
Message-ID: <87bk1pztsr.fsf@posteo.net> (raw)
In-Reply-To: <864j7hzviv.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 18 Aug 2024 18:43:36 +0300")
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Philip Kaludercic <philipk@posteo.net>
>> 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?
No, you were right, and I manged to locate what was causing the issue.
I had a (revert-buffer t t t) at the beginning of the function.
Wrapping `save-window-start' around just that expression also prevented
the displayed portion of the window from changing.
Thinking about the proposal again, it might seem better to avoid calling
`revert-buffer' in the first place. The problem I was concerned with
was that if a .diff was outdated, jumping to the original file might not
do the right thing and copy the wrong inter-hunk text. Now I realise
that `revert-buffer' doesn't always help resolve this either, e.g. if
copying text from an old .patch file.
The proper solution would be to try and detect these kinds of
inconsistencies and signal and error instead.
>> 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.)
It is not needed, but I would be interested in what the conceptual
errors are.
--
Philip Kaludercic on peregrine
next prev parent reply other threads:[~2024-08-18 16:20 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-19 9:53 bug#65380: [PATCH] Add command to copy contents in a diff-mode buffer Philip Kaludercic
2023-08-19 10:00 ` Philip Kaludercic
2023-08-20 0:59 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-20 7:52 ` Philip Kaludercic
2023-08-19 10:46 ` Eli Zaretskii
2023-08-19 10:48 ` Philip Kaludercic
2023-08-19 11:06 ` Eli Zaretskii
2023-08-19 15:45 ` Philip Kaludercic
2023-08-19 19:09 ` Eli Zaretskii
2023-08-19 19:30 ` Philip Kaludercic
2023-08-19 21:01 ` Sean Whitton
2023-08-19 22:49 ` Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-20 0:41 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-20 16:30 ` Juri Linkov
2023-08-20 18:17 ` Eli Zaretskii
2023-08-20 18:24 ` Philip Kaludercic
2023-08-20 18:29 ` Eli Zaretskii
2023-08-22 11:06 ` Philip Kaludercic
2023-08-22 11:29 ` Eli Zaretskii
2024-08-17 16:34 ` Philip Kaludercic
2024-08-18 15:29 ` Philip Kaludercic
2024-08-18 15:43 ` Eli Zaretskii
2024-08-18 16:20 ` Philip Kaludercic [this message]
2024-08-18 18:00 ` Eli Zaretskii
2024-08-19 19:34 ` Philip Kaludercic
2024-08-20 6:44 ` Juri Linkov
2024-08-20 7:46 ` Philip Kaludercic
2024-08-20 16:53 ` Juri Linkov
2024-08-20 11:36 ` Eli Zaretskii
2024-08-20 12:10 ` Philip Kaludercic
2024-08-20 13:09 ` Eli Zaretskii
2024-08-20 16:23 ` Philip Kaludercic
2024-08-20 18:43 ` Eli Zaretskii
2024-08-20 21:35 ` Philip Kaludercic
2024-08-21 13:42 ` Eli Zaretskii
2024-08-21 19:40 ` Philip Kaludercic
2024-08-22 3:25 ` Eli Zaretskii
2024-08-22 6:41 ` Philip Kaludercic
2024-08-22 10:22 ` Eli Zaretskii
2024-08-22 18:59 ` Philip Kaludercic
2023-08-20 19:47 ` Jim Porter
2023-08-20 20:13 ` Gregory Heytings
2023-08-20 20:45 ` Jim Porter
2023-08-20 21:29 ` Gregory Heytings
2023-08-20 22:21 ` Jim Porter
2023-08-20 22:31 ` Gregory Heytings
2023-08-20 23:39 ` Gregory Heytings
2023-08-21 0:34 ` Jim Porter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bk1pztsr.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=65380@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=juri@linkov.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.