annotate lisp/ilisp/ilisp-mod.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children b82b59fe008d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; -*- Mode: Emacs-Lisp -*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; ilisp-mod.el --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; This file is part of ILISP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; Version: 5.7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; 1993, 1994 Ivan Vasquez
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; 1994, 1995 Marco Antoniotti and Rick Busdiecker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; Other authors' names for which this Copyright notice also holds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; may appear later in this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; Send mail to 'ilisp-request@lehman.com' to be included in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; ILISP mailing list. 'ilisp@lehman.com' is the general ILISP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; mailing list were bugs and improvements are discussed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; ILISP is freely redistributable under the terms found in the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; COPYING.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; ILISP mode top level definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;;%ilisp-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (defun ilisp-byte-code-to-list (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 "Returns a list suitable for passing to make-byte-code from FUNCTION."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (let ((function-object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (if (symbolp function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (symbol-function function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (if (fboundp 'compiled-function-arglist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (read (concat "("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (substring (let ((print-readably t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (prin1-to-string function-object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 2 -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ")"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; FSFmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (append function-object nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (defun ilisp-set-doc (function string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 "Set the documentation of the symbol FUNCTION to STRING."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (let* ((old-function (symbol-function function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (cond ((listp old-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; Probe to test whether function is in preloaded read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; memory, and if so make writable copy:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (setcar old-function (car old-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (setq old-function (copy-sequence old-function)) ; shallow copy only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (fset function old-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (let ((ndoc-cdr (nthcdr 2 old-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (if (stringp (car ndoc-cdr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; Replace the existing docstring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (setcar ndoc-cdr string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; There is no docstring. Insert the overwrite msg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (setcdr ndoc-cdr (cons (car ndoc-cdr) (cdr ndoc-cdr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (setcar ndoc-cdr string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; it's an emacs19 compiled-code object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (let ((new-code (ilisp-byte-code-to-list old-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (if (nthcdr 4 new-code)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (setcar (nthcdr 4 new-code) string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (setcdr (nthcdr 3 new-code) (cons string nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (fset function (apply 'make-byte-code new-code)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defun ilisp-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (run-ilisp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (ilisp-set-doc 'ilisp-mode ilisp-documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (ilisp-set-doc 'lisp-mode ilisp-documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;;%%ILISP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defun lisp-command-args (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 "Break up STRING into (command args ...)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (let ((len (length string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (position 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (args nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (while (< position len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (if (eq (aref string position) ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (setq args (cons (substring string arg position) args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 arg (1+ position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (setq position (1+ position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (setq args (reverse (cons (substring string arg position) args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (defun ilisp (name setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 "Run an inferior LISP process NAME, input and output via buffer *name*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 If there is a process already running in *name*, just switch to that buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 Takes the program name from the variable ilisp-program.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 \(Type \\[describe-mode] in the process buffer for a list of commands.)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (set-buffer ilisp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (if (not (comint-check-proc ilisp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (let* ((dialect (car ilisp-dialect))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (program ilisp-program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (args (lisp-command-args program))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; Use pipes so that strings can be long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (process-connection-type nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (names (format "%s" name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (apply 'make-comint name (car args) nil (cdr args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (comint-setup-ipc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; Because comint-mode kills all buffer-local variables in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; fsf-19 we have to re-call the setup here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (funcall setup name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (setq major-mode 'ilisp-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 mode-name "ILISP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (rplaca (car comint-send-queue)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (run-hooks 'ilisp-init-hook))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (setq ilisp-initialized (lisp-del ilisp-buffer ilisp-initialized))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (if (not (lisp-memk names ilisp-buffers 'car))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (setq ilisp-buffers (cons (list names) ilisp-buffers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (lisp-pop-to-buffer ilisp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (setq start (window-start (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ilisp-program program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (insert (format "Starting %s ...\n" ilisp-program))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (set-marker (process-mark (ilisp-process)) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (funcall comint-update-status 'start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (if ilisp-motd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (progn (lisp-display-output (format ilisp-motd ilisp-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (set-window-start (selected-window) start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (if (not ilisp-prefix-match) (require 'completer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (lisp-pop-to-buffer ilisp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (use-local-map ilisp-use-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; This is necessary to get mode documentation to come out right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (set-default 'ilisp-use-map ilisp-use-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;;%Manual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (autoload 'fi:clman "fi/clman"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 "Look up SYMBOL in the online manual with completion." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (autoload 'fi:clman-apropos "fi/clman"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 "Do an apropos search in online manual for STRING." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;;;%Bridges
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (autoload 'install-bridge "bridge" "Install process bridge." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;;;%Modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (set-default 'auto-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (append '(("\\.cl$" . lisp-mode) ("\\.lisp$" . lisp-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 auto-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (setq completion-ignored-extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (append '(".68fasl" ".sfasl" ".ifasl" ".pfasl"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ".68fasl4" ".sfasl4" ".ifasl4" ".pfasl4"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ".sbin")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 completion-ignored-extensions))