annotate lisp/ilisp/ilisp-mod.el @ 164:4e0740e5aab2

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