Stopping fill-paragraph from breaking Stata inline dynamics tags

Stata inline dynamic tags contain spaces. E.g. <<dd_display: %9.3f abs(_b[2.rep78])>>. This means that when using fill-paragraph, the inline tag can be broken, which Stata’s dyndoc and dyntext commands will break on.

This snippet to include in your Emacs init file fixes this issue.

(defun my-in-dd-display ()
  "Don't break lines in Inline Stata Dynamic Tags."
  (save-excursion
    (save-match-data
      (and (re-search-backward ">>\\|\\(<<dd_display:\\)"
                               (line-beginning-position) t)
       (match-beginning 1)))))
(add-hook 'fill-nobreak-predicate #'my-in-dd-display)

After defining the function with defun, the add-hook function enables it’s use with fill-paragraph. This comes from https://emacs.stackexchange.com/a/78562.

Home | Back to blog

This work is licensed under CC BY-NC 4.0 Creative Commons BY-NC image