Mercurial > hg > xemacs-beta
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lisp/ilisp/ilisp-rng.el Mon Aug 13 08:45:50 2007 +0200 @@ -0,0 +1,58 @@ +;;; -*- Mode: Emacs-Lisp -*- + +;;; ilisp-rng.el -- + +;;; This file is part of ILISP. +;;; Version: 5.7 +;;; +;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell +;;; 1993, 1994 Ivan Vasquez +;;; 1994, 1995 Marco Antoniotti and Rick Busdiecker +;;; +;;; Other authors' names for which this Copyright notice also holds +;;; may appear later in this file. +;;; +;;; Send mail to 'ilisp-request@lehman.com' to be included in the +;;; ILISP mailing list. 'ilisp@lehman.com' is the general ILISP +;;; mailing list were bugs and improvements are discussed. +;;; +;;; ILISP is freely redistributable under the terms found in the file +;;; COPYING. + + + +;;; +;;; ILISP match ring. +;;; +(defun match-ring (ring regexp start) + "Return the index in RING of REGEXP starting at START." + (let ((n 0) + (len (ring-length ring))) + (while (and (< n len) + (not (string-match regexp (ring-ref ring n)))) + (setq n (1+ n))) + (if (= n len) + nil + n))) + +;;; +(defun lisp-match-ring (regexp string &optional no-insert) + "Match REGEXP in the input-ring of the current buffer and set the +ring variables to look like comint-previous-similar-input if found. +If not found insert STRING, unless NO-INSERT." + (let ((n (if regexp (match-ring (ilisp-get-input-ring) regexp 0)))) + (if n + (let ((point (progn (comint-kill-input) (point)))) + (insert (ring-ref (ilisp-get-input-ring) n)) + (save-excursion + (goto-char (+ point (length string))) + (skip-chars-forward "^ \t\n\)") + (setq point (point))) + (push-mark point) + (set-ilisp-input-ring-index n) + (setq this-command 'comint-previous-similar-input + comint-last-similar-string string) + t) + (if (and string (not no-insert)) + (progn (comint-kill-input) (insert string) t) + nil))))