-\f
-;;; Filling
-(defun octave-auto-fill ()
- "Perform auto-fill in Octave mode.
-Returns nil if no feasible place to break the line could be found, and t
-otherwise."
- (let (fc give-up)
- (if (or (null (setq fc (current-fill-column)))
- (save-excursion
- (beginning-of-line)
- (and auto-fill-inhibit-regexp
- (octave-looking-at-kw auto-fill-inhibit-regexp))))
- nil ; Can't do anything
- (if (and (not (octave-in-comment-p))
- (> (current-column) fc))
- (setq fc (- fc (+ (length octave-continuation-string) 1))))
- (while (and (not give-up) (> (current-column) fc))
- (let* ((opoint (point))
- (fpoint
- (save-excursion
- (move-to-column (+ fc 1))
- (skip-chars-backward "^ \t\n")
- ;; If we're at the beginning of the line, break after
- ;; the first word
- (if (bolp)
- (re-search-forward "[ \t]" opoint t))
- ;; If we're in a comment line, don't break after the
- ;; comment chars
- (if (save-excursion
- (skip-syntax-backward " <")
- (bolp))
- (re-search-forward "[ \t]" (line-end-position)
- 'move))
- ;; If we're not in a comment line and just ahead the
- ;; continuation string, don't break here.
- (if (and (not (octave-in-comment-p))
- (looking-at
- (concat "\\s-*"
- (regexp-quote
- octave-continuation-string)
- "\\s-*$")))
- (end-of-line))
- (skip-chars-backward " \t")
- (point))))
- (if (save-excursion
- (goto-char fpoint)
- (not (or (bolp) (eolp))))
- (let ((prev-column (current-column)))
- (if (save-excursion
- (skip-chars-backward " \t")
- (= (point) fpoint))
- (progn
- (octave-maybe-insert-continuation-string)
- (indent-new-comment-line t))
- (save-excursion
- (goto-char fpoint)
- (octave-maybe-insert-continuation-string)
- (indent-new-comment-line t)))
- (if (>= (current-column) prev-column)
- (setq give-up t)))
- (setq give-up t))))
- (not give-up))))
-