I use TAB to expand snippets from yasnippet, when it doesn't expand a snippet, it usually falls back to indenting (the default command bound to TAB), this is referred to by yasnippets custom variable yas-fallback-behavior
which can only be call-other-command
or return-nil
.
The desired functionality I want is upon hitting TAB:
- Tries to complete snippet, succeeds, or fails silently.
- Checks if we're in PHP mode, and calls
php-complete-function
, succeeds, or fails silently. - Defaults to it's current indentation command
(
indent-for-tab-command
).
It currently performs 1, then 3, perfectly. I was however, able to make it work for the most part by advising yas--fallback
with this bit of code:
(defadvice yas--fallback (before try-php-expand (&optional arg from-trigger-key-p) activate)
(when (string-equal mode-name "PHP")
(php-complete-function)))
The only main issue that remains is that when trying to indent anything using TAB, php-complete-function
does not fail silently, but instead spams the minibuffer with messages from it's multiple checks for a PHP completion.
So is there a way to disallow messaging from that function in this case, without doing all the same checks it does essentially re-programming the function in my advise? Alternatively, is there a better way to do this with yasnippet to begin with that I'm missing?