Function: center-line
center-line is an interactive and byte-compiled function defined in
text-mode.el.gz.
Signature
(center-line &optional NLINES)
Documentation
Center the line point is on, within the width specified by fill-column.
This means adjusting the indentation so that it equals
the distance between the end of the text and fill-column.
The argument NLINES says how many lines to center.
Probably introduced at or before Emacs version 23.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/text-mode.el.gz
(defun center-line (&optional nlines)
"Center the line point is on, within the width specified by `fill-column'.
This means adjusting the indentation so that it equals
the distance between the end of the text and `fill-column'.
The argument NLINES says how many lines to center."
(interactive "P")
(if nlines (setq nlines (prefix-numeric-value nlines)))
(while (not (eq nlines 0))
(save-excursion
(let ((lm (current-left-margin))
space)
(beginning-of-line)
(delete-horizontal-space)
(end-of-line)
(delete-horizontal-space)
(setq space (- fill-column lm (current-column)))
(if (> space 0)
(indent-line-to (+ lm (/ space 2))))))
(cond ((null nlines)
(setq nlines 0))
((> nlines 0)
(setq nlines (1- nlines))
(forward-line 1))
((< nlines 0)
(setq nlines (1+ nlines))
(forward-line -1)))))