The following appears in the West Calder Kirk Session minutes on 1 September 1678 :
A communication from the Privy Council being read for a voluntary contribution for the relief of Robert Williamson skipper in Montross [Montrose] and the rest of his company captives with the Turks in Algiers, the Session ordains a collection to be made through the several houses of the Parish & intimation publickly to be made before the collection thereof.
England had sought relief from pirate attacks through a series of attacks and gunboat diplomacy in previous years. In 1675 Sir John Narborough, commanding a Royal Navy squadron, had negotiated a treaty with Tunis, and also - following a bombardment - with Tripoli, in modern-day Libya. The next year, peace followed with the Republic of Salé (opposite Rabat in Morocco). A peace deal had been negotiated with Algiers in 1671, but this was broken in 1677 and a large number of ships from Britain were captured by corsairs operating out of Algiers. Janeway  lists over 80 ships captured by Algiers corsairs in 1677-1679.
Evidently the men appointed to raise a collection for Robert Williamson were not particularly assiduous in carrying out their task, as seven weeks later we again read in the session minutes :
October 22 1678
The Session desires those that were named to gather the collection for the Prisoners with the Turks to go about it with all diligence.
December 8 1678
The Session appoints Mr James Brown to deliver to John Knox in Borrowstounness [Bo'ness] Factor constitute for receiving the Voluntary Contribution for Robert Williamson skipper in Montross & his company Captives with the Turks, that sum which was collected for them in this Parish, being £24-00-00.
 By Workshop of Willem van de Velde the Younger - Christie's, LotFinder: entry 5080190, Public Domain, https://commons.wikimedia.org/w/index.php?curid=18420790
 Kirk Session of West Calder, Minutes, September 1 1678, CH2/366/1, Records of Church of Scotland Synods, Presbyteries and Kirk Sessions, National Records of Scotland, Edinburgh
 A list of ships taken since July, 1677 from his Majesties subjects, by the corsairs of Algier. With their names, masters names, and places to which they belong'd, and time of taking : with a modest estimate of the loss. London: Printed for Richard Janeway, 1682.
 Kirk Session of West Calder, Minutes, October 22 1678, CH2/366/1, Records of Church of Scotland Synods, Presbyteries and Kirk Sessions, National Records of Scotland, Edinburgh
 Kirk Session of West Calder, Minutes, December 8 1678, CH2/366/1, Records of Church of Scotland Synods, Presbyteries and Kirk Sessions, National Records of Scotland, Edinburgh