~ubuntu-branches/ubuntu/karmic/mit-scheme/karmic

« back to all changes in this revision

Viewing changes to src/edwin/fileio.scm

  • Committer: Bazaar Package Importer
  • Author(s): Chris Hanson
  • Date: 2006-09-20 21:59:42 UTC
  • mfrom: (1.1.4 upstream) (3.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20060920215942-o3erry1wowyk1ezz
Tags: 7.7.90+20060906-3
No changes; rebuild with downgraded openssl in order to permit
transition into testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#| -*-Scheme-*-
2
2
 
3
 
$Id: fileio.scm,v 1.167 2006/01/27 21:05:52 cph Exp $
 
3
$Id: fileio.scm,v 1.168 2006/04/29 01:29:56 cph Exp $
4
4
 
5
5
Copyright 1986,1989,1991,1992,1993,1994 Massachusetts Institute of Technology
6
6
Copyright 1995,1997,1999,2000,2001,2002 Massachusetts Institute of Technology
7
 
Copyright 2003,2004,2005 Massachusetts Institute of Technology
 
7
Copyright 2003,2004,2005,2006 Massachusetts Institute of Technology
8
8
 
9
9
This file is part of MIT/GNU Scheme.
10
10
 
399
399
        (suffix (extract-string end (line-end end 0))))
400
400
    (let ((prefix? (not (string-null? prefix)))
401
401
          (suffix? (not (string-null? suffix))))
 
402
 
402
403
      (define (loop mark)
403
404
        (let ((start (line-start mark 1)))
404
405
          (if (not start) (editor-error "Missing local variables entry"))
405
406
          (do-line start (line-end start 0))))
406
407
 
407
408
      (define (do-line start end)
 
409
 
408
410
        (define (check-suffix mark)
409
411
          (if (and suffix? (not (match-forward suffix mark)))
410
412
              (editor-error "Local variables entry missing suffix")))
 
413
 
411
414
        (let ((m1
412
415
               (horizontal-space-end
413
416
                (if prefix?
414
417
                    (or (match-forward prefix start end #f)
415
418
                        (editor-error "Local variables entry missing prefix"))
416
419
                    start))))
417
 
          (let ((m2
418
 
                 (let ((m2 (char-search-forward #\: m1 end)))
419
 
                   (if (not m2)
420
 
                       (editor-error "Missing colon in local variables entry"))
421
 
                   (mark-1+ m2))))
422
 
            (let ((var (extract-string m1 (horizontal-space-start m2)))
423
 
                  (m3 (horizontal-space-end (mark1+ m2))))
424
 
              (if (not (string-ci=? var "End"))
425
 
                  (with-input-from-mark m3 read
426
 
                    (lambda (val m4)
427
 
                      (check-suffix (horizontal-space-end m4))
428
 
                      (if (string-ci=? var "Mode")
429
 
                          (let ((mode
430
 
                                 (string-table-get editor-modes
431
 
                                                   (extract-string m3 m4))))
432
 
                            (if mode
433
 
                                ((if (mode-major? mode)
434
 
                                     set-buffer-major-mode!
435
 
                                     enable-buffer-minor-mode!)
436
 
                                 buffer mode)))
437
 
                          (call-with-current-continuation
438
 
                           (lambda (continuation)
439
 
                             (bind-condition-handler
440
 
                                 (list condition-type:error)
441
 
                                 (lambda (condition)
442
 
                                   condition
443
 
                                   (editor-beep)
444
 
                                   (message
445
 
                                    "Error while processing local variable: "
446
 
                                    var)
447
 
                                   (continuation #f))
448
 
                               (lambda ()
449
 
                                 (if (string-ci=? var "Eval")
450
 
                                     (with-selected-buffer buffer
451
 
                                       (lambda ()
 
420
          (cond ((re-match-forward "End:[ \t]*" m1 end)
 
421
                 (check-suffix (re-match-end 0)))
 
422
                ((re-search-forward ":[ \t]+" m1 end)
 
423
                 (let ((var (extract-string m1 (re-match-start 0)))
 
424
                       (m2 (re-match-end 0)))
 
425
                   (if (line-end? m2)
 
426
                       (editor-error "Missing value for local variable:" var))
 
427
                   (with-input-from-mark m2 read
 
428
                     (lambda (val m3)
 
429
                       (check-suffix (horizontal-space-end m3))
 
430
                       (if (string-ci=? var "Mode")
 
431
                           (let ((mode
 
432
                                  (string-table-get editor-modes
 
433
                                                    (extract-string m2 m3))))
 
434
                             (if mode
 
435
                                 ((if (mode-major? mode)
 
436
                                      set-buffer-major-mode!
 
437
                                      enable-buffer-minor-mode!)
 
438
                                  buffer mode)))
 
439
                           (if (condition?
 
440
                                (ignore-errors
 
441
                                 (lambda ()
 
442
                                   (if (string-ci=? var "Eval")
 
443
                                       (with-selected-buffer buffer
 
444
                                         (lambda ()
 
445
                                           (evaluate val)))
 
446
                                       (define-variable-local-value! buffer
 
447
                                           (name->variable (intern var))
452
448
                                         (evaluate val)))
453
 
                                     (define-variable-local-value! buffer
454
 
                                         (name->variable (intern var))
455
 
                                       (evaluate val))))))))
456
 
                      (loop m4))))))))
 
449
                                   #f)))
 
450
                               (editor-error
 
451
                                "Error while processing local variable:"
 
452
                                var)))
 
453
                       (loop m3)))))
 
454
                (else
 
455
                 (editor-error "Missing colon in local variables entry")))))
457
456
 
458
457
      (loop start))))
459
458