Arr Sat Madrid. Mon Night train to Lisbon arriving Tue. Fri fly to Barcelona area. Tue train to Valencia. Thur train to Madrid. Fri fly home. I will be missing Gibralter/Tangier.
Is this a question? Even if it isn't, I assume you realize that going from Lisbon to Barcelona you will be flying all the way back across Spain. An open-jaw itinerary such as Arr Lisbon, train to Madrid, train to Valencia, train to Barcelona for flight home, or the reverse would seem to be more efficient than the figure-8 you describe.