This comes from the book Walden by American author and philosopher Henry David Thoreau. Thoreau had spent some time living in an isolated cabin near Walden Pond, Massachusetts, as a social experiment and he wrote a book about his experiences.
If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music which he hears, however measured or far away.
The book was published in 1854, making it quite possible that Wigram in The Far Pavilions had read it and was quoting from it.
There are many superstitions regarding magpies - for example, some people salute them when they see them to ward off bad luck.
There are several rhymes and poems about magpies, including the following:
"One for sorrow, two for joy; Three for a girl, four for a boy; Five for silver, six for gold; Seven for a secret, never to be told."
Magpies are also known for their love of shiny objects.