Generalised type of 'autoBrackets' function.