Bonnie Dundee is the title of a poem and a song written by Walter Scott in 1825 in honour of John Graham, 7th Laird of Claverhouse, who was created 1st Viscount Dundee in November 1688, then in 1689 led a Jacobite rising in which he died, becoming a Jacobite hero.

The older tune Bonny Dundee adapted by Scott had already been used for several songs appearing under variations of that title and referring to the bonnie town of Dundee rather than to Claverhouse.  Scott's song has been used as a regimental march by several Scottish regiments in the British Army.

Bonny Dundee: tunes and songs
Bonny Dundee is a very old Scottish folk-tune used for at least fifteen songs. A simpler version of the tune appears in the Skene manuscript around 1630 under the title Adew, Dundee. The title Bonny Dundee for the tune appears in an appendix to John Playford's 1688 edition of The Dancing Master, an English publication. The tune has been used for the following popular song:
O whaur gat ye that hauver-meal bannock?
Silly blind body, O dinna ye see?
I gat it frae a brisk sodger laddie,
Atween Saint Johnstone and Bonnie Dundee.

O, gin I saw the laddie that gae me't!
Aft has he doudl'd me on o' his knee.
But now he's awa', and I dinner ken whaur he's,
O gin he was back to his minnie and me!

"Saint Johnstone" refers to Perth, and "Bonny Dundee" is the town of Dundee. This song was parodied in English publications of the early 18th century with coarser wording, under the title Jockey's Deliverance, or the Valiant Escape from Dundee, to be sung "to an Excellent Tune, called Bonny Dundee."  A 1719 collection titled the parody Jockey's Escape from Dundee; and the Parsons Daughter whom he had Mowd, and its chorus featured variations on "Come open the Gates, and let me go free, And shew me the way to bonny Dundee". Robert Burns rewrote the second verse of the original, so that the latter lines were "May Heaven protect my Bonnie Scots laddie, and send him safe hame to his baby and me." He added a concluding verse with the promise to the baby to "bigg a bower on yon bonnie banks, where Tay rins dimpling by sae clear", alluding to the River Tay.  Another version of the original, titled Scots Callan O' Bonnie Dundee, refers to a callant (lad) rather than a soldier, and a "bonnie blue bonnet" instead of a bannock.

The tune is used for unrelated words in a broadside ballad published in 1701 under the title Bonny Dundee, suggesting that it was to be sung to this melody, and in John Gay's The Beggar's Opera published in 1765.

Graham of Claverhouse
From 1668 John Graham, the laird of Claverhouse was at the forefront of Royalist repression of the Covenanters, for which he was called "Bluidy Clavers" (Bloody Claverhouse) by his covenanting opponents. In 1688 he was made 1st Viscount of Dundee by James VII of Scotland (James II of England). When William of Orange overturned James in 1688 in what was called the Glorious Revolution, Claverhouse was one of the few Scottish nobles who remained loyal to James. After trying to influence the Convention of Estates of Scotland on James's behalf, at some danger to himself, he led his cavalry out of Edinburgh to carry on the struggle in the field and was killed at the moment of victory in the battle of Killiecrankie (1689). His forces were subsequently defeated at the Battle of Dunkeld. Over a century later he was immortalised in a poem by Walter Scott which was later adapted into a song.

Walter Scott's poem
Walter Scott's novel Old Mortality, published in 1816, gives a sympathetic portrait of Claverhouse. The story mentions one of Claverhouse's troopers "humming the lively Scottish air, 'Between Saint Johnstone and Bonny Dundee, I'll gar ye be fain to follow me'." In this, "Saint Johnstone" refers to Perth, and "Bonny" was the common description of the town of Dundee before Scott transferred the description to Claverhouse.

On 22 December 1825 Scott wrote in his journal:

Scott sent a copy of the verses to his daughter-in-law Jane, mentioning that his great-grandfather had been among Claverhouse's followers and describing himself as "a most incorrigible Jacobite". This is a comic exaggeration, but Scott's ballad is certainly written from the point of view of Claverhouse, whom he had already celebrated in his novel Old Mortality (1816). It consists of eleven stanzas, which Scott admitted was "greatly too long" (Letters, vol. 9, p. 350), with a refrain copied from the traditional song Jockey's Escape from Dundee.

The poem was first published in a miscellany, The Christmas Box (1828-9), and then included as a song in Scott's unperformed play The Doom of Devorgoil (1830). Later adaptations for singing include only stanzas 1, 2, 8 and 10, with the refrain. After Scott's death, many changes were made in the text in different republications. Some add extra Scotticisms, e.g. "To the lords" becomes "Tae the lairds". The authentic long text below comes from The Poetical Works of Sir Walter Scott, Bart. (12 vols., 1833-4), ed. J. G. Lockhart (vol. 12, pp. 903–4).

Scott's original poem
To the Lords of Convention 'twas Clavers who spoke.
'Ere the King's crown shall fall there are crowns to be broke;
So let each Cavalier who loves honour and me,
Come follow the bonnet of Bonny Dundee.
Come fill up my cup, come fill up my can,
Come saddle your horses, and call up your men;
Come open the West Port and let me gae free, 
And it's room for the bonnets of Bonny Dundee!

Dundee he is mounted, he rides up the street,
The bells are rung backward, the drums they are beat;
But the Provost, douce man, said, "Just e'en let him be,
The Gude Town is weel quit of that De'il Dundee."
Come fill up my cup, etc.

As he rode down the sanctified bends of the Bow,
Ilk carline was flyting and shaking her pow;
But the young plants of grace they looked couthie and slee,
Thinking luck to thy bonnet, thou Bonny Dundee!
Come fill up my cup, etc.

With sour-featured Whigs the Grass-market was crammed,
As if half the West had set tryst to be hanged;
There was spite in each look, there was fear in each e'e,
As they watched for the bonnets of Bonny Dundee.
Come fill up my cup, etc. 

These cowls of Kilmarnock had spits and had spears,
And lang-hafted gullies to kill cavaliers;
But they shrunk to close-heads and the causeway was free,
At the toss of the bonnet of Bonny Dundee.
Come fill up my cup, etc.

He spurred to the foot of the proud Castle rock,
And with the gay Gordon he gallantly spoke;
"Let Mons Meg and her marrows speak twa words or three,
For the love of the bonnet of Bonny Dundee."
Come fill up my cup, etc. 

The Gordon demands of him which way he goes?
"Where'er shall direct me the shade of Montrose!
Your Grace in short space shall hear tidings of me,
Or that low lies the bonnet of Bonny Dundee.
Come fill up my cup, etc.

"There are hills beyond Pentland and lands beyond Forth,
If there's lords in the Lowlands, there's chiefs in the North;
There are wild Duniewassals three thousand times three,
Will cry hoigh! for the bonnet of Bonny Dundee.
Come fill up my cup, etc. 

"There's brass on the target of barkened bull-hide;
There's steel in the scabbard that dangles beside;
The brass shall be burnished, the steel shall flash free,
At the toss of the bonnet of Bonny Dundee.
Come fill up my cup, etc.

"Away to the hills, to the caves, to the rocks
Ere I own an usurper, I'll couch with the fox;
And tremble, false Whigs, in the midst of your glee,
You have not seen the last of my bonnet and me!"
Come fill up my cup, etc.

He waved his proud hand, the trumpets were blown,
The kettle-drums clashed and the horsemen rode on,
Till on Ravelston's cliffs and on Clermiston's lee
Died away the wild war-notes of Bonny Dundee.
Come fill up my cup, come fill up my can,
Come saddle the horses, and call up the men,
Come open your gates, and let me gae free,
For it's up with the bonnets of Bonny Dundee!

The song
There are several versions of the song and a common one is given here.

1. Tae the lairds o' convention 'twas Claverhouse spoke
Ere the King's crown go down, there are crowns tae be broke;
Now let each cavalier wha loves honour and me
Come follow the bonnets o' bonnie Dundee.

Chorus:
Come fill up my cup, come fill up my can,
Come saddle my horses and call out my men.
And it's ope' the west port and let us gae free,
And we'll follow the bonnets o' bonnie Dundee!

2. Dundee he is mounted, he rides doon the street,
The bells they ring backwards, the drums they are beat,
But the Provost, (douce man!), says; Just e'en let him be
For the toon is weel rid of that de'il Dundee.

Chorus: 

3. There are hills beyond Pentland and lands beyond Forth,
Be there lairds i' the south, there are chiefs i' the north!
And brave duine-uasals*, three thousand times three *("noble men", pron. doony wassals - Gaelic with English s plural)
Will cry "Hai!" for the bonnets o' bonnie Dundee.

Chorus:

4. We'll awa' tae the hills, tae the lea, tae the rocks
E'er I own a usurper, I'll couch wi' the fox!
So tremble, false Whigs, in the midst o' your glee,
For ye've naw seen the last o' my bonnets and me!

Chorus:

Scott's attribution of the tune
To help Jane identify the tune, Scott gave a few lines from each of three songs for which it had been used. His first quotation is from Jockey's Escape from Dundee; the second is from Scots Callan o' Bonnie Dundee (though a version of these lines also appears in Jockey's Escape); and the third is from John Gay, The Beggar's Opera (1728; Air LVII, The Charge is prepar'd).

The transcriptions of the tune for different sets of words vary both in notes and in rhythmic phrasing. The version in The Beggar's Opera differs most widely, with most of the dotted rhythms smoothed out into a regular succession of crotchets. We cannot say whether Scott had any particular variation in mind; he professed to have a good ear for time but little or none for tune. All are in a minor key, and their melancholy and their subtle rhythms will surprise anyone familiar only with the setting now best known.

This later setting, with its cheerful major key and cantering rhythm, suits both the spirit of Scott's lines and their metre, and makes an excellent cavalry march. Scott might well have approved: he intended the verses "to be sung a la militaire" and not as the song is in The Beggars Opera. In this tune, too, variations occur in different publications.

The origin of this immensely popular tune is uncertain. It makes use of the Lombard rhythm or "Scotch snap", and may owe something to Scottish folk-song. It seems first to have been used about 1850 and was associated with the contralto and composer Charlotte Dolby, later Sainton-Dolby (1821–85). The sheet music of Bonnie Dundee was published by Boosey & Sons as "sung by Miss Dolby" and (after 1860) "sung by Madame Sainton-Dolby", but Boosey credits her only with performing the song and arranging the accompaniment; no composer is named, and Boosey lists the piece as a Scotch Air. However, Bonnie Dundee has been included among Dolby's works.

It has been suggested that the melody comes from a piano piece called The Band at a Distance, and that it was Dolby who first combined this tune with Scott's words. A score for piano or harp called The Band at a Distance, by Nicolas-Charles Bochsa, was published by Walker & Son c. 1830, but has no resemblance to Bonnie Dundee.

In the Scottish Orpheus (1897), Adam Hamilton gives the song as "Composed by Dr E. F. Rimbault. Arranged by Edward Rimbault Dibdin" (p. 52). This attribution has not been confirmed. Edward Francis Rimbault (1816-1876) was a prolific writer of and about music, but his songs are not listed separately in any bibliography. His name sometimes appears as having "arranged" Bonnie Dundee.

Marches
The song is the authorized regimental march for the following Canadian regiments:
The Royal Canadian Horse Artillery (gallop past)
1st Hussars
The Brockville Rifles
The Stormont, Dundas and Glengarry Highlanders
The Loyal Edmonton Regiment (4th Battalion, Princess Patricia's Canadian Light Infantry)
The Queen's Own Cameron Highlanders of Canada (D Company)

It is used by several British cavalry regiments and the Royal Horse Artillery, in addition to being the regimental march for Tayforth Universities Officers Training Corps which is based in Dundee

Parodies and alternative versions
Scott's song was parodied by Lewis Carroll in Through the Looking-Glass and by Rudyard Kipling in The Jungle Book.

William McGonagall praised the town of Dundee in 1878.

A 1904 broadside ballad titled The Bailies of Bonnie Dundee parodied Scott's song to raise accusations of corruption by members of Dundee's burgh council.

Lewis Carroll
From Chapter IX of Through the Looking-Glass, 1871:

To the Looking-Glass world it was Alice that said
"I've a sceptre in hand, I've a crown on my head.
Let the Looking-Glass creatures, whatever they be
Come dine with the Red Queen, the White Queen and Me!"

Then fill up the glasses as quick as you can,
And sprinkle the table with buttons and bran:
Put cats in the coffee, and mice in the tea--
And welcome Queen Alice with thirty-times-three!

"O Looking-Glass creatures," quoth Alice, "draw near!
'Tis an honour to see me, a favour to hear:
'Tis a privilege high to have dinner and tea
Along with the Red Queen, the White Queen, and Me!"

Then fill up the glasses with treacle and ink,
Or anything else that is pleasant to drink:
Mix sand with the cider, and wool with the wine--
And welcome Queen Alice with ninety-times-nine!

William McGonagall
William McGonagall returned to the idea of praising the town in Bonnie Dundee in 1878. The opening lines quoted below exemplify McGonagall's inimitable style:
Oh, Bonnie Dundee! I will sing in thy praise
A few but true simple lays,
Regarding some of your beauties of the present day
And virtually speaking, there’s none can them gainsay;
There’s no other town I know of with you can compare
For spinning mills and lasses fair,
And for stately buildings there’s none can excel
The beautiful Albert Institute or the Queen’s Hotel,

Orthodoxee
In 1892 there was a protest in the Highlands of Scotland against the Free Church of Scotland's Declaratory Act, which modified the denomination's adherence to the orthodoxy of the Westminster Confession of Faith and "abandoned the whole system of thought for which it stood." Initially the protest was led by Rev. Murdoch Macaskill of Dingwall, though he did not in the end separate with the two ministers from Syke who created the Free Presbyterian Church of Scotland in 1893.

The poem 'Orthodoxee' was published in the 'Grantown Supplement' weekly newspaper, Grantown-on-Spey, on 25 June 1892.

Orthodoxee
(To the tune: 'Bonnie Dundee')

To the Highland Convention Macaskill thus spoke -
"If the Free Kirk’s not ‘sound’ there’s a kirk to be broke,
Then each sturdy supporter of orthodoxee,
Let him follow the lead of Mackenzie and me."

Chorus:
"Come wallop me, Dods, come wallop me, Bruce,
Come saddle me, Drummond, with loads of abuse;
Unloosen your tongues like Balfour and me,
Or it’s up with the prospects of orthodoxee."

"Mackenzie he is roused, he has got on his feet:
He’ll break the Free Kirk ere he’ll sound a retreat."
(But Rainy, douse man, said, "Just e’en let it be,
For the Kirk is well rid o’ their orthodoxee.")

"If the Kirk is determined, for all it is worth,
To alter its Creed, we’ll disrupt in the North,
For all the adherents of orthodoxee
Are ready to swear by Mackenzie and me."

"Then away to the hills; set the heather ablaze,
And raise such a smoke as you only can raise:
We’ll see if we can’t make these heretics be
More tenderly careful of orthodoxee."

Rudyard Kipling

From "Parade Song of the Camp Animals", which follows the story "Her Majesty's Servants", in The Jungle Book published in 1894:

By the brand on my shoulder, the finest of tunes
Is played by the Lancers, Hussars, and Dragoons,
And it's sweeter than "Stables" or "Water" to me--
The Cavalry Canter of "Bonnie Dundee"!

Then feed us and break us and handle and groom,
And give us good riders and plenty of room,
And launch us in column of squadron and see
The way of the war-horse to "Bonnie Dundee"!

American Civil War

Riding a Raid (Traditional)

During the American Civil War traditional English, Irish, and Scottish songs were often sung or modified. The Confederates did this very often. The song Riding a Raid takes place during the 1862 Antietam Campaign. J.E.B. Stuart's Confederate cavalry set off on a screening movement on the flank of Robert E. Lee's army in order to give Lee time to prepare his army to meet the Union Army after Northern general George B. McClellan had gained information on Lee's location and plans. The Campaign would culminate in the battle of Antietam, or Sharpsburg as the Confederates called it. This would be the bloodiest day in American history and while the battle was indecisive, Lee was forced to abandon any hope of continuing the campaign.

 Riding a Raid

'Tis old Stonewall the Rebel that leans on his sword,
And while we are mounting prays low to the Lord:
"Now each cavalier that loves honor and right,
Let him follow the feather of Stuart tonight."

Chorus:
Come tighten your girth and slacken your rein;
Come buckle your blanket and holster again;
Try the click of your trigger and balance your blade,
For he must ride sure that goes riding a raid.

Now gallop, now gallop to swim or to ford!
Old Stonewall, still watching, prays low to the Lord:
"Goodbye, dear old Rebel! The river's not wide,
And Maryland's lights in her window to guide."

Chorus:

There's a man in the White House with blood on his mouth!
If there's knaves in the North, there are braves in the South.
We are three thousand horses, and not one afraid;
We are three thousand sabres and not a dull blade.

Chorus:

Then gallop, then gallop by ravines and rocks!
Who would bar us the way take his toll in hard knocks;
For with these points of steel, on the line of the Penn
We have made some fine strokes -- and we'll make 'em again

Chorus:

Second Boer War

During the final phase of the Second Boer War, Afrikaner residents of Winburg taunted the local British garrison with a parody of Bonnie Dundee, which was typically sung in English. The parody celebrated the guerrilla warfare of Boer commando Christiaan De Wet.

 De Wet he is mounted, he rides up the street
 The English skedaddle an A1 retreat!
 And the commander swore: They've got through the net
 That's been spread with such care for Christiaan De Wet.

 There are hills beyond Winburg and Boers on each hill
 Sufficient to thwart ten generals' skill
 There are stout-hearted burghers 10,000 men set
 On following the Mausers of Christian De Wet.

 Then away to the hills, to the  veld, to the rocks
 Ere we own a usurper we'll crouch with the fox
 And tremble false Jingoes amidst all your glee
 Ye have not seen the last of my Mausers and me!

References

1820s in Dundee
1825 poems
1825 songs
British military marches
Jacobite songs
Poetry by Walter Scott
Scottish folk songs