Historical memory and clerical activity in medieval Spain and Portugal