yasnippet展开会追加换行(newline)

# -*- mode: snippet -*-
# name: overline
# key: oln
# group: Math – Accents
# condition: (texmathp)
# --
\overline{$0}

这个snippet, 展开后就会追加\n. 就像这样:

image

文档是这么说的:

If there is a newline at the end of a snippet definition file, YASnippet will add a newline when expanding that snippet. When editing or saving a snippet file, please be careful not to accidentally add a terminal newline.

Note that some editors will automatically add a newline for you. In Emacs, if you set require-final-newline to t , it will add the final newline automatically.

但是我的snippet中并没有newline.

这个snippet是从这里下载的.

我其它snippet就没这个问题, 从这里下载的就都有这个问题.

感叹一下, 要是emacs能用ultisnips就好了, ultisnips是我最想念的vim插件, 暂时没有之一.

确定没有换行符吗?用 M-x hexl-mode 确定看下末尾是否有 0a

应该检查一下这个变量:require-final-newline 看一下是不是它在作怪。

还是那句话:

$ [PROXY] emacsq.sh -P yasnippet --eval "
  (progn
    (defun yas-texmathp () (require 'texmathp) (texmathp))
    (with-temp-buffer
      (emacs-lisp-mode)
      (url-insert-file-contents
       \"http://git.savannah.gnu.org/cgit/auctex.git/plain/texmathp.el\")
      (eval-buffer))
    (switch-to-buffer \"oln.snippet\")
    (progn
      (url-insert-file-contents
       \"https://raw.githubusercontent.com/saf-dmitry/latex-math-input/ac1689f3376ff76e44e5bb6c7959c51b52feeb74/yasnippets/latex-mode/mm-accents/mm-accent-overline\")

      (require 'cl-lib)
      (cl-letf (((symbol-function 'yas--compute-major-mode-and-parents)
                 (lambda (_)
                   '(latex-mode))))
        (yas-tryout-snippet)
        (whitespace-mode))))
  "