diff options
| author | Stefan Monnier | 2007-07-22 22:02:49 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-07-22 22:02:49 +0000 |
| commit | f151b310f65fd73924a32b566a17b3f44279c72a (patch) | |
| tree | cae0495d46fa482b7b5dfb03ac7c144abb5c18fb | |
| parent | 8f2d38de67278017981023e70e331f0d42aa7927 (diff) | |
| download | emacs-f151b310f65fd73924a32b566a17b3f44279c72a.tar.gz emacs-f151b310f65fd73924a32b566a17b3f44279c72a.zip | |
(diff-refine-ignore-spaces-hunk): Rename from
diff-refine-hunk. Adjust users.
(diff-unified-hunk-p, diff-splittable-p): New functions.
(diff-mode-menu): Use it to disable Split when it doesn't work.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/diff-mode.el | 21 |
2 files changed, 24 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 043592ab416..ad16626bd71 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2007-07-22 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * diff-mode.el (diff-refine-ignore-spaces-hunk): Rename from | ||
| 4 | diff-refine-hunk. Adjust users. | ||
| 5 | (diff-unified-hunk-p, diff-splittable-p): New functions. | ||
| 6 | (diff-mode-menu): Use it to disable Split when it doesn't work. | ||
| 7 | |||
| 1 | 2007-07-22 Dan Nicolaescu <dann@ics.uci.edu> | 8 | 2007-07-22 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 9 | ||
| 3 | * diff-mode.el (diff-mode-menu): New entries. | 10 | * diff-mode.el (diff-mode-menu): New entries. |
diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el index cfebb365770..a1bd0afa126 100644 --- a/lisp/diff-mode.el +++ b/lisp/diff-mode.el | |||
| @@ -155,7 +155,7 @@ when editing big diffs)." | |||
| 155 | ("\C-c\C-u" . diff-context->unified) | 155 | ("\C-c\C-u" . diff-context->unified) |
| 156 | ;; `d' because it duplicates the context :-( --Stef | 156 | ;; `d' because it duplicates the context :-( --Stef |
| 157 | ("\C-c\C-d" . diff-unified->context) | 157 | ("\C-c\C-d" . diff-unified->context) |
| 158 | ("\C-c\C-w" . diff-refine-hunk) | 158 | ("\C-c\C-w" . diff-refine-ignore-spaces-hunk) |
| 159 | ("\C-c\C-f" . next-error-follow-minor-mode)) | 159 | ("\C-c\C-f" . next-error-follow-minor-mode)) |
| 160 | "Keymap for `diff-mode'. See also `diff-mode-shared-map'.") | 160 | "Keymap for `diff-mode'. See also `diff-mode-shared-map'.") |
| 161 | 161 | ||
| @@ -172,8 +172,8 @@ when editing big diffs)." | |||
| 172 | ["Unified -> Context" diff-unified->context t] | 172 | ["Unified -> Context" diff-unified->context t] |
| 173 | ;;["Fixup Headers" diff-fixup-modifs (not buffer-read-only)] | 173 | ;;["Fixup Headers" diff-fixup-modifs (not buffer-read-only)] |
| 174 | "-----" | 174 | "-----" |
| 175 | ["Split hunk" diff-split-hunk t] | 175 | ["Split hunk" diff-split-hunk (diff-splittable-p)] |
| 176 | ["Refine hunk" diff-refine-hunk t] | 176 | ["Refine hunk" diff-refine-ignore-spaces-hunk t] |
| 177 | ["Kill current hunk" diff-hunk-kill t] | 177 | ["Kill current hunk" diff-hunk-kill t] |
| 178 | ["Kill current file's hunks" diff-file-kill t] | 178 | ["Kill current file's hunks" diff-file-kill t] |
| 179 | "-----" | 179 | "-----" |
| @@ -416,6 +416,12 @@ but in the file header instead, in which case move forward to the first hunk." | |||
| 416 | (diff-beginning-of-file-and-junk) | 416 | (diff-beginning-of-file-and-junk) |
| 417 | (diff-hunk-next)))))) | 417 | (diff-hunk-next)))))) |
| 418 | 418 | ||
| 419 | (defun diff-unified-hunk-p () | ||
| 420 | (save-excursion | ||
| 421 | (ignore-errors | ||
| 422 | (diff-beginning-of-hunk) | ||
| 423 | (looking-at "^@@")))) | ||
| 424 | |||
| 419 | (defun diff-beginning-of-file () | 425 | (defun diff-beginning-of-file () |
| 420 | (beginning-of-line) | 426 | (beginning-of-line) |
| 421 | (unless (looking-at diff-file-header-re) | 427 | (unless (looking-at diff-file-header-re) |
| @@ -528,6 +534,13 @@ data such as \"Index: ...\" and such." | |||
| 528 | (while (re-search-forward re end t) (incf n)) | 534 | (while (re-search-forward re end t) (incf n)) |
| 529 | n))) | 535 | n))) |
| 530 | 536 | ||
| 537 | (defun diff-splittable-p () | ||
| 538 | (save-excursion | ||
| 539 | (beginning-of-line) | ||
| 540 | (and (looking-at "^[-+ ]") | ||
| 541 | (progn (forward-line -1) (looking-at "^[-+ ]")) | ||
| 542 | (diff-unified-hunk-p)))) | ||
| 543 | |||
| 531 | (defun diff-split-hunk () | 544 | (defun diff-split-hunk () |
| 532 | "Split the current (unified diff) hunk at point into two hunks." | 545 | "Split the current (unified diff) hunk at point into two hunks." |
| 533 | (interactive) | 546 | (interactive) |
| @@ -1525,7 +1538,7 @@ For use in `add-log-current-defun-function'." | |||
| 1525 | (goto-char (+ (car pos) (cdr src))) | 1538 | (goto-char (+ (car pos) (cdr src))) |
| 1526 | (add-log-current-defun)))))) | 1539 | (add-log-current-defun)))))) |
| 1527 | 1540 | ||
| 1528 | (defun diff-refine-hunk () | 1541 | (defun diff-refine-ignore-spaces-hunk () |
| 1529 | "Refine the current hunk by ignoring space differences." | 1542 | "Refine the current hunk by ignoring space differences." |
| 1530 | (interactive) | 1543 | (interactive) |
| 1531 | (let* ((char-offset (- (point) (progn (diff-beginning-of-hunk 'try-harder) | 1544 | (let* ((char-offset (- (point) (progn (diff-beginning-of-hunk 'try-harder) |