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?

  • 'I tried creating yasnippet description files for both "cp" and "Cp"' - Did you give them different #name:s?
    – npostavs
    Nov 25 '15 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. Nov 25 '15 at 3:51

You can use the following advice:

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

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

  • 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. Nov 30 '15 at 2:04
  • @scaramouche: per-snippet would be more difficult. Opened an issue to track this: github.com/capitaomorte/yasnippet/issues/635
    – npostavs
    Dec 3 '15 at 1:29

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.