Custom buffers, for example, to change the order of the elements in a
list.
+** Diff
+
+---
+*** New 'diff-mode' font locking face 'diff-error'.
+This face is used for error messages from diff.
+
++++
+*** New command 'diff-refresh-hunk'.
+This new command (bound to 'C-c C-l') regenerates the current hunk.
+
+
** Miscellaneous
+++
number". (This requires that all callers are altered to use
'format-prompt', though.)
----
-*** New 'diff-mode' font locking face 'diff-error'.
-This face is used for error messages from diff.
-
+++
*** New global mode 'global-goto-address-mode'.
This will enable 'goto-address-mode' in all buffers.
;; `d' because it duplicates the context :-( --Stef
("\C-c\C-d" . diff-unified->context)
("\C-c\C-w" . diff-ignore-whitespace-hunk)
+ ;; `l' because it "refreshes" the hunk like C-l refreshes the screen
+ ("\C-c\C-l" . diff-refresh-hunk)
("\C-c\C-b" . diff-refine-hunk) ;No reason for `b' :-(
("\C-c\C-f" . next-error-follow-minor-mode))
"Keymap for `diff-mode'. See also `diff-mode-shared-map'.")
:help "Split the current (unified diff) hunk at point into two hunks"]
["Ignore whitespace changes" diff-ignore-whitespace-hunk
:help "Re-diff the current hunk, ignoring whitespace differences"]
+ ["Recompute the hunk" diff-refresh-hunk
+ :help "Re-diff the current hunk, keeping the whitespace differences"]
["Highlight fine changes" diff-refine-hunk
:help "Highlight changes of hunk at point at a finer granularity"]
["Kill current hunk" diff-hunk-kill
(defun diff-ignore-whitespace-hunk ()
"Re-diff the current hunk, ignoring whitespace differences."
(interactive)
+ (diff-refresh-hunk t))
+
+(defun diff-refresh-hunk (&optional ignore-whitespace)
+ "Re-diff the current hunk."
+ (interactive)
(let* ((char-offset (- (point) (diff-beginning-of-hunk t)))
- (opts (pcase (char-after) (?@ "-bu") (?* "-bc") (_ "-b")))
+ (opt-type (pcase (char-after)
+ (?@ "-u")
+ (?* "-c")))
(line-nb (and (or (looking-at "[^0-9]+\\([0-9]+\\)")
(error "Can't find line number"))
(string-to-number (match-string 1))))
(file1 (make-temp-file "diff1"))
(file2 (make-temp-file "diff2"))
(coding-system-for-read buffer-file-coding-system)
- old new)
+ opts old new)
+ (when ignore-whitespace
+ (setq opts '("-b")))
+ (when opt-type
+ (setq opts (cons opt-type opts)))
+
(unwind-protect
(save-excursion
(setq old (diff-hunk-text hunk nil char-offset))
(write-region (concat lead (car new)) nil file2 nil 'nomessage)
(with-temp-buffer
(let ((status
- (call-process diff-command nil t nil
- opts file1 file2)))
+ (apply 'call-process
+ `(,diff-command nil t nil
+ ,@opts ,file1 ,file2))))
(pcase status
(0 nil) ;Nothing to reformat.
(1 (goto-char (point-min))