diff options
| author | Eli Zaretskii | 2018-11-09 11:13:32 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2018-11-09 11:13:32 +0200 |
| commit | a3242cc4593a1682f467d00b93670e538171c620 (patch) | |
| tree | 1466d8022cd1b8f8d5bc7bec468a50ffe17abbad | |
| parent | 39e85a0c6c8de75b446e8e4dc41cdfdca96907e3 (diff) | |
| download | emacs-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.texi | 93 |
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 |
| 1429 | are contiguous chunks of text that contain one or more changed lines. | 1429 | are contiguous chunks of text that contain one or more changed lines. |
| 1430 | Hunks can also include unchanged lines to provide context for the | 1430 | Hunks usually also include unchanged lines to provide context for the |
| 1431 | changes. Each hunk is preceded by a @dfn{hunk header}, which | 1431 | changes. Each hunk is preceded by a @dfn{hunk header}, which |
| 1432 | specifies the old and new line numbers at which the hunk occurs. Diff | 1432 | specifies the old and new line numbers where the hunk's changes occur. |
| 1433 | mode highlights each hunk header, to distinguish it from the actual | 1433 | Diff mode highlights each hunk header, to distinguish it from the |
| 1434 | contents of the hunk. | 1434 | actual contents of the hunk. |
| 1435 | |||
| 1436 | The first hunk in a patch is preceded by a file header, which shows | ||
| 1437 | the names of the new and the old versions of the file, and their time | ||
| 1438 | stamps. If a patch shows changes for more than one file, each file | ||
| 1439 | has 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 |
| 1438 | read-only, you need to make it writable first. @xref{Misc Buffer}.) | 1443 | read-only, you need to make it writable first; see @ref{Misc Buffer}.) |
| 1439 | Whenever you change a hunk, Diff mode attempts to automatically | 1444 | Whenever you edit a hunk, Diff mode attempts to automatically correct |
| 1440 | correct the line numbers in the hunk headers, to ensure that the patch | 1445 | the line numbers in the hunk headers, to ensure that the patch remains |
| 1441 | remains correct. To disable automatic line number correction, | 1446 | correct, and could still be applied by @command{patch}. To disable |
| 1442 | change the variable @code{diff-update-on-the-fly} to @code{nil}. | 1447 | automatic 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 | |
| 1445 | Compilation mode. Thus, you can use commands such as @kbd{C-x `} to | 1450 | Diff mode arranges for hunks to be treated as compiler error |
| 1446 | visit the corresponding source locations. @xref{Compilation Mode}. | 1451 | messages by @kbd{C-x `} and other commands that handle error messages |
| 1452 | (@pxref{Compilation Mode}). Thus, you can use the compilation-mode | ||
| 1453 | commands 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, |
| 1449 | manipulate and apply parts of patches: | 1456 | manipulate 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 |
| 1454 | Move to the next hunk-start (@code{diff-hunk-next}). | 1461 | Move to the next hunk-start (@code{diff-hunk-next}). With prefix |
| 1462 | argument @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 |
| 1472 | Move to the previous hunk-start (@code{diff-hunk-prev}). Like | 1480 | Move to the previous hunk-start (@code{diff-hunk-prev}). With prefix |
| 1481 | argument @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, |
| 1474 | unless you disable Diff Auto-Refine mode. | 1483 | unless you disable Diff Auto-Refine mode. |
| 1475 | 1484 | ||
| 1476 | @item M-@} | 1485 | @item M-@} |
| 1477 | @findex diff-file-next | 1486 | @findex diff-file-next |
| 1478 | Move to the next file-start, in a multi-file patch | 1487 | Move 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 |
| 1489 | to 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 |
| 1483 | Move to the previous file-start, in a multi-file patch | 1493 | Move 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 |
| 1495 | the 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 |
| 1498 | Apply this hunk to its target file (@code{diff-apply-hunk}). With a | 1509 | Apply this hunk to its target file (@code{diff-apply-hunk}). With a |
| 1499 | prefix argument of @kbd{C-u}, revert this hunk. | 1510 | prefix argument of @kbd{C-u}, revert this hunk, i.e.@: apply the |
| 1511 | reverse of the hunk, which changes the ``new'' version into the ``old'' | ||
| 1512 | version. If @code{diff-jump-to-old-file} is non-@code{nil}, apply the | ||
| 1513 | hunk 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 | ||
| 1509 | Go to the source file and line corresponding to this hunk | 1524 | Go 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'' |
| 1526 | version of the file, the one shown first on the file header. | ||
| 1527 | With a prefix argument, jump to the ``old'' version instead. If | ||
| 1528 | @code{diff-jump-to-old-file} is non-@code{nil}, this command by | ||
| 1529 | default jumps to the ``old'' file, and the meaning of the prefix | ||
| 1530 | argument is reversed. If the prefix argument is a number greater than | ||
| 1531 | 8 (e.g., if you type @kbd{C-u C-u C-c C-c}), then this command also | ||
| 1532 | sets @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 |
| 1519 | Restrict the view to the current hunk (@code{diff-restrict-view}). | 1541 | Restrict 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 |
| 1521 | view to the current file of a multiple-file patch. To widen again, | 1543 | view to the current file of a multiple-file patch. To widen again, |
| 1522 | use @kbd{C-x n w} (@code{widen}). | 1544 | use @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 |
| 1526 | Reverse the direction of comparison for the entire buffer | 1548 | Reverse the direction of comparison for the entire buffer |
| 1527 | (@code{diff-reverse-direction}). | 1549 | (@code{diff-reverse-direction}). With a prefix argument, reverse the |
| 1550 | direction only inside the current region (@pxref{Mark}). Reversing | ||
| 1551 | the direction means changing the hunks and the file-start headers to | ||
| 1552 | produce a patch that would change the ``new'' version into the ``old'' | ||
| 1553 | one. | ||
| 1528 | 1554 | ||
| 1529 | @item C-c C-s | 1555 | @item C-c C-s |
| 1530 | @findex diff-split-hunk | 1556 | @findex diff-split-hunk |
| 1531 | Split the hunk at point (@code{diff-split-hunk}). This is for | 1557 | Split the hunk at point (@code{diff-split-hunk}) into two separate |
| 1532 | manually editing patches, and only works with the @dfn{unified diff | 1558 | hunks. This inserts a hunk header and modifies the header of the |
| 1533 | format} produced by the @option{-u} or @option{--unified} options to | 1559 | current hunk. This command is useful for manually editing patches, |
| 1534 | the @command{diff} program. If you need to split a hunk in the | 1560 | and 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 | 1562 | program. If you need to split a hunk in the @dfn{context diff format} |
| 1537 | to the unified diff format with @kbd{C-c C-u}. | 1563 | produced by the @option{-c} or @option{--context} options to |
| 1564 | @command{diff}, first convert the buffer to the unified diff format | ||
| 1565 | with @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 |
| 1541 | Convert the entire buffer to the @dfn{context diff format} | 1569 | Convert 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 |
| 1543 | the text within the region. | 1571 | the 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 |
| 1547 | Convert the entire buffer to unified diff format | 1575 | Convert 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 |
| 1549 | unified format to context format. When the mark is active, convert | 1577 | unified format to context format. When the mark is active, convert |
| 1550 | only the text within the region. | 1578 | only 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 |
| 1554 | Re-diff the current hunk, disregarding changes in whitespace | 1582 | Re-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). | |||
| 1582 | This command does not save the modifications that it makes, so you can | 1610 | This command does not save the modifications that it makes, so you can |
| 1583 | decide whether to save the changes (the list of modified files is | 1611 | decide whether to save the changes (the list of modified files is |
| 1584 | displayed in the echo area). With a prefix argument, it tries to | 1612 | displayed in the echo area). With a prefix argument, it tries to |
| 1585 | modify the original source files rather than the patched source files. | 1613 | modify 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 |