annotate lisp/ilisp/ilisp-el.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-el.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 ;;; ILISP extensions to emacs lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;%Utils
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; This should be in emacs, but it isn't.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (defun lisp-mem (item list &optional elt=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 "Test to see if ITEM is equal to an item in LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 Option comparison function ELT= defaults to equal."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (let ((elt= (or elt= (function equal)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (done nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (while (and list (not done))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (if (funcall elt= item (car list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (setq done list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (setq list (cdr list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 done))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;;%%Misc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (defun lisp-memk (item list key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 "Test to see if ITEM is in LIST using KEY on each item in LIST
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 before comparing it to ITEM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (lisp-mem item list (function (lambda (x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (equal x (funcall key y))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; This should be in emacs, but it isn't.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (defun lisp-del (item list &optional test)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 "Delete ITEM from LIST using TEST comparison and return the result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 Default test is equal."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (let ((test (or test (function equal)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (element list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (prev nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (done nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (while (and element (not done))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (if (funcall test item (car element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (setq done t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (if prev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (rplacd prev (cdr element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (setq list (cdr list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (setq prev element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 element (cdr element))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defun lisp-last (list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "Return the last element of LIST."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (while (cdr list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (car list))