2

I want yasnippet to expand both "Cp" and "cp" into the same, say, "\citep{}".

How can this be done? Is there a way to make yasnippet case insensitive? As a quick-and-dirty solution, I tried creating yasnippet description files for both "cp" and "Cp", but only one of them is being recognized. Any ideas?

2
  • 'I tried creating yasnippet description files for both "cp" and "Cp"' - Did you give them different #name:s?
    – npostavs
    Commented Nov 25, 2015 at 1:17
  • Yes, you are right. If the #name: field is different (e.g., citep and Citep), it works. It is a quite a bit of a hassle, though, to do this manually for a large number of snippets. It would be nice if case insensitivity could be configured. Commented Nov 25, 2015 at 3:51

1 Answer 1

1

You can use the following advice:

(defun yas--downcase-key (args) ; args = (table key)
  (cl-callf downcase (nth 1 args))
  args)
(advice-add 'yas--fetch :filter-args #'yas--downcase-key)

But there should probably be some kind of yasnippet option for this.

2
  • Yes, I agree that it would be nice if this was an option that could be configured globally as well as in a per snippet basis. Commented Nov 30, 2015 at 2:04
  • @scaramouche: per-snippet would be more difficult. Opened an issue to track this: github.com/capitaomorte/yasnippet/issues/635
    – npostavs
    Commented Dec 3, 2015 at 1:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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