The discovery of a painting at a mansion house in the Borders has helped to reveal the history of one of Britain's rarest breeds of terrier.
It appears every living Dandie Dinmont can now be traced to a pet owned by Sir Walter Scott and a poacher's dog caught in a trap in Selkirk.
And in a bid to save the wee Scottish terrier from extinction, later this month 50 of the few surviving Dandie Dinmonts, led by their proud owners, will come "home" to Selkirk's Georgian Haining House, where it has been revealed the pedigree originated in a dog called Old Ginger.
On the two-day trip, 75 Dandie-lovers from eight countries will join fans of Sir Walter Scott at Abbotsford, in celebrating the 200th anniversary of the Border bard's second novel Guy Mannering, which gave the Dandie Dinmont breed its name, and fame, in February 1815.
Scott's best-selling tale of smugglers, which sold out in its first 24 hours, first introduced the tough but friendly Liddesdale farmer Dandie Dinmont, whose temperament matched those of his six "Pepper and Mustard Terriers", which, like many of Scott's fictions, were based on historical fact.
These game little Border terriers had been bred for poaching, and hunting badgers and foxes, since at least 1770, when Thomas Gainsborough painted the earliest-known image of a "Dandie-like" dog, at the foot of Henry, 3rd Duke of Buccleuch.
Factfile: Dandie Dinmont terrier
A breed of terrier developed in the border country of England and Scotland.
First noted as a distinct breed about 1700, it was later named after a character created by Sir Walter Scott in his novel Guy Mannering (1815).
Unlike other terriers, the Dandie Dinmont has a softly curved, rather than angular, body.
It has large eyes, a long body, short legs, and a large, domed head crowned by a silky topknot. Its crisp-textured coat, a combination of hard and soft hairs, may be pepper (silver-grey to blue-black) or mustard (light fawn to reddish brown) in colour.
The Dandie Dinmont stands 8 to 11 inches (20 to 28 cm) and weighs 18 to 24 pounds (8 to 11 kg).
Source: Encyclopaedia Britannica
Thanks to the book's popularity, they became the fashionable Dandie Dinmont, beloved pets of Queen Victoria, Sir Edwin Landseer, and later Agatha Christie and Sir Alec Guinness.
They even had a Clyde paddle steamer, a locomotive, a tobacco and a whisky blend named after them.
Today the Dandie is the only breed of dog named after a fictional character, but its factual origin, which has just come to light, is a story worth telling too.
The latest chapter begins at a house auction, raising funds to renovate a Palladian mansion in Selkirk called the Haining, bequeathed to the people of Selkirkshire in 2009 by its late owner, Andrew Nimmo-Smith.
One of the lots, a landscape titled "Dandy Dinmonts by the Haining Loch", signed by Scottish artist Robert Smellie in 1888, was bought by canine art dealer Paul Keevil, who wondered if the four males, bitch and puppy depicted in the scene were studs from the breed's history.
The hunt was on. Digging deep into the Haining records, Mr Keevil got nose of a familiar name, Old Ginger - known to be one of the pedigree's founding fathers - as belonging to Robert Pringle, owner of the Haining in the 1840s.
Following the scent further, Mr Keevil rooted out that Old Ginger, after Pringle's death, had passed to Eaglesfield Bradshaw-Smith of Blackwood House, Dumfriesshire - the man today hailed as the "saviour" of the breed, who used Old Ginger as a stud.
Eaglesfield's impeccable records uncovered Old Ginger's father to be the granddaddy of all living Dandie Dinmonts: a wee "dug" called Old Pepper, of unknown pedigree, because he was caught in a poachers' trap by the gamekeeper to the 5th Duke of Buccleuch on his estate near Selkirk, Bowhill, in 1839.
Closing in on the kill, Mr Keevil tracked Old Ginger's mother Vixen, and his grandmother Wasp, as also belonging to Robert Pringle and his sister Mrs V Douglas at the Haining - thereby establishing Selkirk as the likely cradle of the Dandie Dinmont pedigree.
But Mr Keevil unearthed one last twist, worthy of a Scott story.
Vixen's father, The Mertoun Dandie, was bred by none other than Sir Walter himself: the man who began the craze for the Dandie Dinmont in 1815.
So not only did Scott name the breed, but he helped create it too.
Sadly, the fortunes of the Dandie Dinmont have declined so much that for the past 10 years The Kennel Club has listed it as a Vulnerable Native Breed. Britain produces about 100 puppies a year, while only around 300 are born annually worldwide.
Mr Keevil, who is co-ordinating the dogs' homecoming celebrations, said: "Two hundred years ago, Sir Walter Scott brought the Dandie Dinmont Terrier to prominence and today, 200 years later, we are extracting his help once again to create awareness of this lovely little dog and, hopefully, save it from possible extinction."
From 23 to 24 February, the gathering of Dandie Dinmonts and their owners will visit the three historic houses which played a part in the breed's creation, including Abbotsford and Bowhill, where they will be greeted by the Duke of Buccleuch, who owns an original painting of Old Pepper.
They will also ask the Duke's permission, as chief of clan Scott, to adopt the Walter Scott plaid as the official tartan of the Dandie Dinmont Terrier.
But the crowning glory will be the Dandie Dinmonts returning to their roots at the Haining in Selkirk.
Fellow dog-lovers are invited to welcome them "home", for the first time in 170 years, on 23 February.