emacs + latex + yasnippet:为什么在代码段之后插入换行符? [英] emacs + latex + yasnippet: Why are newlines inserted after a snippet?

查看:160
本文介绍了emacs + latex + yasnippet:为什么在代码段之后插入换行符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我在.tex文件中插入一个代码片段(带有yasnippet)时,我会在代码段之后获得一个换行符。这对于通常用于文本样式的小片段来说是非常烦人的。我该如何避免?

Everytime I insert a snippet (with yasnippet) in a .tex document, I obtain a newline after the snippet. This is quite annoying for small snippets that are typically used in text style. How can I avoid that?

我读了一些有关问题的信息(http://code.google.com/p/yasnippet/issues/detail?id=115或 http://yasnippet.googlecode.com/svn/trunk/doc/faq.html )但找不到解决方案。重现它如下(我在Mac OS X 10.6.8与yasnippet版本0.6.1c使用Aquamacs 2.3a):

I read a bit about the problem (http://code.google.com/p/yasnippet/issues/detail?id=115 or http://yasnippet.googlecode.com/svn/trunk/doc/faq.html) but couldn't find a solution. Reproduce it as follows (I work with Aquamacs 2.3a on Mac OS X 10.6.8 with yasnippet version 0.6.1c):


  1. 定义〜/ Library / Preferences / Aquamacs Emacs / Preferences.el为:
    (require'yasnippet)
    (yas / initialize)
    (yas / load-directory〜/ Library /首选项/ Aquamacs Emacs / plugins / yasnippet-0.6.1c / snippets)

  1. Define ~/Library/Preferences/Aquamacs Emacs/Preferences.el to be: (require 'yasnippet) (yas/initialize) (yas/load-directory "~/Library/Preferences/Aquamacs Emacs/plugins/yasnippet-0.6.1c/snippets")

定义以下代码段(称为bm.yasnippet[bm = boldmath ];星号*表示游标结束的位置 - 请注意,片段后面没有换行符)

define the following snippet (call it "bm.yasnippet" [bm = boldmath]; the star * symbolizes where the cursor ends -- note that there is no newline after the snippet)

# name: \bm{}{}
# key: bm
# --
\bm{$1}*


  • 重新启动Aquamacs并打开一个.tex文件并输入bm + 选项卡 [这应该插入片段]

  • restart Aquamacs and open a .tex file and type in bm + Tab [this should insert the snippet]

    片段后添加换行符。这是非常不方便的,因为 \bm {foo} 通常用于文本样式,例如在矢量 \bm {x} 不是空向量。一个典型的原因是该片段以换行符结束,然后插入。但是,即使代码片段不能以换行符结尾,我也明确获得此行为。

    A newline is added after the snippet. This is quite inconvenient since \bm{foo} is typically used in text style, so for example in "The vector \bm{x} is not the null vector". A typical cause of this is that the snippet ends with a newline which is then inserted, too. However, I specifically obtain this behavior even the snippet does not end with a newline.


    推荐答案

    我不能用纯粹的Emacs来重新命名。事实上,我有这个确切的问题,但我的问题是我有 require-final-newline 设置为 t 。所以Emacs在我的模板的最后添加一个换行符。

    I can't repro it with plain Emacs. In fact, I had this exact issue, but my problem is I had require-final-newline set to t. So Emacs was adding a newline at the end of my template.

    我的设置有点复杂,但是解决方案可能是设置 mode-require-final-newline to nil并重新启动Emacs。

    My setup is a little more complicated but the solution for you is probably to set mode-require-final-newline to nil and restart Emacs.

    为了验证这是问题,打开模板并检查最后的换行。

    To verify this is the problem, open up the template and check for the final newline.

    这篇关于emacs + latex + yasnippet:为什么在代码段之后插入换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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