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 $
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
9
9
This file is part of MIT/GNU Scheme.
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
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))))
407
408
(define (do-line start end)
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")))
412
415
(horizontal-space-end
414
417
(or (match-forward prefix start end #f)
415
418
(editor-error "Local variables entry missing prefix"))
418
(let ((m2 (char-search-forward #\: m1 end)))
420
(editor-error "Missing colon in local variables entry"))
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
427
(check-suffix (horizontal-space-end m4))
428
(if (string-ci=? var "Mode")
430
(string-table-get editor-modes
431
(extract-string m3 m4))))
433
((if (mode-major? mode)
434
set-buffer-major-mode!
435
enable-buffer-minor-mode!)
437
(call-with-current-continuation
438
(lambda (continuation)
439
(bind-condition-handler
440
(list condition-type:error)
445
"Error while processing local variable: "
449
(if (string-ci=? var "Eval")
450
(with-selected-buffer buffer
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)))
426
(editor-error "Missing value for local variable:" var))
427
(with-input-from-mark m2 read
429
(check-suffix (horizontal-space-end m3))
430
(if (string-ci=? var "Mode")
432
(string-table-get editor-modes
433
(extract-string m2 m3))))
435
((if (mode-major? mode)
436
set-buffer-major-mode!
437
enable-buffer-minor-mode!)
442
(if (string-ci=? var "Eval")
443
(with-selected-buffer buffer
446
(define-variable-local-value! buffer
447
(name->variable (intern var))
453
(define-variable-local-value! buffer
454
(name->variable (intern var))
455
(evaluate val))))))))
451
"Error while processing local variable:"
455
(editor-error "Missing colon in local variables entry")))))