unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* 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; 4+ 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] 4+ 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; 4+ 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] 4+ 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; 4+ 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] 4+ 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; 4+ 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] 4+ messages in thread

end of thread, other threads:[~2024-11-22  7:44 UTC | newest]

Thread overview: 4+ 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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).