Function: idlwave-auto-fill
idlwave-auto-fill is a byte-compiled function defined in
idlwave.el.gz.
Signature
(idlwave-auto-fill)
Documentation
Called to break lines in auto fill mode.
Only fills non-comment lines if idlwave-fill-comment-line-only is
non-nil. Places a continuation character at the end of the line if
not in a comment. Splits strings with IDL concatenation operator +
if idlwave-auto-fill-split-string is non-nil.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/idlwave.el.gz
(defun idlwave-auto-fill ()
"Called to break lines in auto fill mode.
Only fills non-comment lines if `idlwave-fill-comment-line-only' is
non-nil. Places a continuation character at the end of the line if
not in a comment. Splits strings with IDL concatenation operator `+'
if `idlwave-auto-fill-split-string' is non-nil."
(if (<= (current-column) fill-column)
nil ; do not to fill
(if (or (not idlwave-fill-comment-line-only)
(save-excursion
;; Check for comment line
(beginning-of-line)
(looking-at idlwave-comment-line-start-skip)))
(let (beg)
(idlwave-indent-line)
;; Prevent actions do-auto-fill which calls indent-line-function.
(let (idlwave-do-actions
(paragraph-separate ".")
(fill-nobreak-predicate
(if (and (idlwave-in-quote)
idlwave-auto-fill-split-string)
(lambda () ;; We'll need 5 spaces for " ' + $"
(<= (- fill-column (current-column)) 5)
))))
(do-auto-fill))
(save-excursion
(end-of-line 0)
;; Indent the split line
(idlwave-indent-line))
(if (save-excursion
(beginning-of-line)
(looking-at idlwave-comment-line-start-skip))
;; A continued line comment
;; We treat continued line comments as part of a comment
;; paragraph. So we check for a hanging indent.
(if idlwave-hanging-indent
(let ((here (- (point-max) (point)))
(indent
(save-excursion
(forward-line -1)
(idlwave-calc-hanging-indent))))
(when indent
;; Remove whitespace between comment delimiter and
;; text, insert spaces for appropriate indentation.
(beginning-of-line)
(re-search-forward comment-start-skip (line-end-position) t)
(delete-horizontal-space)
(idlwave-indent-to indent)
(goto-char (- (point-max) here)))))
;; Split code or comment?
(if (save-excursion
(end-of-line 0)
(idlwave-in-comment))
;; Splitting a non-full-line comment.
;; Insert the comment delimiter from split line
(progn
(save-excursion
(beginning-of-line)
(skip-chars-forward " \t")
;; Insert blank to keep off beginning of line
(insert " "
(save-excursion
(forward-line -1)
(buffer-substring (idlwave-goto-comment)
(progn
(skip-chars-forward "; ")
(point))))))
(idlwave-indent-line))
;; Split code line - add continuation character
(save-excursion
(end-of-line 0)
;; Check to see if we split a string
(if (and (setq beg (idlwave-in-quote))
idlwave-auto-fill-split-string)
;; Split the string and concatenate.
;; The first extra space is for the space
;; the line was split. That space was removed.
(insert " " (char-after beg) " +"))
(insert " $"))
(if beg
(if idlwave-auto-fill-split-string
;; Make the second part of continued string
(save-excursion
(beginning-of-line)
(skip-chars-forward " \t")
(insert (char-after beg)))
;; Warning
(beep)
(message "Warning: continuation inside a string.")))
;; Although do-auto-fill (via indent-new-comment-line) calls
;; idlwave-indent-line for the new line, re-indent again
;; because of the addition of the continuation character.
(idlwave-indent-line))
)))))