Yasnippet:如何扩展“或"但不在“-or”上。 [英] Yasnippet: How to expand on " or" but not on "-or"

查看:118
本文介绍了Yasnippet:如何扩展“或"但不在“-or”上。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题表示,是否可以改变yasnippets行为,以便不可能在-or上展开,但是可以在[newline]或[tab]或only?



我想这样做,是因为我可以在扩展时自动扩展我的yasnippets,而且当我编写变量名时,也只会有冲突。

解决方案

我在这里找到解决方案:
http://ergoemacs.org/emacs/emacs_tip_yasnippet_expand_whole_hyphenated_word.html



有变量(defvar yas-key-syntaxes(listww_w_。w _。()^)..),它控制各种扩展。 w表示或被扩展为单独的或。



如果

 (setq yas-key-syntaxes'(w_w_。w _。()^))

然后 - 或 < some> -or但是通常被扩展。



所以,buffer-substring 只有在文件 buffer-substring.yasnippet 与内容

 #贡献者:Xah Lee(XahLee.org)
#名称:buffer-substring
#key:buffer-substring
# -
(缓冲区子串START $ 0 END)

但是与w code>关键字buffer-substring将被扩展为 substring.yasnippet



如果文件中有额外的字符串#key:bs buffer-substring.yasnippet then buffer-substring根本不会被扩展。 (For Version:0.8.0)


Title says it, is it possible to alter yasnippets behavior so that it is not possible to expand on "-or" but it is possible to expand on "[newline]or" or "[tab]or" only?

I would like this because I am trying to expand my yasnippets automatically when expansion is possible, and there is only ever confliction when I am writing variable names.

解决方案

I got the solution here: http://ergoemacs.org/emacs/emacs_tip_yasnippet_expand_whole_hyphenated_word.html

There is variable (defvar yas-key-syntaxes (list "w" "w_" "w_." "w_.()" "^ ")..), which controls kinds of expansions. "w" means that `"-or" is expanded as separate "or".

If

(setq yas-key-syntaxes '("w_" "w_." "w_.()" "^ "))

then "-or" is expanded as complex expression "<some>-or" only. But " or" is expanded as usually.

So, "buffer-substring" will be expanded only if there is file buffer-substring.yasnippet with content

# contributor: Xah Lee (XahLee.org)
# name: buffer-substring
# key: buffer-substring
# --
(buffer-substring START$0 END)

But with "w" keyword "buffer-substring" will be expanded as substring.yasnippet.

If there is additional string # key: bs in file buffer-substring.yasnippet then "buffer-substring" won't be expanded at all. (For Version: 0.8.0)

这篇关于Yasnippet:如何扩展“或&QUOT;但不在“-or”上。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆