;;; -*-Scheme-*-
;;;
-;;; $Id: basic.scm,v 1.132 1999/01/28 06:03:18 cph Exp $
+;;; $Id: basic.scm,v 1.133 2000/02/25 14:20:56 cph Exp $
;;;
-;;; Copyright (c) 1986, 1989-1999 Massachusetts Institute of Technology
+;;; Copyright (c) 1986, 1989-2000 Massachusetts Institute of Technology
;;;
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License as
(declare (usual-integrations))
\f
(define-command self-insert-command
- "Insert the character used to invoke this.
-With an argument, insert the character that many times."
- "P"
- (lambda (argument)
- (insert-chars (last-command-key)
- (command-argument-numeric-value argument))))
+ "Insert the character you type.
+Whichever character you type to run this command is inserted."
+ "p"
+ (lambda (n)
+ (let ((char (last-command-key)))
+ (if (not (char? char))
+ (editor-error "self-insert-command only works on character keys."))
+ (self-insert char n #t))))
+
+(define (self-insert char n allow-auto-fill?)
+ (if (> n 0)
+ (begin
+ (if (and (current-minor-mode? (ref-mode-object abbrev))
+ (not (char=? #\w (char-syntax char)))
+ (buffer-writable? (selected-buffer))
+ (eqv? #\w (char-syntax (extract-left-char))))
+ ((ref-command expand-abbrev)))
+ (insert-chars char n)
+ (if (and (or (char=? #\space char)
+ (char=? #\newline char))
+ (current-minor-mode? (ref-mode-object auto-fill)))
+ (auto-fill-break)))))
(define (read-quoted-char prompt-string)
(let ((read-ascii-char
;;; -*-Scheme-*-
;;;
-;;; $Id: fill.scm,v 1.61 2000/02/23 17:37:03 cph Exp $
+;;; $Id: fill.scm,v 1.62 2000/02/25 14:20:32 cph Exp $
;;;
;;; Copyright (c) 1986, 1989-2000 Massachusetts Institute of Technology
;;;
(and (not (group-start? m))
(memv (extract-left-char m) '(#\. #\? #\!)))))
\f
+;;;; Auto Fill
+
(define-command auto-fill-mode
"Toggle auto-fill mode.
With argument, turn auto-fill mode on iff argument is positive."
(enable-current-minor-mode! mode)
(disable-current-minor-mode! mode)))))
-(define-command &auto-fill-space
- "Breaks the line if it exceeds the fill column, then inserts a space."
- "p"
- (lambda (argument)
- (conditionally-override-key (ref-command-object &auto-fill-space)
- (ref-command-object self-insert-command)
- (lambda ()
- (insert-chars #\space argument)
- (auto-fill-break)))))
-
-(define-command &auto-fill-newline
- "Breaks the line if it exceeds the fill column, then inserts a newline."
- "P"
- (lambda (argument)
- (conditionally-override-key (ref-command-object &auto-fill-newline)
- (ref-command-object newline)
- (lambda ()
- (auto-fill-break)
- ((ref-command newline) argument)))))
-
-(define (conditionally-override-key overriding overridden action)
- ;; This looks at the context in which the auto-fill commands are
- ;; invoked, and performs the auto-fill action only when the context
- ;; is the expected one.
- (let ((command
- (local-comtab-entry
- (let ((comtabs (current-comtabs)))
- (let ((tail
- (memq (minor-mode-comtab (ref-mode-object auto-fill))
- comtabs)))
- (if (or (null? tail) (null? (cdr tail)))
- comtabs
- (cdr tail))))
- (current-command-key)
- (current-point))))
- (if (or (eq? command overriding)
- (eq? command overridden)
- (eq? command (ref-command-object undefined)))
- (action)
- (dispatch-on-command command))))
-
-(define-minor-mode auto-fill "Fill" "")
-(define-key 'auto-fill #\space '&auto-fill-space)
-(define-key 'auto-fill #\return '&auto-fill-newline)
+(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 (re-search-backward "[^ \t][ \t]+"
(move-to-column
point
- (1+ (ref-variable fill-column)))
+ (+ (ref-variable fill-column) 1))
(line-start point 0))
(with-current-point (re-match-end 0)
(ref-command indent-new-comment-line))))))
;;; -*-Scheme-*-
;;;
-;;; $Id: lincom.scm,v 1.123 1999/01/02 06:11:34 cph Exp $
+;;; $Id: lincom.scm,v 1.124 2000/02/25 14:20:43 cph Exp $
;;;
-;;; Copyright (c) 1986, 1989-1999 Massachusetts Institute of Technology
+;;; Copyright (c) 1986, 1989-2000 Massachusetts Institute of Technology
;;;
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License as
"Insert a newline. With arg, insert that many newlines."
"*P"
(lambda (argument)
- (insert-newlines (command-argument-numeric-value argument))))
+ (self-insert #\newline
+ (command-argument-numeric-value argument)
+ ;; Don't do auto-fill if argument supplied.
+ (not argument))))
(define-command split-line
"Move rest of this line vertically down.