Yasnippet:如何扩展“或"但不在“-or”上。 [英] Yasnippet: How to expand on " or" but not on "-or"
问题描述
我想这样做,是因为我可以在扩展时自动扩展我的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:如何扩展“或"但不在“-or”上。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!