diff options
| author | Dan Nicolaescu | 2007-07-30 00:19:06 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2007-07-30 00:19:06 +0000 |
| commit | eff23ff37606569028a6ef96ba2481df6b061ec4 (patch) | |
| tree | d5acc8e64e1e122a74c8bf3cfad654b70217dbd4 /lisp/diff-mode.el | |
| parent | 463dca7e44715219fe720858d2144d54ea315635 (diff) | |
| download | emacs-eff23ff37606569028a6ef96ba2481df6b061ec4.tar.gz emacs-eff23ff37606569028a6ef96ba2481df6b061ec4.zip | |
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Remove.
(vc-git-revision-completion-table): Enable.
* vc-hooks.el (vc-handled-backends): Add GIT and HG.
* vc.el (vc-directory-exclusion-list): Add .git and .hg.
* vc-hg.el (vc-hg-revision-completion-table): Re-enable.
* diff-mode.el (diff-mode-menu): New entries.
* diff-mode.el (diff-beginning-of-file-and-junk): New function.
(diff-file-kill): Use it.
(diff-beginning-of-hunk): Add arg `try-harder' using it.
(diff-restrict-view, diff-find-source-location, diff-refine-hunk):
Use it so they find the hunk even when we're in the file header.
* vc.el: Add new VC operation `revision-completion-table'.
(vc-default-revision-completion-table): New function.
(vc-version-diff, vc-version-other-window): Use it to provide
completion of revision names if the backend provides it.
* vc-arch.el (vc-arch--version-completion-table)
(vc-arch-revision-completion-table): New functions to provide
completion of revision names.
* vc-cvs.el: Require CL.
(vc-cvs-revision-table, vc-cvs-revision-completion-table):
New functions to provide completion of revision names.
* eval.c (init_eval_once): Bump max_lisp_eval_depth to 400.
* vc2-xtra.texi (Customizing VC): Add GIT and HG.
Diffstat (limited to 'lisp/diff-mode.el')
| -rw-r--r-- | lisp/diff-mode.el | 65 |
1 files changed, 52 insertions, 13 deletions
diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el index 3f96ba6e453..f2800f1c337 100644 --- a/lisp/diff-mode.el +++ b/lisp/diff-mode.el | |||
| @@ -164,12 +164,23 @@ when editing big diffs)." | |||
| 164 | '("Diff" | 164 | '("Diff" |
| 165 | ["Jump to Source" diff-goto-source t] | 165 | ["Jump to Source" diff-goto-source t] |
| 166 | ["Apply hunk" diff-apply-hunk t] | 166 | ["Apply hunk" diff-apply-hunk t] |
| 167 | ["Test applying hunk" diff-test-hunk t] | ||
| 167 | ["Apply diff with Ediff" diff-ediff-patch t] | 168 | ["Apply diff with Ediff" diff-ediff-patch t] |
| 168 | ["-----" nil nil] | 169 | "-----" |
| 169 | ["Reverse direction" diff-reverse-direction t] | 170 | ["Reverse direction" diff-reverse-direction t] |
| 170 | ["Context -> Unified" diff-context->unified t] | 171 | ["Context -> Unified" diff-context->unified t] |
| 171 | ["Unified -> Context" diff-unified->context t] | 172 | ["Unified -> Context" diff-unified->context t] |
| 172 | ;;["Fixup Headers" diff-fixup-modifs (not buffer-read-only)] | 173 | ;;["Fixup Headers" diff-fixup-modifs (not buffer-read-only)] |
| 174 | "-----" | ||
| 175 | ["Split hunk" diff-split-hunk t] | ||
| 176 | ["Refine hunk" diff-refine-hunk t] | ||
| 177 | ["Kill current hunk" diff-hunk-kill t] | ||
| 178 | ["Kill current file's hunks" diff-file-kill t] | ||
| 179 | "-----" | ||
| 180 | ["Previous Hunk" diff-hunk-prev t] | ||
| 181 | ["Next Hunk" diff-hunk-next t] | ||
| 182 | ["Previous File" diff-file-prev t] | ||
| 183 | ["Next File" diff-file-next t] | ||
| 173 | )) | 184 | )) |
| 174 | 185 | ||
| 175 | (defcustom diff-minor-mode-prefix "\C-c=" | 186 | (defcustom diff-minor-mode-prefix "\C-c=" |
| @@ -390,13 +401,20 @@ when editing big diffs)." | |||
| 390 | ;; The return value is used by easy-mmode-define-navigation. | 401 | ;; The return value is used by easy-mmode-define-navigation. |
| 391 | (goto-char (or end (point-max))))) | 402 | (goto-char (or end (point-max))))) |
| 392 | 403 | ||
| 393 | (defun diff-beginning-of-hunk () | 404 | (defun diff-beginning-of-hunk (&optional try-harder) |
| 405 | "Move back to beginning of hunk. | ||
| 406 | If TRY-HARDER is non-nil, try to cater to the case where we're not in a hunk | ||
| 407 | but in the file header instead, in which case move forward to the first hunk." | ||
| 394 | (beginning-of-line) | 408 | (beginning-of-line) |
| 395 | (unless (looking-at diff-hunk-header-re) | 409 | (unless (looking-at diff-hunk-header-re) |
| 396 | (forward-line 1) | 410 | (forward-line 1) |
| 397 | (condition-case () | 411 | (condition-case () |
| 398 | (re-search-backward diff-hunk-header-re) | 412 | (re-search-backward diff-hunk-header-re) |
| 399 | (error (error "Can't find the beginning of the hunk"))))) | 413 | (error |
| 414 | (if (not try-harder) | ||
| 415 | (error "Can't find the beginning of the hunk") | ||
| 416 | (diff-beginning-of-file-and-junk) | ||
| 417 | (diff-hunk-next)))))) | ||
| 400 | 418 | ||
| 401 | (defun diff-beginning-of-file () | 419 | (defun diff-beginning-of-file () |
| 402 | (beginning-of-line) | 420 | (beginning-of-line) |
| @@ -425,7 +443,7 @@ when editing big diffs)." | |||
| 425 | If the prefix ARG is given, restrict the view to the current file instead." | 443 | If the prefix ARG is given, restrict the view to the current file instead." |
| 426 | (interactive "P") | 444 | (interactive "P") |
| 427 | (save-excursion | 445 | (save-excursion |
| 428 | (if arg (diff-beginning-of-file) (diff-beginning-of-hunk)) | 446 | (if arg (diff-beginning-of-file) (diff-beginning-of-hunk 'try-harder)) |
| 429 | (narrow-to-region (point) | 447 | (narrow-to-region (point) |
| 430 | (progn (if arg (diff-end-of-file) (diff-end-of-hunk)) | 448 | (progn (if arg (diff-end-of-file) (diff-end-of-hunk)) |
| 431 | (point))) | 449 | (point))) |
| @@ -453,18 +471,37 @@ If the prefix ARG is given, restrict the view to the current file instead." | |||
| 453 | (diff-end-of-hunk) | 471 | (diff-end-of-hunk) |
| 454 | (kill-region start (point))))) | 472 | (kill-region start (point))))) |
| 455 | 473 | ||
| 474 | (defun diff-beginning-of-file-and-junk () | ||
| 475 | "Go to the beginning of file-related diff-info. | ||
| 476 | This is like `diff-beginning-of-file' except it tries to skip back over leading | ||
| 477 | data such as \"Index: ...\" and such." | ||
| 478 | (let ((start (point)) | ||
| 479 | (file (condition-case err (progn (diff-beginning-of-file) (point)) | ||
| 480 | (error err))) | ||
| 481 | ;; prevhunk is one of the limits. | ||
| 482 | (prevhunk (save-excursion (ignore-errors (diff-hunk-prev) (point)))) | ||
| 483 | err) | ||
| 484 | (when (consp file) | ||
| 485 | ;; Presumably, we started before the file header, in the leading junk. | ||
| 486 | (setq err file) | ||
| 487 | (diff-file-next) | ||
| 488 | (setq file (point))) | ||
| 489 | (let ((index (save-excursion | ||
| 490 | (re-search-backward "^Index: " prevhunk t)))) | ||
| 491 | (when index (setq file index)) | ||
| 492 | (if (<= file start) | ||
| 493 | (goto-char file) | ||
| 494 | ;; File starts *after* the starting point: we really weren't in | ||
| 495 | ;; a file diff but elsewhere. | ||
| 496 | (goto-char start) | ||
| 497 | (signal (car err) (cdr err)))))) | ||
| 498 | |||
| 456 | (defun diff-file-kill () | 499 | (defun diff-file-kill () |
| 457 | "Kill current file's hunks." | 500 | "Kill current file's hunks." |
| 458 | (interactive) | 501 | (interactive) |
| 459 | (diff-beginning-of-file) | 502 | (diff-beginning-of-file-and-junk) |
| 460 | (let* ((start (point)) | 503 | (let* ((start (point)) |
| 461 | (prevhunk (save-excursion | ||
| 462 | (ignore-errors | ||
| 463 | (diff-hunk-prev) (point)))) | ||
| 464 | (index (save-excursion | ||
| 465 | (re-search-backward "^Index: " prevhunk t))) | ||
| 466 | (inhibit-read-only t)) | 504 | (inhibit-read-only t)) |
| 467 | (when index (setq start index)) | ||
| 468 | (diff-end-of-file) | 505 | (diff-end-of-file) |
| 469 | (if (looking-at "^\n") (forward-char 1)) ;`tla' generates such diffs. | 506 | (if (looking-at "^\n") (forward-char 1)) ;`tla' generates such diffs. |
| 470 | (kill-region start (point)))) | 507 | (kill-region start (point)))) |
| @@ -1289,7 +1326,8 @@ SRC and DST are the two variants of text as returned by `diff-hunk-text'. | |||
| 1289 | SWITCHED is non-nil if the patch is already applied." | 1326 | SWITCHED is non-nil if the patch is already applied." |
| 1290 | (save-excursion | 1327 | (save-excursion |
| 1291 | (let* ((other (diff-xor other-file diff-jump-to-old-file)) | 1328 | (let* ((other (diff-xor other-file diff-jump-to-old-file)) |
| 1292 | (char-offset (- (point) (progn (diff-beginning-of-hunk) (point)))) | 1329 | (char-offset (- (point) (progn (diff-beginning-of-hunk 'try-harder) |
| 1330 | (point)))) | ||
| 1293 | ;; Check that the hunk is well-formed. Otherwise diff-mode and | 1331 | ;; Check that the hunk is well-formed. Otherwise diff-mode and |
| 1294 | ;; the user may disagree on what constitutes the hunk | 1332 | ;; the user may disagree on what constitutes the hunk |
| 1295 | ;; (e.g. because an empty line truncates the hunk mid-course), | 1333 | ;; (e.g. because an empty line truncates the hunk mid-course), |
| @@ -1458,7 +1496,8 @@ For use in `add-log-current-defun-function'." | |||
| 1458 | (defun diff-refine-hunk () | 1496 | (defun diff-refine-hunk () |
| 1459 | "Refine the current hunk by ignoring space differences." | 1497 | "Refine the current hunk by ignoring space differences." |
| 1460 | (interactive) | 1498 | (interactive) |
| 1461 | (let* ((char-offset (- (point) (progn (diff-beginning-of-hunk) (point)))) | 1499 | (let* ((char-offset (- (point) (progn (diff-beginning-of-hunk 'try-harder) |
| 1500 | (point)))) | ||
| 1462 | (opts (case (char-after) (?@ "-bu") (?* "-bc") (t "-b"))) | 1501 | (opts (case (char-after) (?@ "-bu") (?* "-bc") (t "-b"))) |
| 1463 | (line-nb (and (or (looking-at "[^0-9]+\\([0-9]+\\)") | 1502 | (line-nb (and (or (looking-at "[^0-9]+\\([0-9]+\\)") |
| 1464 | (error "Can't find line number")) | 1503 | (error "Can't find line number")) |