summaryrefslogtreecommitdiff
path: root/elisp/erbot/erbcspecial.el
blob: a4d54f78e1851c16972c0ea6668c68accf746aa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
;;; erbcspecial.el --- Special/dangerous implementation functions.
;; Many fs-functions can simply be defined in terms of other
;; fs-functions (and always should be!, for security.)
;; This file is for the remaining few, that can't be.
;; Thus, CODE IN THIS FILE SHOULD BE CONSTRUCTED VERY CAREFULLY.
1
;; Time-stamp: <2007-11-23 11:30:12 deego>
;; Copyright (C) 2004 D. Goel
;; Emacs Lisp Archive entry
;; Filename: erbcspecial.el
;; Package: erbcspecial
;; Author: D. Goel <deego@glue.umd.edu>
;; Keywords:
;; Version:
;; URL:  http://www.emacswiki.org/cgi-bin/wiki.pl?ErBot
;; For latest version:


 
;; This file is NOT (yet) part of GNU Emacs.
 
;; This is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
 
;; This is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
 

;; See also:

(defconst erbcspecial-version "0.0dev")

;;==========================================
;;; Requires:
(eval-when-compile (require 'cl))


;;; Code:

(defun erbn-special-quote-function (fcn)
  (cond
   ((symbolp fcn)
    (erblisp-sandbox-quoted fcn))
   ((and (listp fcn)
	 (equal (first fcn) 'lambda)
	 fcn))
   ;; notice the recursion below:
   ((listp fcn) (erbn-special-quote-function (fs-eval fcn)))
   (t (error "Cannot apply this as a function!"))))


;; (defun fs-mapcar-old (sym seq)
;;   "only symbols allowed at this time. "
;;   (unless (symbolp sym)
;;     (error "Function argument to mapcar for this bot can only be a symbol."))
;;   (setq sym (erblisp-sandbox-quoted sym))
;;   ;; everything should already be boxquoted.. cool
;;   (mapcar sym seq))

(defun fsi-mapcar (fcn ls)
  (apply 'mapcar 
	 (erbn-special-quote-function fcn)
	 ls nil))




;; (defun fs-mapc (sym seq)
;;   "only symbols allowed at this time. "
;;   (unless (symbolp sym)
;;     (error "Function argument to mapcar for this bot can only be a symbol."))
;;   (setq sym (erblisp-sandbox-quoted-ensure-symbol sym))
;;   ;; everything should already be boxquoted.. cool
;;   (mapc sym seq))




(defun fsi-mapc (fcn ls)
  (apply 'mapc
	 (erbn-special-quote-function fcn)
	 ls nil))



(defun fsi-mapconcat (fcn ls sep)
  (apply 'mapconcat
	 (erbn-special-quote-function fcn)
	 ls sep nil))







(defun fsi-maplist (fcn ls &rest args)
  (require 'cl)
  (apply 'maplist
	 (erbn-special-quote-function fcn)
	 ls args))



(defun fsi-mapl (fcn ls &rest args)
  (require 'cl)
  (apply 'mapl
	 (erbn-special-quote-function fcn)
	 ls args))

(defun fsi-mapcar* (fcn ls &rest args)
  (require 'cl)
  (apply 'mapcar*
	 (erbn-special-quote-function fcn)
	 ls args))



(defun fsi-mapcon (fcn ls &rest args)
  (require 'cl)
  (apply 'mapcon
	 (erbn-special-quote-function fcn)
	 ls args))






;;; Real Code:



(provide 'erbcspecial)
(run-hooks 'erbcspecial-after-load-hook)



;;; erbcspecial.el ends here