Reputation: 3501
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:
php-complete-function
,
succeeds, or fails silently.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?
Upvotes: 2
Views: 109
Reputation: 28531
You could try something like (guaranteed 100% untested):
(defvar my-inhibit-messages nil)
(defadvice message (around my-inhibit activate)
(unless my-inhibit-messages ad-do-it))
(defadvice php-complete-function (around my-silence-php-messages activate)
(let ((my-inhibit-messages t))
ad-do-it))
Upvotes: 0
Reputation: 59811
You can turn of logging in any expression by setting message-log-max
to nil
.
(defadvice yas--fallback (before try-php-expand (&optional arg from-trigger-key-p) activate)
(when (string-equal mode-name "PHP")
(let (message-log-max)
(php-complete-function))))
Upvotes: 0