We already have 'SET LOCAL', which manages scope to the current transaction. How about SET BLOCK which would set until you've left the current statement block?
This is reason why PRAGMA was designed - it can works on function, block, or statement level. But only in block based PL languages.