1

After setting Dired do-what-I-mean

(setq dired-dwim-target t)

which, quoting the man pages

If non-nil, Dired tries to guess a default target directory. This means: if there is a Dired buffer displayed in some window, use its current directory, instead of this Dired buffer’s current directory.

but you frequently want the target to be some other directory. In particular, you may want to copy (if copy is the operation at hand) to the same directory, not to the C-x 3 (and hence dwimeant) directory.

How do you target the present directory, once in a while, with dwim enabled?

Drew
  • 75,699
  • 9
  • 109
  • 225
Calaf
  • 483
  • 3
  • 16
  • 1
    What do you mean by "exclude" here? Do you mean ahead of time in some sense, or when you actually do the copy or whatever? (In the latter case you just tell it what target you want.) The question isn't clear to me. – Drew Nov 01 '21 at 15:49
  • @Drew yeah... "exclusion" was hardly the best word. Rephrased, but anyway phils provides exactly the solution I was seeking. – Calaf Nov 03 '21 at 02:58

1 Answers1

3

I think such exclusions cannot be pre-determined, but are simply decisions you make at the time you decide to copy the file.

In such cases I just use M-n at the prompt, which gives me the original directory as the first option.

M-n runs the command next-history-element

Puts next element of the minibuffer history in the minibuffer. With argument N, it uses the Nth following element. The position in the history can go beyond the current position and invoke "future history."

Where "future history" can be alternatively phrased as "educated guesses". This works at many prompts.

In this case, dired ensures that the original directory is first in that list.

phils
  • 48,657
  • 3
  • 76
  • 115