1 ;;; -*- Mode: Emacs-Lisp -*-
4 ;;; ILISP mode top level definitions.
6 ;;; This file is part of ILISP.
7 ;;; Please refer to the file COPYING for copyrights and licensing
9 ;;; Please refer to the file ACKNOWLEGDEMENTS for an (incomplete) list
10 ;;; of present and past contributors.
12 ;;; $Id: ilisp-mod.el,v 1.3 2001-07-02 09:40:47 youngs Exp $
16 (defun ilisp-byte-code-to-list (function)
17 "Returns a list suitable for passing to make-byte-code from FUNCTION."
18 (let ((function-object
19 (if (symbolp function)
20 (symbol-function function)
22 (if (fboundp 'compiled-function-arglist)
25 (substring (let ((print-readably t))
26 (prin1-to-string function-object))
30 (append function-object nil))))
33 (defun ilisp-set-doc (function string)
34 "Set the documentation of the symbol FUNCTION to STRING."
35 (let* ((old-function (symbol-function function)))
36 (cond ((listp old-function)
37 ;; Probe to test whether function is in preloaded read-only
38 ;; memory, and if so make writable copy:
40 (setcar old-function (car old-function))
42 (setq old-function (copy-sequence old-function)) ; shallow copy only
43 (fset function old-function)))
44 (let ((ndoc-cdr (nthcdr 2 old-function)))
45 (if (stringp (car ndoc-cdr))
46 ;; Replace the existing docstring.
47 (setcar ndoc-cdr string)
48 ;; There is no docstring. Insert the overwrite msg.
49 (setcdr ndoc-cdr (cons (car ndoc-cdr) (cdr ndoc-cdr)))
50 (setcar ndoc-cdr string))))
52 ;; it's an emacs19 compiled-code object
53 (let ((new-code (ilisp-byte-code-to-list old-function)))
54 (if (nthcdr 4 new-code)
55 (setcar (nthcdr 4 new-code) string)
56 (setcdr (nthcdr 3 new-code) (cons string nil)))
57 (fset function (apply 'make-byte-code new-code)))))))
66 (ilisp-set-doc 'ilisp-mode ilisp-documentation)
67 (ilisp-set-doc 'lisp-mode ilisp-documentation)
70 (defun lisp-command-args (command-line)
71 "Break up COMMAND-LINE into (command args ...)"
75 for pos = (string-match "\\S-" command-line start)
77 if (char-equal (aref command-line pos) ?\")
78 collect (let ((str+end-pos (read-from-string command-line pos)))
79 (setq start (cdr str+end-pos))
81 else collect (let ((end-pos (string-match "\\s-" command-line pos)))
83 (substring command-line pos end-pos)))
84 (error (error "Invalid inferior Lisp program command line"))))
88 (defun ilisp (name setup)
89 "Run an inferior LISP process NAME, input and output via buffer *name*.
90 If there is a process already running in *name*, just switch to that buffer.
91 Takes the program name from the variable ilisp-program.
92 \(Type \\[describe-mode] in the process buffer for a list of commands.)"
93 (set-buffer ilisp-buffer)
94 (if (not (comint-check-proc ilisp-buffer))
95 (let* ((dialect (car ilisp-dialect))
96 (program ilisp-program)
97 (args (lisp-command-args program))
98 ;; Use pipes so that strings can be long
99 (process-connection-type nil)
100 (names (format "%s" name))
102 (apply 'make-comint name (car args) nil (cdr args))
104 ;; Because comint-mode kills all buffer-local variables in
105 ;; fsf-19 we have to re-call the setup here.
107 (setq major-mode 'ilisp-mode
109 (rplaca (car comint-send-queue)
111 (run-hooks 'ilisp-init-hook-local))))
112 (setq ilisp-initialized (delete* ilisp-buffer ilisp-initialized
114 (unless (member* names ilisp-buffers :key #'car)
115 (setq ilisp-buffers (cons (list names) ilisp-buffers)))
116 (lisp-pop-to-buffer ilisp-buffer)
117 (setq start (window-start (selected-window))
118 ilisp-program program)
119 (goto-char (point-max))
120 (insert (format "Starting %s ...\n" ilisp-program))
121 (set-marker (process-mark (ilisp-process)) (point))
122 (funcall comint-update-status 'start)
125 (lisp-display-output (format ilisp-motd ilisp-*version*))
127 (set-window-start (selected-window) start))
129 (unless ilisp-*prefix-match* (require 'completer)))
131 (lisp-pop-to-buffer ilisp-buffer))
132 (use-local-map ilisp-use-map)
133 ;; This is necessary to get mode documentation to come out right
134 (set-default 'ilisp-use-map ilisp-use-map))
138 (autoload 'fi:clman "fi/clman"
139 "Look up SYMBOL in the online manual with completion." t)
140 (autoload 'fi:clman-apropos "fi/clman"
141 "Do an apropos search in online manual for STRING." t)
144 (autoload 'install-bridge "bridge" "Install process bridge." t)
147 (set-default 'auto-mode-alist
148 (append '(("\\.cl$" . lisp-mode) ("\\.lisp$" . lisp-mode))
150 (setq completion-ignored-extensions
151 (append '(".68fasl" ".sfasl" ".ifasl" ".pfasl"
152 ".68fasl4" ".sfasl4" ".ifasl4" ".pfasl4"
154 completion-ignored-extensions))