File: rep.jl

package info (click to toggle)
librep 0.9-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,576 kB
  • ctags: 1,928
  • sloc: ansic: 21,612; sh: 7,386; lisp: 5,331; makefile: 392; sed: 93
file content (83 lines) | stat: -rw-r--r-- 2,968 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
;;;; rep.jl -- read-eval-print loop
;;;  Copyright (C) 1993, 1994 John Harper <john@dcs.warwick.ac.uk>
;;;  $Id: rep.jl,v 1.13 1999/12/10 22:38:25 john Exp $

;;; This file is part of Jade.

;;; Jade is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2, or (at your option)
;;; any later version.

;;; Jade is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.

;;; You should have received a copy of the GNU General Public License
;;; along with Jade; see the file COPYING.  If not, write to
;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

(defun rep ()
  (require 'readline)
  (let
      (input)
    (while t
      (setq input (concat input (readline (if input "> " "rep? "))))
      (condition-case data
	  (progn
	    (format standard-output "%S\n" (eval (read-from-string input)))
	    (setq input nil))
	(end-of-stream
	 (unless (and input (not (string= "" input)))
	   (throw 'quit 0)))
	(error
	 (format standard-output "error--> %S\n" data)
	 (setq input nil))))))

;; Install all autoload hooks. This is done last so that it works
;; when dumped. We load autoload.jl to ensure that we don't get a
;; compiled (and possibly out of date) version
(load-all "autoload.jl" t)

;; Do operating-system initialisation
(load-all (concat "os-" (symbol-name operating-system)) t)

;; Load site specific initialisation. Errors here are trapped since
;; they're probably not going to result in an unusable state
(unless (get-command-line-option "--no-rc")
  (condition-case error-data
      (progn
	;; First the site-wide stuff
	(load-all "site-init")
	;; Now try to interpret the user's startup file, or failing that
	;; the default.jl file providing site-wide user options
	(or
	 (load (concat (user-home-directory) ".reprc") t t)
	 (load "rep-default" t)))
    (error
     (format (stderr-file) "error in local config--> %S\n" error-data))))

;; Use all arguments which are left.
(let
    (arg)
  (while (setq arg (car command-line-args))
    (setq command-line-args (cdr command-line-args))
    (cond
      ((equal "-f" arg)
       (setq arg (car command-line-args))
       (setq command-line-args (cdr command-line-args))
       ((symbol-value (read-from-string arg))))
      ((equal "-l" arg)
       (setq arg (car command-line-args))
       (setq command-line-args (cdr command-line-args))
       (load arg))
      ((equal "-q" arg)
       (throw 'quit 0))
      (t
       (setq batch-mode t)
       (load arg)))))

(unless batch-mode
  (format standard-output ";; rep %s, Copyright (C) 1999 John Harper\n;; rep comes with ABSOLUTELY NO WARRANTY; for details see the file COPYING\n;; built %s\n" rep-version rep-build-id)
  (rep))