* bug#12831: 24.2.50; diff-remove-trailing-whitespace is broken
@ 2012-11-08 10:33 Chong Yidong
2012-11-08 17:33 ` Chong Yidong
0 siblings, 1 reply; 2+ messages in thread
From: Chong Yidong @ 2012-11-08 10:33 UTC (permalink / raw)
To: 12831; +Cc: Óscar Fuentes
The command diff-remove-trailing-whitespace, newly introduced for Emacs
24.3, is broken. AFAICT, it can't easily be made to work right.
1) diff-remove-trailing-whitespace is confused about the order of files
in the diff:
echo "a" > oldfile
echo "b " > newfile
emacs -Q
M-x diff RET newfile RET oldfile RET
C-x o
M-x diff-remove-trailing-whitespace RET
=> no trailing whitespace fixes needed
(Note that the new file is by convention the FIRST argument to M-x
diff and the SECOND argument to the `diff' command.) This can be
fixed by replacing (diff-find-source-location t t) in the definition
of diff-remove-trailing-whitespace. But we hit the second problem:
2) After the trailing whitespaces are fixed in the underlying files, the
trailing whitespace still remains in the *Diff* buffer. The basic
problem is that the algorithm of this command is too simplistic: it
looks for trailing whitespace in the Diff buffer, jumps to the
corresponding location given by diff-find-source-location, looks for
trailing whitespace on that line, and deletes it.
This simple algorithm can lead to serious mistakes. There's no
attempt to check if the point in the Diff buffer corresponds to a
"before" or "after" line (nothing ought to be done for the former,
but the existing command is happy to use it), or whether the
"trailing whitespace" that it found is merely the space which is
customarily inserted after "!" in context diffs.
Unless someone comes up with a version of this command that works right,
I think we should go back to the drawing board on this, and remove it
from Emacs 24.3.
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#12831: 24.2.50; diff-remove-trailing-whitespace is broken
2012-11-08 10:33 bug#12831: 24.2.50; diff-remove-trailing-whitespace is broken Chong Yidong
@ 2012-11-08 17:33 ` Chong Yidong
0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2012-11-08 17:33 UTC (permalink / raw)
To: 12831-done; +Cc: Óscar Fuentes
> The command diff-remove-trailing-whitespace, newly introduced for Emacs
> 24.3, is broken.
I have rewritten the command to make it work properly, and renamed it to
diff-delete-trailing-whitespace (for consistency with the existing
delete-trailing-whitespace command).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-08 17:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-08 10:33 bug#12831: 24.2.50; diff-remove-trailing-whitespace is broken Chong Yidong
2012-11-08 17:33 ` Chong Yidong
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.