7

Since several years I've been using this snippet to insert a date into buffer:

# -*- coding: utf-8 -*-
# name: date
# key: date
# --
`(insert (format-time-string "%Y-%m-%d"))`$0

However nowadays I get this annoying warning:

Warning (yasnippet): `date' modified buffer in a backquote expression.
To hide this warning, add (yasnippet backquote-change) to `warning-suppress-types'.

This is clearly related to this question, but it is not clear what is the proper way to fix the snippet (rather then just suppress the message).

  • 1
    "the solution doesn't work" - do you mean the warning is not suppressed? It should be. – npostavs Sep 18 '16 at 16:26
  • Sorry, that was poorly worded - I've updated it (plus your answer works so thanks again!) – user673592 Sep 19 '16 at 12:17
12

You should rewrite your snippet so that the backquoted expression doesn't modify the buffer, but instead returns the string to insert:

# -*- coding: utf-8 -*-
# name: date
# key: date
# --
`(format-time-string "%Y-%m-%d")`$0

For more examples, see yasnippet truncates clipboard contents

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.