8e97b71a3d0e749e832145b76d2dc5d1f728fb6e
[elisp/apel.git] / static.el
1 ;;; static.el --- tools for static evaluation.
2
3 ;; Copyright (C) 1999 Tanaka Akira <akr@jaist.ac.jp>
4
5 ;; Author: Tanaka Akira <akr@jaist.ac.jp>
6 ;; Keywords: emulation, compatibility, incompatibility, Mule
7
8 ;; This file is part of APEL (A Portable Emacs Library).
9
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
14
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 ;; General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Code:
26
27 (put 'static-if 'lisp-indent-function 2)
28 (defmacro static-if (cond then &rest else)
29   (if (eval cond)
30       then
31     (` (progn  (,@ else)))))
32
33 (put 'static-when 'lisp-indent-function 1)
34 (defmacro static-when (cond &rest body)
35   (if (eval cond)
36       (` (progn (,@ body)))))
37
38 (put 'static-unless 'lisp-indent-function 1)
39 (defmacro static-unless (cond &rest body)
40   (if (eval cond)
41       nil
42     (` (progn (,@ body)))))
43
44 (put 'static-condition-case 'lisp-indent-function 2)
45 (defmacro static-condition-case (var bodyform &rest handlers)
46   (eval (` (condition-case (, var)
47                (list (quote quote) (, bodyform))
48              (,@ (mapcar
49                   (if var
50                       (lambda (h)
51                         (` ((, (car h))
52                             (list (quote funcall)
53                                   (lambda ((, var)) (,@ (cdr h)))
54                                   (list (quote quote) (, var))))))
55                     (lambda (h)
56                       (` ((, (car h)) (quote (progn (,@ (cdr h))))))))
57                   handlers))))))
58
59
60 ;;; @ end
61 ;;;
62
63 (provide 'static)
64
65 ;;; static.el ends here