如何避免| ... |中的换行符在Emacs [英] How to avoid line breaks within |...| in Emacs

查看:156
本文介绍了如何避免| ... |中的换行符在Emacs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Emacs中,如何避免| ... |中的换行符当使用Mq(fill-paragraph)?

In Emacs, how can I avoid line breaks within |...| when using M-q (fill-paragraph)?

我找到了[[...]]的以下解决方案,但是当打开和关闭分隔符相同时,它不起作用: / p>

In https://groups.google.com/forum/?fromgroups#!searchin/gnu.emacs.help/fill-nobreak-predicate/gnu.emacs.help/qNuZZjQnsww/99oJ1fb4OSUJ I found the following solution for [[...]], but it doesn't work when the open and close delimiters are the same:

(defun fill-open-link-nobreak-p ()
  "Don't break a line after an unclosed \"[[link \"."
  (save-excursion
    (skip-chars-backward " ")
    (let ((opoint (point))
          spoint inside)
      (save-excursion
        (beginning-of-line)
        (setq spoint (point)))
       (when (re-search-backward "\\[\\[" spoint t)
        ;; (message "found") (sit-for 2)
        (unless (re-search-forward "\\]\\]" opoint t)
          (setq inside t)))
      inside)))

(add-to-list 'fill-nobreak-predicate 'fill-open-link-nobreak-p)


推荐答案

(defun odd-number-of-pipes-this-paragraph-so-far ()
  (oddp (how-many "|" (save-excursion (backward-paragraph) (point)) (point))))

(add-to-list 'fill-nobreak-predicate 'odd-number-of-pipes-this-paragraph-so-far)

这篇关于如何避免| ... |中的换行符在Emacs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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