Commit 26f59676 authored by Glenn Morris's avatar Glenn Morris
Browse files

Document diff-remove-trailing-whitespace

* doc/emacs/files.texi (Diff Mode): Trailing whitespace updates.

* lisp/vc/diff-mode.el (diff-remove-trailing-whitespace): Doc fix.

* etc/NEWS: Related markup.
parent 7858872b
2012-11-08 Glenn Morris <rgm@gnu.org>
* files.texi (Diff Mode): Trailing whitespace updates.
2012-11-07 Chong Yidong <cyd@gnu.org> 2012-11-07 Chong Yidong <cyd@gnu.org>
* misc.texi (Terminal emulator): Document Term mode faces. * misc.texi (Terminal emulator): Document Term mode faces.
......
...@@ -1470,11 +1470,19 @@ name from the patch itself. This is useful for making log entries for ...@@ -1470,11 +1470,19 @@ name from the patch itself. This is useful for making log entries for
functions that are deleted by the patch. functions that are deleted by the patch.
@end table @end table
By default, Diff mode highlights trailing whitespace on modified @c Trailing whitespace is NOT shown by default.
lines, so that they are more obvious. This is done by enabling @c Emacs's dir-locals file enables this (for some reason).
Whitespace mode in the Diff buffer (@pxref{Useless Whitespace}). Diff @cindex trailing whitespace, in diffs
mode buffers are set up so that Whitespace mode avoids highlighting @findex diff-remove-trailing-whitespace
trailing whitespace occurring in the diff context. Diff mode has various features for dealing with trailing whitespace
on modified lines, since this is often an unintentional and unwanted
change. If you enable Whitespace mode in a Diff buffer, trailing
whitespace is highlighted (@pxref{Useless Whitespace}). The command
@kbd{M-x diff-remove-trailing-whitespace} searches for trailing
whitespace in the lines modified or added by a diff. If it finds any,
it tries to visit the associated file(s) and remove it. It does not
save the modifications, rather it lists any buffers that were modified
so you can decide for yourself what to do.
@node Misc File Ops @node Misc File Ops
@section Miscellaneous File Operations @section Miscellaneous File Operations
......
...@@ -392,18 +392,21 @@ details. ...@@ -392,18 +392,21 @@ details.
** Diff mode ** Diff mode
---
*** Changes are now highlighted using the same color scheme as in *** Changes are now highlighted using the same color scheme as in
modern VCSes. Deletions are displayed in red (new faces modern VCSes. Deletions are displayed in red (new faces
`diff-refine-removed' and `smerge-refined-removed' and new definition `diff-refine-removed' and `smerge-refined-removed', and new definition
of `diff-removed'), insertions in green (new faces `diff-refine-added' of `diff-removed'), insertions in green (new faces `diff-refine-added'
and `smerge-refined-added' and new definition of `diff-added'). and `smerge-refined-added', and new definition of `diff-added').
---
*** The variable `diff-use-changed-face' defines whether to use the *** The variable `diff-use-changed-face' defines whether to use the
face `diff-changed', or `diff-removed' and `diff-added' to highlight face `diff-changed', or `diff-removed' and `diff-added' to highlight
changes in context diffs. changes in context diffs.
*** The new command `diff-remove-trailing-whitespace' fixes trailing +++
whitespace problems introduced by the diff. *** The new command `diff-remove-trailing-whitespace' removes trailing
whitespace introduced by a diff.
** Dired ** Dired
+++ +++
......
2012-11-08 Glenn Morris <rgm@gnu.org>
* vc/diff-mode.el (diff-remove-trailing-whitespace): Doc fix.
2012-11-08 Stefan Monnier <monnier@iro.umontreal.ca> 2012-11-08 Stefan Monnier <monnier@iro.umontreal.ca>
   
* emacs-lisp/gv.el (gv-define-simple-setter): Fix last change * emacs-lisp/gv.el (gv-define-simple-setter): Fix last change
......
...@@ -2049,12 +2049,12 @@ I.e. like `add-change-log-entry-other-window' but applied to all hunks." ...@@ -2049,12 +2049,12 @@ I.e. like `add-change-log-entry-other-window' but applied to all hunks."
(error nil)))) (error nil))))
(defun diff-remove-trailing-whitespace () (defun diff-remove-trailing-whitespace ()
"When on a buffer that contains a diff, inspects the "Remove trailing whitespace from the lines modified/added by a diff.
differences and removes trailing whitespace (spaces, tabs) from Called from a buffer containing a diff, this searches for trailing
the lines modified or introduced by this diff. Shows a message whitespace (spaces, tabs) in the modified/added lines. If the
with the name of the altered buffers, which are unsaved. If a file that such a line refers to can be found, it visits it and
file referenced on the diff has no buffer and needs to be fixed, removes the associated whitespace, if it is present. It does not
a buffer visiting that file is created." save any changed buffers, it just gives a message naming them."
(interactive) (interactive)
;; We assume that the diff header has no trailing whitespace. ;; We assume that the diff header has no trailing whitespace.
(let ((modified-buffers nil)) (let ((modified-buffers nil))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment