2

Emacs では、|...| 内で改行を避けるにはどうすればよいですか? MQ (fill-paragraph) を使用する場合は?

https://groups.google.com/forum/?fromgroups#!searchin/gnu.emacs.help/fill-nobreak-predicate/gnu.emacs.help/qNuZZjQnsww/99oJ1fb4OSUJで[[.. .]] ですが、開始区切り文字と終了区切り文字が同じ場合は機能しません。

(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)
4

1 に答える 1

2

これはトリックを行うようです:

(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)
于 2012-12-17T17:14:00.530 に答える