GNU bug report logs -
#65380
[PATCH] Add command to copy contents in a diff-mode buffer
Previous Next
Reported by: Philip Kaludercic <philipk <at> posteo.net>
Date: Sat, 19 Aug 2023 09:55:01 UTC
Severity: normal
Tags: patch
Done: Philip Kaludercic <philipk <at> posteo.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> I'm attaching the newest version of the patch here:
Thanks, I tried it out, and it works nicely for the single hunk case.
> +*** New command 'diff-kill-ring-save'
> +This command copies out the modified contents out of a diff, without
> +having to apply it first. If the selected range extends a hunk, the
> +commands attempts to look up and copy the text between from the
> +referenced file.
I'm not sure about usefulness of the last part in multi-hunk case.
Does someone really need to copy a huge part of the source file
between hunks at the top and bottom? I expected that multi-hunk case
would copy only concatenated text of hunks, not the source file.
But I have no strong opinion about this. My main use case will be
to copy the text of the current hunk. Could you please support
this case where typing 'w' would copy the current hunk when the
region is not activated.
> @@ -630,6 +631,22 @@ diff-end-of-hunk
> +(defun diff-beginning-of-hunk-position (&optional try-harder)
> + "Call `diff-end-of-hunk' without moving.
> +The optional argument TRY-HARDER is passed on to
> +`diff-beginning-of-hunk'."
> + (save-excursion
> + (save-window-excursion
> + (diff-beginning-of-hunk try-harder))))
> +
> +(defun diff-end-of-hunk-position (&optional style donttrustheader)
> + "Call `diff-end-of-hunk' without moving.
> +The optional arguments STYLE and DONTTRUSTHEADER are passed on to
> +`diff-end-of-hunk'."
> + (save-excursion
> + (save-window-excursion
> + (diff-end-of-hunk style donttrustheader))))
I don't understand why separate functions with 'save-window-excursion'
are needed here, since all other uses of 'diff-beginning-of-hunk'
just wrap the calls with 'save-excursion'.
This bug report was last modified 273 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.