2022 Developer Survey is open! Take survey.

Hot answers tagged

56 votes
Accepted

How to view diff when emacs suggests to recover this file?

After running recover-this-file and accepting the autosave version, you'll have a modified buffer containing the autosave contents. At this point you can use M-x diff-buffer-with-file RET to see the ...
user avatar
  • 43.1k
17 votes

How to start ediff-ing a file that has git conflict markers in it?

If you use magit, you can press e at the unmerged file in magit status buffer (started by pressing M-xmagit-statusRET) to start ediff session for resolving the conflicts
user avatar
  • 7,278
16 votes
Accepted

How do I compare regions in the same file?

You can use ediff-regions-wordwise. It prompts you for two buffers, and then for two regions. The buffers can be the same.
user avatar
  • 13.6k
15 votes
Accepted

How can I quit ediff immediately without having to type 'y'

You can advise ediff-quit so it dynamically rebinds y-or-n-p to a function that returns t. (defun disable-y-or-n-p (orig-fun &rest args) (cl-letf (((symbol-function 'y-or-n-p) (lambda (prompt) ...
user avatar
14 votes
Accepted

How to show a diff between two buffers with "character-level" diffs

(setq-default ediff-forward-word-function 'forward-char)
user avatar
12 votes

How to start ediff-ing a file that has git conflict markers in it?

You can use the minor mode smerge-mode to move between conflicts and resolve them. You can open ediff to resolve conflicts with C-c ^ E while in smerge mode.
user avatar
11 votes

How to start ediff-ing a file that has git conflict markers in it?

M-x vc-resolve-conflicts RET I bind it to C-xv<
user avatar
  • 43.1k
11 votes
Accepted

Launch emacs with ediff-files (of ediff-directories) from command line

I'm pretty sure there are other solutions, but you can do this using --eval instead of -f (--funcall): emacs --eval '(ediff-files "file1" "file2")' In fact, the Emacs manual on &...
user avatar
  • 14.2k
10 votes
Accepted

Restoring windows and layout after an Ediff session

What you want can be achieved cleanly using hook provided by ediff (which if read the documentation seem to be provided for this exact purpose), advices are not needed. The relevant hooks are 1) ...
user avatar
  • 7,278
10 votes
Accepted

Comparing two text files on a Windows system

As @nanny said in comments, solution is having installed Cygwin with diffutils. Here is how to do it: Download Cygwin from its homepage. Install Cygwin with diffutils: A GNU collection of diff ...
user avatar
  • 1,311
10 votes
Accepted

Prevent folding org files opened by ediff

It sounds like your goal is to have org-mode files always show everything when in ediff. The simplest solution is probably to avoid the local variables approach and just put show-all in the relevant ...
user avatar
  • 31k
9 votes

Stage diff hunk into git from ediff?

Move point to the file you want to partially stage/unstage using Ediff and press e (magit-ediff-dwim). Alternatively you can also leave point where it is and press E s (magit-ediff-stage) but then you ...
user avatar
  • 24.2k
8 votes
Accepted

How to use both variants in Ediff?

See this StackOverflow answer. From @killdash9: Pressing d will copy both A and B to buffer C. (defun ediff-copy-both-to-C () (interactive) (ediff-copy-diff ediff-current-difference nil 'C ...
user avatar
7 votes

Comparing two text files on a Windows system

If you have git for windows installed, then it is enough to add C:\Program Files\Git\usr\bin\ to your PATH, because it already ships with a diff executable and installs it in that folder.
user avatar
  • 181
7 votes

How do I ediff a buffer against a revision?

When using magit: Use l -al l to view the revisions of all branches in your history go to the line containing the revision you want to compare your current buffer content against. Type d and you are ...
user avatar
  • 1,734
7 votes
Accepted

How do I ediff a buffer against a revision?

Emacs is doing what you told it to do instead of what you meant. ediff-revision asks for three pieces of information: The file to work on — default: the file that the current buffer is visiting. The ...
user avatar
7 votes

How can I compare two commit diffs in magit?

You can do it from the magit-log buffer M-x magit-log E r ref1..ref2
user avatar
  • 3,006
6 votes

How to show a diff between two buffers with "character-level" diffs

This feature is called "refining" in Ediff. You can hit * to refine the current hunk, or @ to turn on automatic refining whenever you move to a different hunk.
user avatar
  • 5,786
6 votes

How to make vc-* and magit treat a symbolic link to a real file in git repo just like the original file?

It's really quite simple; don't do that: I use (setq vc-follow-symlinks nil) to not prompt to ask yes/no and not follow to the real file It doesn't make much sense to set this variable to nil and ...
user avatar
  • 24.2k
6 votes
Accepted

How to make vc-* and magit treat a symbolic link to a real file in git repo just like the original file?

I had the same problem and added ;;; When opening a file that is a symbolic link, don't ask whether I ;;; want to follow the link. Just do it (setq find-file-visit-truename t) to my .emacs file. ...
user avatar
  • 1,069
6 votes

How can I diff two long lines from the same buffer?

Split the window. In each window, put point at the start of one of the two lines (or at the start of each "..." in your example). M-x compare-windows RET C-xzzzz... to repeatedly compare as many times ...
user avatar
  • 43.1k
5 votes
Accepted

How to undo on ediff A-B changes

ediff-mode has built-in bindings to apply and revert diff hunks. Let's say you are running ediff between files/buffers A and B. To copy A's region to B, press a To undo that, i.e. to restore the ...
user avatar
  • 24.2k
5 votes

Launch emacs with ediff-files (of ediff-directories) from command line

I use the following script: it checks in advance if there are differences, and in case there are, it opens Emacs with the appropriate function evaluated. With the -d option, it assumes the items ...
user avatar
5 votes

How can I quit ediff immediately without having to type 'y'

Unfortunately I think you do have to either rebind q or adjust the source of ediff-quit. As is apparent in the source of ediff-quit the prompt always happens. (defun ediff-quit (reverse-default-keep-...
user avatar
  • 3,954
5 votes
Accepted

How can I compare two commit diffs in magit?

Based on Kyle Meyer's comment to the OP -- thanks, Kyle. It seems that what you want is to see the diffs associated with the two commits in two separate magit-revision buffers. You can accomplish ...
user avatar
  • 334
4 votes

Restoring windows and layout after an Ediff session

Look at what you made me do, I was so happy with my ugly hack, and now it's fixed: (defvar ediff-last-windows nil "Last ediff window configuration.") (defun ediff-restore-windows () "Restore ...
user avatar
  • 13.6k
4 votes
Accepted

How can I only show different lines in ediff?

You can tweak the options used by Ediff by customizing ediff-diff-options, but options controlling the display (like context) are not supported. You can however call ediff-show-diff-output from an ...
user avatar
  • 19.1k
4 votes

Prevent folding org files opened by ediff

Another option can be found on the worg page. The basic idea is to use ediff-select-hook to unfold an element whenever given region is selected in ediff and folding them back in the ediff-unselect-...
user avatar
  • 7,278
4 votes
Accepted

magit ediff conflicts wordwise

Good question. This feels like it should be standard. With a little digging into the code and experimenting, this seems at first glance to work: From the ediff control window: M-: (setq ediff-word-...
user avatar
  • 43.1k
3 votes

Comparing two text files on a Windows system

This may save people some time so I will answer here. If you do not wish to add the cygwin bin directory to your path (or any of the other ones suggested in the other answers), you can set the path of ...
user avatar
  • 131

Only top scored, non community-wiki answers of a minimum length are eligible