* Thoughts on support for vc-diff unsaved buffer contents?
@ 2024-11-21 22:02 Campbell Barton
2024-11-22 0:04 ` James Thomas
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Campbell Barton @ 2024-11-21 22:02 UTC (permalink / raw)
To: emacs-devel
Hi, recently I've run into a situation where it's necessary to calculate
modified line ranges without first saving the buffer (where "modified"
is determined by a version control diff).
I'm curious if this is something that might be supported - or, is
already supported (although I'm fairly sure it's not).
The use case is for auto-formatters only to format modified lines.
This particular case is for clang-format.el although the same
functionality could useful for other formatters too.
clang-format.el can be configured to format on save,
so when saving: clang-format.el calculates the lines that differ from
the working copy them formats them before saving.
Currently it's necessary for clang-format.el to call git & diff
directly, which makes the functionality limited to git. I was hoping
this could be supported in a generic way that uses generic `vc` API's.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Thoughts on support for vc-diff unsaved buffer contents?
2024-11-21 22:02 Thoughts on support for vc-diff unsaved buffer contents? Campbell Barton
@ 2024-11-22 0:04 ` James Thomas
2024-11-22 6:05 ` Alfred M. Szmidt
2024-11-22 7:44 ` Juri Linkov
2 siblings, 0 replies; 6+ messages in thread
From: James Thomas @ 2024-11-22 0:04 UTC (permalink / raw)
To: emacs-devel
Campbell Barton wrote:
> Hi, recently I've run into a situation where it's necessary to
> calculate modified line ranges without first saving the buffer (where
> "modified" is determined by a version control diff).
>
> I'm curious if this is something that might be supported - or, is
> already supported (although I'm fairly sure it's not).
>
> ...
>
> so when saving: clang-format.el calculates the lines that differ from
> the working copy them formats them before saving.
>
> Currently it's necessary for clang-format.el to call git & diff
> directly, which makes the functionality limited to git. I was hoping
> this could be supported in a generic way that uses generic `vc` API's.
Isn't it enough to pipe vc-find-revision-no-save of vc-working-revision to
diff? (IIUYC)
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Thoughts on support for vc-diff unsaved buffer contents?
2024-11-21 22:02 Thoughts on support for vc-diff unsaved buffer contents? Campbell Barton
2024-11-22 0:04 ` James Thomas
@ 2024-11-22 6:05 ` Alfred M. Szmidt
2024-11-22 7:44 ` Juri Linkov
2 siblings, 0 replies; 6+ messages in thread
From: Alfred M. Szmidt @ 2024-11-22 6:05 UTC (permalink / raw)
To: Campbell Barton; +Cc: emacs-devel
Hi, recently I've run into a situation where it's necessary to calculate
modified line ranges without first saving the buffer (where "modified"
is determined by a version control diff).
I'm curious if this is something that might be supported - or, is
already supported (although I'm fairly sure it's not).
Maybe diff-buffer-with-file?
The use case is for auto-formatters only to format modified lines.
This particular case is for clang-format.el although the same
functionality could useful for other formatters too.
clang-format.el can be configured to format on save,
so when saving: clang-format.el calculates the lines that differ from
the working copy them formats them before saving.
Currently it's necessary for clang-format.el to call git & diff
directly, which makes the functionality limited to git. I was hoping
this could be supported in a generic way that uses generic `vc` API's.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Thoughts on support for vc-diff unsaved buffer contents?
2024-11-21 22:02 Thoughts on support for vc-diff unsaved buffer contents? Campbell Barton
2024-11-22 0:04 ` James Thomas
2024-11-22 6:05 ` Alfred M. Szmidt
@ 2024-11-22 7:44 ` Juri Linkov
2024-11-22 9:05 ` Campbell Barton
2 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2024-11-22 7:44 UTC (permalink / raw)
To: Campbell Barton; +Cc: emacs-devel
> Hi, recently I've run into a situation where it's necessary to calculate
> modified line ranges without first saving the buffer (where "modified" is
> determined by a version control diff).
>
> I'm curious if this is something that might be supported - or, is already
> supported (although I'm fairly sure it's not).
'diff-no-select' as well as 'multi-file-diff-no-select' accept
unsaved buffers as their arguments.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Thoughts on support for vc-diff unsaved buffer contents?
2024-11-22 7:44 ` Juri Linkov
@ 2024-11-22 9:05 ` Campbell Barton
2024-11-23 17:58 ` Juri Linkov
0 siblings, 1 reply; 6+ messages in thread
From: Campbell Barton @ 2024-11-22 9:05 UTC (permalink / raw)
To: emacs-devel
On 24-11-22 6:44 PM, Juri Linkov wrote:
>> Hi, recently I've run into a situation where it's necessary to calculate
>> modified line ranges without first saving the buffer (where "modified" is
>> determined by a version control diff).
>>
>> I'm curious if this is something that might be supported - or, is already
>> supported (although I'm fairly sure it's not).
>
> 'diff-no-select' as well as 'multi-file-diff-no-select' accept
> unsaved buffers as their arguments.
Thanks for the suggestion.
The part I'm not sure about regarding `diff-no-select' &
`diff-buffer-with-file' is how they could work with version-control
(vc-diff or a related functions).
As far as I can see the diff needs to be generated by version-control
(git/hg/svn etc) instead of a file - since the "original" file
necessarily exist as a file on disk.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Thoughts on support for vc-diff unsaved buffer contents?
2024-11-22 9:05 ` Campbell Barton
@ 2024-11-23 17:58 ` Juri Linkov
0 siblings, 0 replies; 6+ messages in thread
From: Juri Linkov @ 2024-11-23 17:58 UTC (permalink / raw)
To: Campbell Barton; +Cc: emacs-devel
>>> Hi, recently I've run into a situation where it's necessary to calculate
>>> modified line ranges without first saving the buffer (where "modified" is
>>> determined by a version control diff).
>>>
>>> I'm curious if this is something that might be supported - or, is already
>>> supported (although I'm fairly sure it's not).
>> 'diff-no-select' as well as 'multi-file-diff-no-select' accept
>> unsaved buffers as their arguments.
>
> Thanks for the suggestion.
>
> The part I'm not sure about regarding `diff-no-select' &
> `diff-buffer-with-file' is how they could work with version-control
> (vc-diff or a related functions).
>
> As far as I can see the diff needs to be generated by version-control
> (git/hg/svn etc) instead of a file - since the "original" file necessarily
> exist as a file on disk.
Probably there is no such existing function that uses vc-diff
(and one of the backend commands such as vc-git-diff)
on an unsaved working revision.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-23 17:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-21 22:02 Thoughts on support for vc-diff unsaved buffer contents? Campbell Barton
2024-11-22 0:04 ` James Thomas
2024-11-22 6:05 ` Alfred M. Szmidt
2024-11-22 7:44 ` Juri Linkov
2024-11-22 9:05 ` Campbell Barton
2024-11-23 17:58 ` Juri Linkov
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.