aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2018-11-09 11:13:32 +0200
committerEli Zaretskii2018-11-09 11:13:32 +0200
commita3242cc4593a1682f467d00b93670e538171c620 (patch)
tree1466d8022cd1b8f8d5bc7bec468a50ffe17abbad
parent39e85a0c6c8de75b446e8e4dc41cdfdca96907e3 (diff)
downloademacs-a3242cc4593a1682f467d00b93670e538171c620.tar.gz
emacs-a3242cc4593a1682f467d00b93670e538171c620.zip
Improve documentation of Diff mode
* doc/emacs/files.texi (Diff Mode): Document the effect of prefix argument on the Diff mode's commands. Document 'diff-jump-to-old-file'.
-rw-r--r--doc/emacs/files.texi93
1 files changed, 61 insertions, 32 deletions
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 61aa2fc3016..9c57bbe267c 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -1427,23 +1427,30 @@ manually, type @kbd{M-x diff-mode}.
1427@cindex hunk, diff 1427@cindex hunk, diff
1428 The changes specified in a patch are grouped into @dfn{hunks}, which 1428 The changes specified in a patch are grouped into @dfn{hunks}, which
1429are contiguous chunks of text that contain one or more changed lines. 1429are contiguous chunks of text that contain one or more changed lines.
1430Hunks can also include unchanged lines to provide context for the 1430Hunks usually also include unchanged lines to provide context for the
1431changes. Each hunk is preceded by a @dfn{hunk header}, which 1431changes. Each hunk is preceded by a @dfn{hunk header}, which
1432specifies the old and new line numbers at which the hunk occurs. Diff 1432specifies the old and new line numbers where the hunk's changes occur.
1433mode highlights each hunk header, to distinguish it from the actual 1433Diff mode highlights each hunk header, to distinguish it from the
1434contents of the hunk. 1434actual contents of the hunk.
1435
1436 The first hunk in a patch is preceded by a file header, which shows
1437the names of the new and the old versions of the file, and their time
1438stamps. If a patch shows changes for more than one file, each file
1439has such a header before the first hunk of that file's changes.
1435 1440
1436@vindex diff-update-on-the-fly 1441@vindex diff-update-on-the-fly
1437 You can edit a Diff mode buffer like any other buffer. (If it is 1442 You can edit a Diff mode buffer like any other buffer. (If it is
1438read-only, you need to make it writable first. @xref{Misc Buffer}.) 1443read-only, you need to make it writable first; see @ref{Misc Buffer}.)
1439Whenever you change a hunk, Diff mode attempts to automatically 1444Whenever you edit a hunk, Diff mode attempts to automatically correct
1440correct the line numbers in the hunk headers, to ensure that the patch 1445the line numbers in the hunk headers, to ensure that the patch remains
1441remains correct. To disable automatic line number correction, 1446correct, and could still be applied by @command{patch}. To disable
1442change the variable @code{diff-update-on-the-fly} to @code{nil}. 1447automatic line number correction, change the variable
1443 1448@code{diff-update-on-the-fly} to @code{nil}.
1444 Diff mode treats each hunk as an error message, similar to 1449
1445Compilation mode. Thus, you can use commands such as @kbd{C-x `} to 1450 Diff mode arranges for hunks to be treated as compiler error
1446visit the corresponding source locations. @xref{Compilation Mode}. 1451messages by @kbd{C-x `} and other commands that handle error messages
1452(@pxref{Compilation Mode}). Thus, you can use the compilation-mode
1453commands to visit the corresponding source locations.
1447 1454
1448 In addition, Diff mode provides the following commands to navigate, 1455 In addition, Diff mode provides the following commands to navigate,
1449manipulate and apply parts of patches: 1456manipulate and apply parts of patches:
@@ -1451,7 +1458,8 @@ manipulate and apply parts of patches:
1451@table @kbd 1458@table @kbd
1452@item M-n 1459@item M-n
1453@findex diff-hunk-next 1460@findex diff-hunk-next
1454Move to the next hunk-start (@code{diff-hunk-next}). 1461Move to the next hunk-start (@code{diff-hunk-next}). With prefix
1462argument @var{n}, move forward to the @var{n}th next hunk.
1455 1463
1456@findex diff-auto-refine-mode 1464@findex diff-auto-refine-mode
1457@cindex mode, Diff Auto-Refine 1465@cindex mode, Diff Auto-Refine
@@ -1469,19 +1477,22 @@ default, add this to your init file (@pxref{Hooks}):
1469 1477
1470@item M-p 1478@item M-p
1471@findex diff-hunk-prev 1479@findex diff-hunk-prev
1472Move to the previous hunk-start (@code{diff-hunk-prev}). Like 1480Move to the previous hunk-start (@code{diff-hunk-prev}). With prefix
1481argument @var{n}, move back to the @var{n}th previous hunk. Like
1473@kbd{M-n}, this has the side-effect of refining the hunk you move to, 1482@kbd{M-n}, this has the side-effect of refining the hunk you move to,
1474unless you disable Diff Auto-Refine mode. 1483unless you disable Diff Auto-Refine mode.
1475 1484
1476@item M-@} 1485@item M-@}
1477@findex diff-file-next 1486@findex diff-file-next
1478Move to the next file-start, in a multi-file patch 1487Move to the next file-start, in a multi-file patch
1479(@code{diff-file-next}). 1488(@code{diff-file-next}). With prefix argument @var{n}, move forward
1489to the start of the @var{n}th next file.
1480 1490
1481@item M-@{ 1491@item M-@{
1482@findex diff-file-prev 1492@findex diff-file-prev
1483Move to the previous file-start, in a multi-file patch 1493Move to the previous file-start, in a multi-file patch
1484(@code{diff-file-prev}). 1494(@code{diff-file-prev}). With prefix argument @var{n}, move back to
1495the start of the @var{n}th previous file.
1485 1496
1486@item M-k 1497@item M-k
1487@findex diff-hunk-kill 1498@findex diff-hunk-kill
@@ -1496,7 +1507,10 @@ In a multi-file patch, kill the current file part.
1496@findex diff-apply-hunk 1507@findex diff-apply-hunk
1497@cindex patches, applying 1508@cindex patches, applying
1498Apply this hunk to its target file (@code{diff-apply-hunk}). With a 1509Apply this hunk to its target file (@code{diff-apply-hunk}). With a
1499prefix argument of @kbd{C-u}, revert this hunk. 1510prefix argument of @kbd{C-u}, revert this hunk, i.e.@: apply the
1511reverse of the hunk, which changes the ``new'' version into the ``old''
1512version. If @code{diff-jump-to-old-file} is non-@code{nil}, apply the
1513hunk to the ``old'' version of the file instead.
1500 1514
1501@item C-c C-b 1515@item C-c C-b
1502@findex diff-refine-hunk 1516@findex diff-refine-hunk
@@ -1506,8 +1520,16 @@ of each changed line were actually changed.
1506 1520
1507@item C-c C-c 1521@item C-c C-c
1508@findex diff-goto-source 1522@findex diff-goto-source
1523@vindex diff-jump-to-old-file
1509Go to the source file and line corresponding to this hunk 1524Go to the source file and line corresponding to this hunk
1510(@code{diff-goto-source}). 1525(@code{diff-goto-source}). By default, this jumps to the ``new''
1526version of the file, the one shown first on the file header.
1527With a prefix argument, jump to the ``old'' version instead. If
1528@code{diff-jump-to-old-file} is non-@code{nil}, this command by
1529default jumps to the ``old'' file, and the meaning of the prefix
1530argument is reversed. If the prefix argument is a number greater than
15318 (e.g., if you type @kbd{C-u C-u C-c C-c}), then this command also
1532sets @code{diff-jump-to-old-file} for the next invocation.
1511 1533
1512@item C-c C-e 1534@item C-c C-e
1513@findex diff-ediff-patch 1535@findex diff-ediff-patch
@@ -1517,41 +1539,47 @@ Start an Ediff session with the patch (@code{diff-ediff-patch}).
1517@item C-c C-n 1539@item C-c C-n
1518@findex diff-restrict-view 1540@findex diff-restrict-view
1519Restrict the view to the current hunk (@code{diff-restrict-view}). 1541Restrict the view to the current hunk (@code{diff-restrict-view}).
1520@xref{Narrowing}. With a prefix argument of @kbd{C-u}, restrict the 1542@xref{Narrowing}. With a prefix argument, restrict the
1521view to the current file of a multiple-file patch. To widen again, 1543view to the current file of a multiple-file patch. To widen again,
1522use @kbd{C-x n w} (@code{widen}). 1544use @kbd{C-x n w} (@code{widen}).
1523 1545
1524@item C-c C-r 1546@item C-c C-r
1525@findex diff-reverse-direction 1547@findex diff-reverse-direction
1526Reverse the direction of comparison for the entire buffer 1548Reverse the direction of comparison for the entire buffer
1527(@code{diff-reverse-direction}). 1549(@code{diff-reverse-direction}). With a prefix argument, reverse the
1550direction only inside the current region (@pxref{Mark}). Reversing
1551the direction means changing the hunks and the file-start headers to
1552produce a patch that would change the ``new'' version into the ``old''
1553one.
1528 1554
1529@item C-c C-s 1555@item C-c C-s
1530@findex diff-split-hunk 1556@findex diff-split-hunk
1531Split the hunk at point (@code{diff-split-hunk}). This is for 1557Split the hunk at point (@code{diff-split-hunk}) into two separate
1532manually editing patches, and only works with the @dfn{unified diff 1558hunks. This inserts a hunk header and modifies the header of the
1533format} produced by the @option{-u} or @option{--unified} options to 1559current hunk. This command is useful for manually editing patches,
1534the @command{diff} program. If you need to split a hunk in the 1560and only works with the @dfn{unified diff format} produced by the
1535@dfn{context diff format} produced by the @option{-c} or 1561@option{-u} or @option{--unified} options to the @command{diff}
1536@option{--context} options to @command{diff}, first convert the buffer 1562program. If you need to split a hunk in the @dfn{context diff format}
1537to the unified diff format with @kbd{C-c C-u}. 1563produced by the @option{-c} or @option{--context} options to
1564@command{diff}, first convert the buffer to the unified diff format
1565with @kbd{C-c C-u}.
1538 1566
1539@item C-c C-d 1567@item C-c C-d
1540@findex diff-unified->context 1568@findex diff-unified->context
1541Convert the entire buffer to the @dfn{context diff format} 1569Convert the entire buffer to the @dfn{context diff format}
1542(@code{diff-unified->context}). With a prefix argument, convert only 1570(@code{diff-unified->context}). With a prefix argument, convert only
1543the text within the region. 1571the hunks within the region.
1544 1572
1545@item C-c C-u 1573@item C-c C-u
1546@findex diff-context->unified 1574@findex diff-context->unified
1547Convert the entire buffer to unified diff format 1575Convert the entire buffer to unified diff format
1548(@code{diff-context->unified}). With a prefix argument, convert 1576(@code{diff-context->unified}). With a prefix argument, convert
1549unified format to context format. When the mark is active, convert 1577unified format to context format. When the mark is active, convert
1550only the text within the region. 1578only the hunks within the region.
1551 1579
1552@item C-c C-w 1580@item C-c C-w
1553@findex diff-ignore-whitespace-hunk 1581@findex diff-ignore-whitespace-hunk
1554Re-diff the current hunk, disregarding changes in whitespace 1582Re-generate the current hunk, disregarding changes in whitespace
1555(@code{diff-ignore-whitespace-hunk}). 1583(@code{diff-ignore-whitespace-hunk}).
1556 1584
1557@item C-x 4 A 1585@item C-x 4 A
@@ -1582,7 +1610,8 @@ that whitespace in both the patch and the patched source file(s).
1582This command does not save the modifications that it makes, so you can 1610This command does not save the modifications that it makes, so you can
1583decide whether to save the changes (the list of modified files is 1611decide whether to save the changes (the list of modified files is
1584displayed in the echo area). With a prefix argument, it tries to 1612displayed in the echo area). With a prefix argument, it tries to
1585modify the original source files rather than the patched source files. 1613modify the original (``old'') source files rather than the patched
1614(``new'') source files.
1586 1615
1587@node Copying and Naming 1616@node Copying and Naming
1588@section Copying, Naming and Renaming Files 1617@section Copying, Naming and Renaming Files