Detect current command name more reliably

Build a pattern to match existing commands defined for this buffer
rather than any user-defined command.