1 ;;; -*- Mode: Emacs-Lisp -*-
4 ;;; ILISP comint interface code.
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-cmt.el,v 1.3 2001-07-02 09:40:46 youngs Exp $
17 (defun ilisp-get-old-input ()
18 "Snarf the sexp starting at the nearest previous prompt, or NIL if none."
20 (let* ((begin (lisp-defun-begin))
21 (pmark (process-mark (get-buffer-process (current-buffer))))
22 (once (if (< (point) pmark)
23 (save-excursion (end-of-line) (point))))
27 (while (and (not done) (< (point) (point-max)))
30 (skip-chars-forward " \t\n")
31 (if (and once (>= (point) once)) (setq done t)))
32 (error (setq end nil)))
33 (if end (buffer-substring begin end)))))
36 (defun ilisp-input-filter (str)
37 "Don't save anything matching ilisp-filter-regexp or less than
38 ilisp-filter-length long."
39 (and (not (string-match ilisp-filter-regexp str))
40 (> (length str) ilisp-filter-length)))
43 (defun ilisp-error-filter (output)
44 "Keep from OUTPUT only what matches ilisp-error-regexp or everything
45 if there is no match."
46 (if (string-match (ilisp-value 'ilisp-error-regexp) output)
47 (substring output (match-beginning 0) (match-end 0))
52 (defun newline-and-indent-lisp ()
53 "If at the end of the buffer, send the string back to the process
54 mark with no newline. Otherwise, insert a newline, then indent. In
55 an ilisp buffer the region is narrowed first. See newline-and-indent
56 for more information."
61 (if (and (= (point) (point-max))
62 (memq major-mode ilisp-modes)
63 (setq input (ilisp-get-old-input)))
64 (let ((process (ilisp-process))
65 (comint-send-newline (not comint-send-newline)))
66 (funcall comint-input-sender process input)
67 (set-marker (process-mark process) (point)))
69 (if (memq major-mode ilisp-modes)
70 (narrow-to-region (save-excursion (lisp-input-start))
72 (newline-and-indent))))))