Emacs has a really nice mode for applying and navigating hunks of a diff file: Diff-Mode

However, there doesn't seem to be a way to apply the full diff when in this mode. Is this just so obvious that I missed it?

1 Answer 1


There doesn't seem to be a function that does that.

You can get that functionality by using a macro. First, hit F3 C-c C-a F4 to define a macro that applies a hunk, and then type C-u 0 M-x kmacro-call-macro to repeatedly call that macro until an error occurs (probably at the end of the diff file).

  • it'd be pretty nice if Diff-Mode was a single keystroke interface... no need for the C-c C- prefix. More magit-like.
    – fommil
    Commented Jan 24, 2016 at 12:11
  • 2
    If you put your diff in read-only mode, you get a few "single keystroke" shortcuts. WRT to a command applying the whole diff, I'd welcome a patch that implements it.
    – Stefan
    Commented Jan 26, 2016 at 4:26
  • @Stefan excellent! Where are the docs for read-only mode commands? I'd like to make diffs read-only by default. BTW, we're using diff-mode as the interface for refactorings in ensime :-)
    – fommil
    Commented Jan 26, 2016 at 9:02
  • 1
    C-h f diff-mode-shared-map and then follow the link to the source code. This map is bound to ESC (aka the Meta modifier) normally but is also used without prefix when the buffer is read-only.
    – Stefan
    Commented Jan 26, 2016 at 13:00
  • it must be C-h v diff-mode-shared-map because it is a variable and not a function. Commented Jul 8, 2016 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.