My memory of this is sketchy, at best, but maybe someone will recognize it…
Two men (A and B) were walking down an alley when A says … something. I forget what. B amazed because, whatever A just said was EXACTLY what B was thinking at the moment.
“However did you know I was thinking that?” says B.
A goes off into a long, convoluted story about B kicking a cobblestone which got him thinking about this and then that and then the other and then the play they had just seen and then Orion (and here A says “And just at that moment you glanced up at the sky, so I knew you were thinking of Orion.”) and then yet another thing, all of which led up to the initial comment.
For some reason I think this is Poe or A. C. Doyle.
You’ve got a very, very distorted memory of the opening of a Holmes story–if I get a moment I’ll track down which one. Holmes & Watson are sitting in their quarters & Holmes breaks in on Watson’s train of reflection to make an uncanny reply to what he’s thinking, & then in response to Watson’s incredulity retraces his deductions. My recollection was that Holmes’s comment was something about the foolishness of nations’ settling quarrels by means of war.