all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Tweaking magit/diff mode to be more helpful in text editing
@ 2016-05-31  6:49 Eric Abrahamsen
  2016-05-31  7:48 ` Yuri Khan
  2016-05-31  7:55 ` tomas
  0 siblings, 2 replies; 7+ messages in thread
From: Eric Abrahamsen @ 2016-05-31  6:49 UTC (permalink / raw)
  To: help-gnu-emacs

So I do a fair amount of writing in Org, in files that are kept in a git
repository, and I've found that, when editing large documents, it can be
nice to have the Magit Diff buffer open to one side, which I can refresh
from time to time and see the edits I've made. It's kind of an
alternative to Track Changes, etc.

I've set `magit-diff-refine-hunk' to 'all, and that helps distinguish
the actual edits from the fact that the paragraphs have been re-filled.
It's not ideal, but it's okay.

I'm currently editing someone else's (very long) document, and instead
of actually using track changes in LibreOffice, I'd much rather give him
a clean odt document exported from Org, and along with that an html
document made using diff2html or one of the other similar tools, so he
can check the edits if he wants.

What I'd really like is to find a way (either a diff algorithm or a
Magit tweak) of only showing the actual edits, not the filling. And then
to still be able to export that in a way that will allow me to give the
author a file only showing those edits.

Does anyone have any clever ideas in that direction?

Thanks!
Eric




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Tweaking magit/diff mode to be more helpful in text editing
  2016-05-31  6:49 Tweaking magit/diff mode to be more helpful in text editing Eric Abrahamsen
@ 2016-05-31  7:48 ` Yuri Khan
  2016-06-01  3:08   ` Eric Abrahamsen
  2016-05-31  7:55 ` tomas
  1 sibling, 1 reply; 7+ messages in thread
From: Yuri Khan @ 2016-05-31  7:48 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: help-gnu-emacs@gnu.org

On Tue, May 31, 2016 at 12:49 PM, Eric Abrahamsen
<eric@ericabrahamsen.net> wrote:

> What I'd really like is to find a way (either a diff algorithm or a
> Magit tweak) of only showing the actual edits, not the filling. And then
> to still be able to export that in a way that will allow me to give the
> author a file only showing those edits.
>
> Does anyone have any clever ideas in that direction?

I have an idea.
Whether it’s clever or stupid, is up to you.

Do not fill paragraphs based on line width.
Wrap lines at stable positions based on sentence structure
such as sentence and clause boundaries
like I’m doing here.

This way, diffs will be compact
(the worst case is when a single line grows too long
and you split it at a logical point near the middle)
and line breaks will be eliminated anyway
when the document is rendered to HTML
or whatever other form.

(One disadvantage is that it looks like a poem.)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Tweaking magit/diff mode to be more helpful in text editing
  2016-05-31  6:49 Tweaking magit/diff mode to be more helpful in text editing Eric Abrahamsen
  2016-05-31  7:48 ` Yuri Khan
@ 2016-05-31  7:55 ` tomas
  2016-06-01  4:00   ` Eric Abrahamsen
  1 sibling, 1 reply; 7+ messages in thread
From: tomas @ 2016-05-31  7:55 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, May 31, 2016 at 02:49:35PM +0800, Eric Abrahamsen wrote:

[...]

> What I'd really like is to find a way [...] of only showing the
> actual edits, not the filling [...]

You mean a diff which works at whole paragraph level instead of
at line level, as if the whole paragraph were a big honkin' line?

The "word processors" seem to "see" texts in this way. With
Emacs we are in a somewhat schizophrenic spot. You might try
actually having one-line paragraphs and use visual-line mode
with word wrapping; be warned that many an Emacs algorithm
doesn't like extremely long lines (they work, but they let
you notice their distaste :-)

regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAldNQ3oACgkQBcgs9XrR2kbeUgCfb4i59Ti/ufPt7muCRScte0Z3
/V4An2PGVpO+m3RpWtfcUl6rYP9LlD2N
=FS1V
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Tweaking magit/diff mode to be more helpful in text editing
  2016-05-31  7:48 ` Yuri Khan
@ 2016-06-01  3:08   ` Eric Abrahamsen
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Abrahamsen @ 2016-06-01  3:08 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan <yuri.v.khan@gmail.com> writes:

> On Tue, May 31, 2016 at 12:49 PM, Eric Abrahamsen
> <eric@ericabrahamsen.net> wrote:
>
>> What I'd really like is to find a way (either a diff algorithm or a
>> Magit tweak) of only showing the actual edits, not the filling. And then
>> to still be able to export that in a way that will allow me to give the
>> author a file only showing those edits.
>>
>> Does anyone have any clever ideas in that direction?
>
> I have an idea.
> Whether it’s clever or stupid, is up to you.
>
> Do not fill paragraphs based on line width.
> Wrap lines at stable positions based on sentence structure
> such as sentence and clause boundaries
> like I’m doing here.
>
> This way, diffs will be compact
> (the worst case is when a single line grows too long
> and you split it at a logical point near the middle)
> and line breaks will be eliminated anyway
> when the document is rendered to HTML
> or whatever other form.
>
> (One disadvantage is that it looks like a poem.)

Ha, that would be quite a mental adjustment! I might give it a shot,
though. Perhaps my writing would improve if I treated it like poetry...




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Tweaking magit/diff mode to be more helpful in text editing
  2016-05-31  7:55 ` tomas
@ 2016-06-01  4:00   ` Eric Abrahamsen
  2016-06-01  4:17     ` Yuri Khan
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Abrahamsen @ 2016-06-01  4:00 UTC (permalink / raw)
  To: help-gnu-emacs

<tomas@tuxteam.de> writes:

> On Tue, May 31, 2016 at 02:49:35PM +0800, Eric Abrahamsen wrote:
>
> [...]
>
>> What I'd really like is to find a way [...] of only showing the
>> actual edits, not the filling [...]
>
> You mean a diff which works at whole paragraph level instead of
> at line level, as if the whole paragraph were a big honkin' line?

Yup, that's exactly it. I'm also just considering the dumb kludge of
clobbering Magit's deffaces. That wouldn't solve any of the other
issues, though.

> The "word processors" seem to "see" texts in this way. With
> Emacs we are in a somewhat schizophrenic spot. You might try
> actually having one-line paragraphs and use visual-line mode
> with word wrapping; be warned that many an Emacs algorithm
> doesn't like extremely long lines (they work, but they let
> you notice their distaste :-)

I've tried visual-line-mode before, and didn't like it too much.

I just found wdiff[1]! This looks to be exactly what I want, and it's
got the right brand, too :) There's also something called adiff.

I've installed it, and tweaked my git config so that I can call "git
difftool --tool=wdiff" and see the diff using wdiff. Right now it spits
out the whole file, not just changes-plus-context, but presumably I can
figure out how to change that.

I suppose I might be able to fool with Magit so that it displays diffs
using the wdiff difftool, but probably I should just write some sort of
standalone mode for doing this display.

But then I'd still want to write git integration, to diff against the
index...

Are any of the Magit developers here? How hard would it be to add wdiff
display as a sort of paste-on command to Magit? Obviously the diffs
themselves can't be fed to git in any useful way, but it would be great
to just have a command that compares commits using wdiff...

Progress!

E

[1] https://www.gnu.org/software/wdiff/




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Tweaking magit/diff mode to be more helpful in text editing
  2016-06-01  4:00   ` Eric Abrahamsen
@ 2016-06-01  4:17     ` Yuri Khan
  2016-06-01  5:08       ` Eric Abrahamsen
  0 siblings, 1 reply; 7+ messages in thread
From: Yuri Khan @ 2016-06-01  4:17 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: help-gnu-emacs@gnu.org

On Wed, Jun 1, 2016 at 10:00 AM, Eric Abrahamsen
<eric@ericabrahamsen.net> wrote:
> <tomas@tuxteam.de> writes:

> I just found wdiff[1]! This looks to be exactly what I want, and it's
> got the right brand, too :) There's also something called adiff.
>
> I've installed it, and tweaked my git config so that I can call "git
> difftool --tool=wdiff" and see the diff using wdiff. Right now it spits
> out the whole file, not just changes-plus-context, but presumably I can
> figure out how to change that.

Git also has a built-in wdiff-like mode. See git-diff(1) for
--word-diff, --word-diff-regex and --color-words.
--word-diff=porcelain might be especially useful for editor
integration.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Tweaking magit/diff mode to be more helpful in text editing
  2016-06-01  4:17     ` Yuri Khan
@ 2016-06-01  5:08       ` Eric Abrahamsen
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Abrahamsen @ 2016-06-01  5:08 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan <yuri.v.khan@gmail.com> writes:

> On Wed, Jun 1, 2016 at 10:00 AM, Eric Abrahamsen
> <eric@ericabrahamsen.net> wrote:
>> <tomas@tuxteam.de> writes:
>
>> I just found wdiff[1]! This looks to be exactly what I want, and it's
>> got the right brand, too :) There's also something called adiff.
>>
>> I've installed it, and tweaked my git config so that I can call "git
>> difftool --tool=wdiff" and see the diff using wdiff. Right now it spits
>> out the whole file, not just changes-plus-context, but presumably I can
>> figure out how to change that.
>
> Git also has a built-in wdiff-like mode. See git-diff(1) for
> --word-diff, --word-diff-regex and --color-words.
> --word-diff=porcelain might be especially useful for editor
> integration.

Well that's embarrassing. I was aware of --word-diff, but for some
reason was totally sure that it only provided "extra" word-level
context, but still marked refilled paragraphs as changes. Instead, it
seems to do exactly what wdiff does. My apologies for insufficient prior
Googling.

It still doesn't work with Magit, but unsurprisingly the issue has
already been discovered and discussed[1]. The Magit developers have said
they won't support --word-diff, "not even read-only", because (as I
guessed) the resulting diffs can't be used as diffs are supposed to be
used: can't be applied, reverted, etc.

So I'll be able to send a fairly useful document to my author, but if I
want the benefit of --word-diff during editing, I'll need to write some
sort of parser myself.

Thanks for putting up with this inquiry!

E

[1]: https://github.com/magit/magit/issues/1615




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-06-01  5:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-31  6:49 Tweaking magit/diff mode to be more helpful in text editing Eric Abrahamsen
2016-05-31  7:48 ` Yuri Khan
2016-06-01  3:08   ` Eric Abrahamsen
2016-05-31  7:55 ` tomas
2016-06-01  4:00   ` Eric Abrahamsen
2016-06-01  4:17     ` Yuri Khan
2016-06-01  5:08       ` Eric Abrahamsen

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.