0
|
1 ;;; -*- Mode: Emacs-Lisp -*-
|
|
2
|
|
3 ;;; ilisp-rng.el --
|
|
4
|
|
5 ;;; This file is part of ILISP.
|
4
|
6 ;;; Version: 5.8
|
0
|
7 ;;;
|
|
8 ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
|
|
9 ;;; 1993, 1994 Ivan Vasquez
|
4
|
10 ;;; 1994, 1995, 1996 Marco Antoniotti and Rick Busdiecker
|
|
11 ;;; 1996 Marco Antoniotti and Rick Campbell
|
0
|
12 ;;;
|
|
13 ;;; Other authors' names for which this Copyright notice also holds
|
|
14 ;;; may appear later in this file.
|
|
15 ;;;
|
4
|
16 ;;; Send mail to 'ilisp-request@naggum.no' to be included in the
|
|
17 ;;; ILISP mailing list. 'ilisp@naggum.no' is the general ILISP
|
0
|
18 ;;; mailing list were bugs and improvements are discussed.
|
|
19 ;;;
|
|
20 ;;; ILISP is freely redistributable under the terms found in the file
|
|
21 ;;; COPYING.
|
|
22
|
|
23
|
|
24
|
|
25 ;;;
|
|
26 ;;; ILISP match ring.
|
|
27 ;;;
|
|
28 (defun match-ring (ring regexp start)
|
|
29 "Return the index in RING of REGEXP starting at START."
|
|
30 (let ((n 0)
|
|
31 (len (ring-length ring)))
|
|
32 (while (and (< n len)
|
|
33 (not (string-match regexp (ring-ref ring n))))
|
|
34 (setq n (1+ n)))
|
|
35 (if (= n len)
|
|
36 nil
|
|
37 n)))
|
|
38
|
|
39 ;;;
|
|
40 (defun lisp-match-ring (regexp string &optional no-insert)
|
|
41 "Match REGEXP in the input-ring of the current buffer and set the
|
|
42 ring variables to look like comint-previous-similar-input if found.
|
|
43 If not found insert STRING, unless NO-INSERT."
|
|
44 (let ((n (if regexp (match-ring (ilisp-get-input-ring) regexp 0))))
|
|
45 (if n
|
|
46 (let ((point (progn (comint-kill-input) (point))))
|
|
47 (insert (ring-ref (ilisp-get-input-ring) n))
|
|
48 (save-excursion
|
|
49 (goto-char (+ point (length string)))
|
|
50 (skip-chars-forward "^ \t\n\)")
|
|
51 (setq point (point)))
|
|
52 (push-mark point)
|
|
53 (set-ilisp-input-ring-index n)
|
|
54 (setq this-command 'comint-previous-similar-input
|
|
55 comint-last-similar-string string)
|
|
56 t)
|
|
57 (if (and string (not no-insert))
|
|
58 (progn (comint-kill-input) (insert string) t)
|
|
59 nil))))
|