2
votes

I use the following C-ish indentation/bracing style when writing LaTeX code:

\foo{
  blah blah... this line is getting too long and should be wrapped
}

whenever I need to re-wrap (technically, refill) a block/paragraph, according to fill-column option (50 in this example), I hit M-q. That also changes the braces' position:

\foo{ blah blah blah... this line is getting too
  long and should be wrapped }

which hurts my eyes :-( Indeed I'd like to keep the braces in their original position, namely:

\foo{ 
  blah blah blah... this line is getting too
  long and should be wrapped 
}

I guess I should add a custom fill-nobreak-predicate hook for AUCTeX, or customize paragraph-start and paragraph-separate, but I'm not that skilled with emacs lisp...

Since this question might apply to any markup-text-mode, fill free to move it upstream.

2

2 Answers

2
votes

Actually, no fill-nobreak-predicate is (as the name implies) to avoid breaking the line at some places, whereas you want to force break the line at some places. You'll probably be better served by paragraph-separate: declare the a line that only contains } or only \cmd{ should not be considered as part of a paragraph.

0
votes

With @Stefan suggestion., I come up with this, Seems working well, for simple tests,

(add-hook 'LaTeX-mode-hook
          '(lambda ()
            (setq paragraph-separate (concat " *}\\|^ *\\\\[a-zA-Z]* ?{\\|"
                                              paragraph-separate))))