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