;;; -*-Scheme-*-
;;;
-;;; $Id: basic.scm,v 1.137 2000/02/29 01:34:38 cph Exp $
+;;; $Id: basic.scm,v 1.138 2000/06/02 00:43:25 cph Exp $
;;;
;;; Copyright (c) 1986, 1989-2000 Massachusetts Institute of Technology
;;;
(char=? #\newline char))
(current-minor-mode? (ref-mode-object auto-fill)))
(let ((t (group-modified-tick (mark-group point))))
- (auto-fill-break)
+ (auto-fill-break (current-point))
(if (not (fix:= t (group-modified-tick (mark-group point))))
(set! hairy? #t))))
hairy?)))
(current-column))))
(set-variable! comment-column column)
(message "comment-column set to " column)))))
-\f
+
(define-command indent-for-comment
"Indent this line's comment to comment column, or insert an empty comment."
()
(begin
(insert-string (ref-variable comment-start))
(insert-comment-end)))))))))
-
+\f
(define-variable comment-multi-line
"True means \\[indent-new-comment-line] should continue same comment
on new line, with no new terminator or starter."
"Break line at point and indent, continuing comment if presently within one."
()
(lambda ()
- (delete-horizontal-space)
- (insert-newlines 1)
+ (indent-new-comment-line (current-point) (ref-variable fill-prefix))))
+
+(define (indent-new-comment-line mark fill-prefix)
+ (let ((mark (mark-left-inserting-copy mark)))
+ (delete-horizontal-space mark)
+ (insert-newlines 1 mark)
(let ((if-not-in-comment
(lambda ()
- (if (ref-variable fill-prefix)
- (insert-string (ref-variable fill-prefix))
- ((ref-command indent-according-to-mode))))))
- (if (ref-variable comment-locator-hook)
- (let ((com ((ref-variable comment-locator-hook)
- (line-start (current-point) -1))))
+ (if fill-prefix
+ (insert-string fill-prefix mark)
+ (with-selected-buffer (mark-buffer mark)
+ (lambda ()
+ (with-current-point mark
+ (ref-command indent-according-to-mode))))))))
+ (if (ref-variable comment-locator-hook mark)
+ (let ((com ((ref-variable comment-locator-hook mark)
+ (line-start mark -1))))
(if com
(let ((start-column (mark-column (car com)))
(end-column (mark-column (cdr com)))
(comment-start (extract-string (car com) (cdr com))))
- (if (ref-variable comment-multi-line)
- (maybe-change-column end-column)
- (begin (insert-string (ref-variable comment-end)
- (line-end (current-point) -1))
- (maybe-change-column start-column)
- (insert-string comment-start)))
- (if (line-end? (current-point))
- (insert-comment-end)))
+ (if (ref-variable comment-multi-line mark)
+ (maybe-change-column end-column mark)
+ (begin
+ (insert-string (ref-variable comment-end mark)
+ (line-end mark -1))
+ (maybe-change-column start-column mark)
+ (insert-string comment-start mark)))
+ (if (line-end? mark)
+ (insert-comment-end mark)))
(if-not-in-comment)))
- (if-not-in-comment)))))
+ (if-not-in-comment)))
+ (mark-temporary! mark)))
(define (insert-comment-end)
(let ((point (mark-right-inserting (current-point))))
;;; -*-Scheme-*-
;;;
-;;; $Id: fill.scm,v 1.63 2000/03/02 05:37:06 cph Exp $
+;;; $Id: fill.scm,v 1.64 2000/06/02 00:42:32 cph Exp $
;;;
;;; Copyright (c) 1986, 1989-2000 Massachusetts Institute of Technology
;;;
(ref-variable fill-prefix start)
(ref-variable fill-column start)
justify?))))
-
+\f
(define-command justify-current-line
"Add spaces to line point is in, so it ends at fill-column."
"d"
(lambda (point)
(justify-line point
- (mark-local-ref point (ref-variable-object fill-prefix))
- (mark-local-ref point (ref-variable-object fill-column)))))
+ (ref-variable fill-prefix point)
+ (ref-variable fill-column point))))
+
+(define-command center-line
+ "Center the line point is on, within the width specified by `fill-column'.
+This means adjusting the indentation to match
+the distance between the end of the text and `fill-column'."
+ "d"
+ (lambda (mark) (center-line mark)))
+
+(define (center-line mark)
+ (let ((mark (mark-permanent! mark)))
+ (delete-horizontal-space (line-start mark 0))
+ (delete-horizontal-space (line-end mark 0))
+ (let ((d
+ (- (- (ref-variable fill-column mark)
+ (ref-variable left-margin mark))
+ (mark-column (line-end mark 0)))))
+ (if (positive? d)
+ (insert-horizontal-space (+ (ref-variable left-margin mark)
+ (quotient d 2))
+ (line-start mark 0))))))
\f
(define (fill-region-as-paragraph start end fill-prefix fill-column justify?)
(let ((start (mark-right-inserting-copy (skip-chars-forward "\n" start end)))
(define-minor-mode auto-fill "Fill"
"Minor mode in which lines are automatically wrapped when long enough.")
-(define (auto-fill-break)
- (let ((point (current-point)))
- (if (auto-fill-break? point)
- (let ((prefix
- (or (and (not (ref-variable paragraph-ignore-fill-prefix point))
- (ref-variable fill-prefix point))
- (and (ref-variable adaptive-fill-mode point)
- (fill-context-prefix (or (paragraph-text-start point)
- (line-start point 0))
- (or (paragraph-text-end point)
- (line-end point 0)))))))
- (if (re-search-backward "[^ \t][ \t]+"
+(define (auto-fill-break point)
+ (and (auto-fill-break? point)
+ (let ((prefix
+ (or (and (not
+ (ref-variable paragraph-ignore-fill-prefix point))
+ (ref-variable fill-prefix point))
+ (and (ref-variable adaptive-fill-mode point)
+ (fill-context-prefix (or (paragraph-text-start point)
+ (line-start point 0))
+ (or (paragraph-text-end point)
+ (line-end point 0)))))))
+ (and (re-search-backward "[^ \t][ \t]+"
(move-to-column
point
(+ (ref-variable fill-column) 1))
(line-start point 0))
(let ((break (re-match-end 0)))
- (if (let ((pe
- (and prefix
- (mark+ (line-start point 0)
- (string-length prefix)
- #f))))
- (or (not pe)
- (mark> break pe)))
- (with-fill-prefix prefix
- (lambda ()
- (with-current-point break
- (ref-command indent-new-comment-line)))))))))))
-
-(define (with-fill-prefix prefix thunk)
- (with-variable-value! (ref-variable-object paragraph-ignore-fill-prefix) #f
- (lambda ()
- (with-variable-value! (ref-variable-object fill-prefix) prefix
- thunk))))
+ (and (let ((pe
+ (and prefix
+ (mark+ (line-start point 0)
+ (string-length prefix)
+ #f))))
+ (or (not pe)
+ (mark> break pe)))
+ (begin
+ (indent-new-comment-line break prefix)
+ #t)))))))
(define (auto-fill-break? point)
- (> (mark-column point) (ref-variable fill-column)))
-\f
-(define (center-line mark)
- (let ((mark (mark-permanent! mark)))
- (delete-horizontal-space (line-start mark 0))
- (delete-horizontal-space (line-end mark 0))
- (let ((d (- (- (ref-variable fill-column) (ref-variable left-margin))
- (mark-column (line-end mark 0)))))
- (if (positive? d)
- (insert-horizontal-space (+ (ref-variable left-margin)
- (quotient d 2))
- (line-start mark 0))))))
-
-(define-command center-line
- "Center the line point is on, within the width specified by `fill-column'.
-This means adjusting the indentation to match
-the distance between the end of the text and `fill-column'."
- "d"
- center-line)
\ No newline at end of file
+ (> (mark-column point) (ref-variable fill-column)))
\ No newline at end of file