summaryrefslogtreecommitdiff
path: root/lisp/textmodes
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1995-09-10 17:44:25 +0000
committerRichard M. Stallman <rms@gnu.org>1995-09-10 17:44:25 +0000
commit9cbeab4b15d1a4ec48a1a93037df3650cc29279f (patch)
treeae1feef85ccdada4f455291bef641efb91428896 /lisp/textmodes
parent5b40dddab3d76cd1acc2f8ea6f0db11528eb5842 (diff)
downloademacs-9cbeab4b15d1a4ec48a1a93037df3650cc29279f.tar.gz
(center-line): New arg NLINES.
Do nothing for lines that are too wide.
Diffstat (limited to 'lisp/textmodes')
-rw-r--r--lisp/textmodes/text-mode.el38
1 files changed, 25 insertions, 13 deletions
diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el
index aa4e2fc9790..2dd825187ce 100644
--- a/lisp/textmodes/text-mode.el
+++ b/lisp/textmodes/text-mode.el
@@ -141,20 +141,32 @@ See `center-line' for more info."
(center-line))
(forward-line 1)))))
-(defun center-line ()
+(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'."
- (interactive)
- (save-excursion
- (let ((lm (current-left-margin))
- line-length)
- (beginning-of-line)
- (delete-horizontal-space)
- (end-of-line)
- (delete-horizontal-space)
- (setq line-length (current-column))
- (indent-line-to
- (+ lm (/ (- fill-column lm line-length) 2))))))
+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))
+ line-length)
+ (beginning-of-line)
+ (delete-horizontal-space)
+ (end-of-line)
+ (delete-horizontal-space)
+ (setq line-length (current-column))
+ (if (> (- fill-column lm line-length) 0)
+ (indent-line-to
+ (+ lm (/ (- fill-column lm line-length) 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)))))
;;; text-mode.el ends here