IT’S like being trapped in a heartless, loveless and controlling relationship, dreaming of escape and hoping that a good-looking and glamorous European can whisk you away to a better life. Only then you realise that the good-looking and glamorous European isn’t so good-looking and glamorous on closer inspection, and is every bit as heartless, loveless and controlling as the domineering partner in the relationship you yearn to escape from.

Now you find yourself reconsidering. That’s a brief summary of the evolution of the attitude of the Scottish independence movement towards the European Union. Because of the EU’s shameful treatment of Catalonia, Scotland’s independence movement is falling out of love with Europe.

If that’s how you treat our sister, we know that we can’t expect anything better. If we do somehow get better treatment and greater understanding than Catalonia has received from the EU, it will only be because the EU wants to use us as a stick to beat up England. Scotland’s independence movement has spent decades fighting against the insulting stereotype that everything we do is motivated by hatred for England.

We’ll only be undoing all that hard work if we base our independence campaign on being a proxy for someone else’s desire to do England down.

The EU’s attitude towards Catalan attempts to achieve independence peacefully and democratically has been hypocritical and characterised by a disrespect for the rights of Catalans – who are after all EU citizens – and a disrespect for international law. The EU has shown that it’s not a Union of nations, it’s a club of states.

The EU has made it clear that it will only deal with Madrid, and that as far as it is concerned what’s going on in Catalonia is for Madrid to deal with as it sees fit. According to a statement released by EU President Jean-Claude Juncker on October 2, what is happening in Catalonia “is an internal matter for Spain that has to be dealt with in line with the constitutional order of Spain”. However, just because something is legal doesn’t mean it’s right. Apartheid was legal. Jailing gay people was legal. Colonialism was legal.

The fact is that the right to self-determination is a principle of international law, and as such it is a greater right than Spain’s right to territorial integrity, and a greater right than anything enshrined in the constitution of any particular state. Madrid, and the EU, both argue that the Catalan referendum was illegal under Spanish law, and that’s the end of the matter.

However, if that’s the case then Spain and the EU have effectively abolished international law. It means that any state could pass a law or write a constitutional clause forbidding an independence referendum on part of its territory, and then no stateless nation anywhere would ever be able to achieve independence.

The current borders of states would be pickled in aspic forever. It requires the international community to enforce international law, and as one of the world’s most powerful and influential transnational organisations, by denying the right of Catalonia to self-determination the EU has betrayed us all, not just the Catalans. As Carles Puigdemont said on Monday in a statement from exile in Brussels, “This is not just about Catalonia. This is about democracy itself.”

This takes us into the thorny question of nationhood. Spain insists that the Catalans do not constitute a nation. In fact one of the sparks for the push towards independence in Catalonia was the Spanish Supreme Court striking down Catalonia’s statute of autonomy in 2010 because, amongst other things, it stated that Catalonia was a nation. The statute had been approved by a large majority in a referendum in Catalonia and passed by the Spanish Parliament. However the Court ruled that under Spanish law, Catalonia was not a nation and could never be recognised as such.

I lived in Spain at the time. I had numerous disagreements with Spanish friends and colleagues, some of whom were supporters of the Partido Popular (the party of Mariano Rajoy, the current Spanish Prime Minister). All of them supported Scotland’s right to self-determination. All of them agreed that Scotland was a nation, because Scotland had a long history as an independent state and then voluntarily, or at least sort of voluntarily, entered into a union with the Kingdom of England.

None of them, not even the most fervent right wing supporter of the Partido Popular, had the slightest problem with the idea of Scottish independence, which is one of the reasons I was always confident that Spain would not block Scottish accession to the EU.

But they denied that Catalonia was a nation. Catalonia has never been an independent state, they said. Catalonia was only ever one of the constituent territories of the Kingdom of Aragon before that kingdom united with Castille to form Spain in 1492. So, they claimed, Catalonia isn’t a nation, and that means Catalonia has no right to self-determination.

It’s a peculiar argument, that nationhood depends upon prior statehood, but it’s an argument that’s widespread and commonplace amongst those who oppose Catalan independence. In the history of the world it’s generally been the other way about. A population which is culturally or linguistically distinctive comes to feel that it’s a nation, and then they agitate for independence and create a state. However the real point here is that it’s not for external parties to inform other people what their identity really is.

The key part of self-determination is the self part of it. It’s not for Greece to tell Macedonia that there’s no such thing as a Macedonian nation. It’s not for Turkey to tell the Kurds that there’s no such thing as a Kurdish nation. And it’s not for Spain to tell Catalonia that there’s no such thing as a Catalan nation. People know for themselves what nation they belong to and to be told otherwise is as insulting as it is for supporters of Scottish independence to be told that the only reason we want independence is because we supposedly hate the English.

In turning a blind eye to Catalonia, in being silent as its leaders are imprisoned, in refusing to condemn the violence of the Spanish state on the day of the Catalan referendum, the EU has shown itself to be a union of elites, a union of the powerful and of existing state structures. It’s not a Union of European peoples. The EU has effectively agreed with Spain that there’s no such thing as a Catalan nation and is not respecting the right of Catalans to define themselves.

As Scotland is dragged into a disastrous Brexit by right-wing British nationalist ideologues, for Scotland’s independence movement the lesson from Catalonia is that we need to rethink our attitude to the EU.