When I invoke diff I get two ivy prompts. The first one defaults to the current buffer, the second often to some kind of backup.

It is quite awkward to navigate from the backup path to any useful location, so I was wondering if I could change that.
Is it from ivy? Or from diff? Can I use advice here?

Ideally the second prompt would default to the path of the buffer in another open window, or if there is none, default to the same location as the first.

I am using Doom, if that matters.

  • 2
    The default is determined by diff, not ivy; specifically the function file-newest-backup. FWIW, you can repeatedly type M-n (next-history-element) to see other default file suggestions.
    – Basil
    Jul 3, 2021 at 20:46
  • Thanks for the pointer, but that function doesn't do anything useful for me.
    – xeruf
    Jul 4, 2021 at 15:23
  • You could advise or set the interactive spec of diff to use your preferred default instead of file-newest-backup; or you could write a custom function with your preferred interactive spec that in turn calls diff non-interactively. You could also submit a feature request or patch upstream via M-x report-emacs-bug to make diff's default prompt more customisable.
    – Basil
    Jul 4, 2021 at 16:57
  • Actually, M-n has become a staple in my workflow now, thank you very much :)
    – xeruf
    Oct 12, 2021 at 7:43


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.