Robusto's answer accounts quite clearly for Doyle's use, which reflects (I think tongue in cheek, but I could be wrong) the vices of contemporaneous journalism.

Your own examples, however, do indeed reflect "a special, dedicated way to express some relations between moments of time". To pin down what the differences are, try recasting your abstract actions—the do somethings—as concrete ones, and add temporal modifiers, thus:

I will do something if you have done something.

"I'm leaving for the office now. I will give your letter to the boss if you have finished it." Here the focus is on the moment of leaving. The letter must be finished (which is what 'perfect' means, literally) now; otherwise I cannot take it with me. And the letter is to be delivered in the future, with respect to that moment.

I did something when he had done something.

"I left for the office at eight o'clock. Ed had finished the letter, so I would give it to the boss when I arrived." As before, the focus is on a single moment of leaving; but that moment is now in the past, so the simple present is recast as a simple past; the simple perfect is recast as a past perfect by employing the past of the auxiliary; and in very old-fashioned writing, the future is also recast with the past of the auxiliary.

Today, however, practically nobody understands would to be the past tense of will; it is rarely used outside an "unreal" context. In effect, English has lost the future-in-the-past construction. Consequently, you must replace would with the past form of a different expression such as can—"so I could give, &c".

If, however, the "unreal" came into play, if what you intended didn't actually happen, you would revert to would. BUT: in this case, the loss of the future-in-the-past requires you to shift your focus to a subsequent time—the time at which the anticipated event failed to occur. So the future-in-the-past event becomes an unreal-perfect-in-the-past event: "I would have given it to the boss when I arrived, but he had already left."

I will do something if you do something.

"I'm leaving for the office now. If you bring me the letter before noon I will give it to the boss." Now the focus is on future events, so a future construction is employed in the indicative main clause; it could be used in the conditional as well, but the 'present' tense (which is actually not a present tense but a non-past tense) is ordinarily used in these constructions, since the conditional's 'modal' quality embraces futurity.

I did something when he did something.

"I left for the office at eight o'clock. I gave the letter to the boss when Ed brought it to me at eleven." Once more, all the events are in the past; in this case, however, there is no obnoxious future to express, and the sequence is made clear lexically, so the simple past construction can be used throughout.


If you look at a little context, you can see that Conan-Doyle came adrift from his timeframe just a bit:

The account of Mrs. Allen, the housekeeper, was, so far as it went, a corroboration of that of her fellow servant. The housekeeper's room was rather nearer to the front of the house than the pantry in which Ames had been working. She was preparing to go to bed when the loud ringing of the bell had attracted her attention. She was a little hard of hearing. Perhaps that was why she had not heard the shot; but in any case the study was a long way off. She remembered hearing some sound which she imagined to be the slamming of a door. That was a good deal earlier--half an hour at least before the ringing of the bell. When Mr. Ames ran to the front she went with him. She saw Mr. Barker, very pale and excited, come out of the study. He intercepted Mrs. Douglas, who was coming down the stairs. He entreated her to go back, and she answered him, but what she said could not be heard.

Notice that the past tense and past perfect are shuttling back and forth so quickly that it would take a good deal of effort to keep them straight. But it is pretty clear that the past tense is meant to describe the general state of things as they were, and past perfect to refer to actions taken at the time of the past narrative. So it would have been clearer had Conan-Doyle written the sentence this way:

She had been preparing to go to bed when the loud ringing of the bell attracted her attention.

That would have placed the ringing of the bell in the same timeframe as her preparations for bed.

What, you think authors don't make mistakes? Sure they do. So do editors.