Function: LaTeX-fill-move-to-break-point
LaTeX-fill-move-to-break-point is a byte-compiled function defined in
latex.el.
Signature
(LaTeX-fill-move-to-break-point LINEBEG)
Documentation
Move to the position where the line should be broken.
See fill-move-to-break-point for the meaning of LINEBEG.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/latex.el
(defun LaTeX-fill-move-to-break-point (linebeg)
"Move to the position where the line should be broken.
See `fill-move-to-break-point' for the meaning of LINEBEG."
(fill-move-to-break-point linebeg)
;; Prevent line break between 2-byte char and 1-byte char.
(when (and (or (and (not (looking-at LaTeX-nospace-between-char-regexp))
(TeX-looking-at-backward
LaTeX-nospace-between-char-regexp 1))
(and (not (TeX-looking-at-backward
LaTeX-nospace-between-char-regexp 1))
(looking-at LaTeX-nospace-between-char-regexp)))
(re-search-backward
(concat LaTeX-nospace-between-char-regexp
LaTeX-nospace-between-char-regexp
LaTeX-nospace-between-char-regexp
"\\|"
".\\ca\\s +\\ca") linebeg t))
(if (looking-at "..\\c>")
(forward-char 1)
(forward-char 2)))
;; Cater for Japanese Macro
(when (and (boundp 'japanese-TeX-mode) japanese-TeX-mode
(aref (char-category-set (char-after)) ?j)
(TeX-looking-at-backward (concat (regexp-quote TeX-esc) TeX-token-char "*")
(1- (- (point) linebeg)))
(not (TeX-escaped-p (match-beginning 0))))
(goto-char (match-beginning 0)))
(when LaTeX-fill-break-at-separators
(let ((orig-breakpoint (point))
(final-breakpoint (point))
start-point)
(save-excursion
(beginning-of-line)
(LaTeX-back-to-indentation 'outer)
(setq start-point (point))
;; Find occurences of [, $, {, }, \(, \), \[, \] or $$.
(while (and (= final-breakpoint orig-breakpoint)
(TeX-re-search-forward-unescaped
(concat "[[{}]\\|\\$\\$?\\|"
(regexp-quote TeX-esc) "[][()]")
orig-breakpoint t))
(let ((match-string (match-string 0)))
(cond
;; [ (opening bracket) (The closing bracket should
;; already be handled implicitely by the code for the
;; opening brace.)
((save-excursion
(and (memq '\[ LaTeX-fill-break-at-separators)
(string= match-string "[")
(TeX-re-search-forward-unescaped (concat "\\][ \t]*{")
(line-end-position) t)
(> (- (or (TeX-find-closing-brace)
(line-end-position))
(line-beginning-position))
fill-column)))
(save-excursion
(skip-chars-backward "^ \n")
(when (> (point) start-point)
(setq final-breakpoint (point)))))
;; { (opening brace)
((save-excursion
(and (memq '\{ LaTeX-fill-break-at-separators)
(string= match-string "{")
(> (- (save-excursion
;; `TeX-find-closing-brace' is not enough
;; if there is no breakpoint in form of
;; whitespace after the brace.
(goto-char (or (TeX-find-closing-brace)
(line-end-position)))
(skip-chars-forward "^ \t\n")
(point))
(line-beginning-position))
fill-column)))
(save-excursion
(skip-chars-backward "^ \n")
;; The following is a primitive and error-prone method
;; to cope with point probably being inside square
;; brackets. A better way would be to use functions
;; to determine if point is inside an optional
;; argument and to jump to the start and end brackets.
(when (save-excursion
(TeX-re-search-forward-unescaped
(concat "\\][ \t]*{") orig-breakpoint t))
(TeX-search-backward-unescaped "["
(line-beginning-position) t)
(skip-chars-backward "^ \n"))
(when (> (point) start-point)
(setq final-breakpoint (point)))))
;; } (closing brace)
((save-excursion
(and (memq '\} LaTeX-fill-break-at-separators)
(string= match-string "}")
(save-excursion
(backward-char 2)
(not (TeX-find-opening-brace
nil (line-beginning-position))))))
(save-excursion
(skip-chars-forward "^ \n")
(when (> (point) start-point)
(setq final-breakpoint (point)))))
;; $ or \( or \[ or $$ (opening math)
((save-excursion
(and (or (and (memq '\\\( LaTeX-fill-break-at-separators)
(or (and (string= match-string "$")
(texmathp))
(string= match-string "\\(")))
(and (memq '\\\[ LaTeX-fill-break-at-separators)
(or (string= match-string "\\[")
(and (string= match-string "$$")
(texmathp)))))
(> (- (save-excursion
(TeX-search-forward-unescaped
(cond ((string= match-string "\\(")
(concat TeX-esc ")"))
((string= match-string "$") "$")
((string= match-string "$$") "$$")
(t (concat TeX-esc "]")))
(point-max) t)
(skip-chars-forward "^ \n")
(point))
(line-beginning-position))
fill-column)))
(save-excursion
(skip-chars-backward "^ \n")
(when (> (point) start-point)
(setq final-breakpoint (point)))))
;; $ or \) or \] or $$ (closing math)
((save-excursion
(and (or (and (memq '\\\) LaTeX-fill-break-at-separators)
(or (and (string= match-string "$")
(not (texmathp)))
(string= match-string "\\)")))
(and (memq '\\\] LaTeX-fill-break-at-separators)
(or (string= match-string "\\]")
(and (string= match-string "$$")
(not (texmathp))))))
(if (member match-string '("$" "$$"))
(save-excursion
(skip-chars-backward "$")
(TeX-search-backward-unescaped
match-string (line-beginning-position) t))
(texmathp-match-switch (line-beginning-position)))))
(save-excursion
(skip-chars-forward "^ \n")
(when (> (point) start-point)
(setq final-breakpoint (point)))))))))
(goto-char final-breakpoint))))