A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Hot answers tagged

51

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 ...


16

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


13

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.


10

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.


10

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


10

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


9

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 function (a command), it reads the ...


9

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


8

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. ...


8

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

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 ...


8

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 #'...


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 ...


7

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-...


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.


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.


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 ...


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

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


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

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 ...


3

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.


3

You can try with the diffview package: https://github.com/emacsmirror/diffview configuration (require 'diffview) execution M-x diffview-current


3

There is an internal predicate in ediff-init.el, called ediff-window-display-p. When I redefined it (after loading ediff, of course) like so, everything works in a single frame, including the function you mentioned as a problem: (defun ediff-window-display-p () nil) I do agree with @lawlist that this is a nice feature request -- to fix ediff-window-setup-...


3

Edit: The duplicate Q&A on StackOverflow has answers to this question (as pointed out by Tianxiang Xiong in the comments). My answer below is no use, as you evidentially can't get the desired result that way. I'm only not deleting it because the information it does give is somewhat relevant, and might still prove interesting information to someone. ...


3

Move to the coloured text you're interested in, and type C-uC-x= to view details of the character at point, including any faces. Select the face you're interested in, then select "customize this face", make the desired changes, and save.


3

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 ...


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