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