1 ;;; zenirc-eval.el --- join the "mi emacs es tu emacs" club
3 ;; Copyright (C) 1997, 1998 Ray Jones
5 ;; Author: Ray Jones <rjones@pobox.com>
6 ;; Maintainer: rjones@pobox.com
7 ;; Keywords: zenirc, extensions, eval, oink
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; if not, you can either send email to this
23 ;; program's maintainer or write to: The Free Software Foundation,
24 ;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
28 ;; Whip me, beat me, make my emacs calculate primes via church
31 ;; WARNING WARNING WARNING WARNING WARNING WARNING WARNING
33 ;; *** DO NOT RUN THIS CODE UNLESS YOU KNOW WHAT IT DOES ***
35 ;; Running this code could be hazardous to your emacs, your files,
36 ;; the machine you're using, and several other things you may not
37 ;; wish to expose to the ministrations of random lusers, particularly
38 ;; in the IRC world. You have been warned.
40 ;; WARNING WARNING WARNING WARNING WARNING WARNING WARNING
45 (require 'zenirc-trigger)
47 (defun zenirc-eval (&optional msg)
48 ;; parse out the (e)valuable bit
49 (string-match "(eval \\(.*\\))" msg)
51 ;; provide a modicum of protection from malicious parties.
52 ;; NB it can be circumvented via a similar expression.
53 (let ((kill-emacs-hook
54 #'(lambda () (error "kill-emacs called from zenirc-eval"))))
56 (let ((res (prin1-to-string (eval (read (match-string 1 msg))))))
60 (error (format "Error: %s" err)))))
62 (zenirc-trigger-register "eval" 'zenirc-eval "(eval \\(.*\\))" t)
64 ;;; zenirc-eval.el ends here.