Hot answers tagged

55

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 differences between the modified buffer and the saved file. The key I've bound for this actually runs a custom function, in order to produce a unified diff, and ...


17

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


14

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) t))) (apply orig-fun args))) (advice-add 'ediff-quit :around #'disable-y-or-n-p) This is more robust to upstream changes than redefining ediff-quit.


14

(setq-default ediff-forward-word-function 'forward-char)


13

You can use ediff-regions-wordwise. It prompts you for two buffers, and then for two regions. The buffers can be the same.


11

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.


11

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 "Command Line Arguments for Emacs Invocation" says that -f function and --funcall function Call Lisp function function. If it is an interactive ...


10

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 utilities package. This package can be found in Utils section in one of few steps of Cygwin installation. Add Cygwin directories to the PATH windows system variable. ...


10

M-x vc-resolve-conflicts RET I bind it to C-xv<


10

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 hook, ediff-prepare-buffer-hook which is run after buffers A, B, & C are set up: (with-eval-after-load 'outline (add-hook 'ediff-prepare-buffer-hook #'...


9

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) ediff-quit-hook, from the documentation Hooks to run in the Ediff control buffer after finishing Ediff. 2) ediff-before-setup-hook Hooks to run before Ediff ...


9

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 will be asked about the file in the minibuffer - so moving to the file first might be more convenient. In the resulting Ediff session use c b to stage and a b ...


8

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 nil (concat (ediff-get-region-contents ediff-current-difference 'A ediff-control-buffer) (ediff-get-...


7

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.


7

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 asked for which revision to compare the current working tree against (the default is the revision at point). Confirm. You'll get a diff overview over changes of ...


7

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 old revision — default: the latest revision. The new revision — default: the current state. At step 1, you select the file, you aren't telling Emacs that you ...


6

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.


6

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 find-file-visit-truename to t. Both variables control whether Emacs should follow symlinks when visiting files. But the latter is much more aggressive. vc-...


6

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. Unfortunately I can't remember where on the web I found this, so no source credits.


5

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 original region in buffer B, do rb Similarly To copy B's region to A, press b To undo that, i.e. to restore the original region in buffer A, do ra While the ...


5

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 provided are directories, and ediff-directories instead of ediff-files is used; otherwise it checks if they are directories or files, and sets the function to use ...


5

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-variants) "Finish an Ediff session and exit Ediff. Unselects the selected difference, if any, restores the read-only and modified flags of the compared file ...


5

You can do it from the magit-log buffer M-x magit-log E r ref1..ref2


5

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 this by loading up the first diff in the usual way (e.g. by hitting RET on it in a log view), running M-x magit-toggle-buffer-lock so that the buffer becomes ...


4

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 window configuration to `ediff-last-windows'." (set-window-configuration ediff-last-windows) (remove-hook 'ediff-after-quit-hook-internal 'ediff-...


4

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 ediff session (bound to D). This command will create a new buffer containing the 'raw' diff output. This command can have its own set of options, e.g. (setq ...


4

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-hook. I am posting the code here for completeness ;; Check for org mode and existence of buffer (defun f-ediff-org-showhide (buf command &rest cmdargs) "If ...


4

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-mode t) RET ! to run ediff-update-diffs Which we can encapsulate in a command (which I've bound to . in the ediff control buffer) like so: (defun my-ediff-...


3

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 the program ediff uses by setting the variable ediff-diff-program. For example you could set it to C:\cygwin\bin (or whatever the actual path is in your case) ...


3

What you did would not work for various reasons. Firstly, because indeed the ediff-* variables and functions are only local to the control window, you cannot call those functions from another window. But you can simply use with-selected-window to switch windows: (with-selected-window (get-buffer-window "*Ediff Control Panel*") (ediff-copy-B-to-A)) ...


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