/[erbot]/erbot/erbc3.el
ViewVC logotype

Diff of /erbot/erbc3.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by deego, Sat Jan 1 22:34:11 2005 UTC revision 1.19 by deego, Sat Jan 8 17:53:08 2005 UTC
# Line 1  Line 1 
1  ;;; erbc3.el ---erbot lisp stuff which should be PERSISTENT ACROSS SESSIONS.  ;;; erbc3.el ---erbot lisp stuff which should be PERSISTENT ACROSS SESSIONS.
2  ;; Time-stamp: <2005-01-01 17:34:19 deego>  ;; Time-stamp: <2005-01-08 12:52:25 deego>
3  ;; Copyright (C) 2003 D. Goel  ;; Copyright (C) 2003 D. Goel
4  ;; Emacs Lisp Archive entry  ;; Emacs Lisp Archive entry
5  ;; Filename: erbc3.el  ;; Filename: erbc3.el
# Line 172  to query using PROMPT, or just return t. Line 172  to query using PROMPT, or just return t.
172  ;; pf stands for persistent functions.  ;; pf stands for persistent functions.
173  ;; pv stands for persistent variables.  ;; pv stands for persistent variables.
174    
175  (defvar erbnoc-pf-file "~/public_html/data/userfunctions.el")  (defvar erbn-pf-file "~/public_html/data/userfunctions.el")
176  (defvar erbnoc-pv-file "~/public_html/data/uservariables.el")  (defvar erbn-pv-file "~/public_html/data/uservariables.el")
177    
178  (defun fsi-pfpv-load ()  (defun fsi-pfpv-load ()
179    (fsi-pf-load)    (fsi-pf-load)
180    (fsi-pv-load))    (fsi-pv-load))
181    
182  (defun fsi-pf-load ()  (defun fsi-pf-load ()
183    (when (file-exists-p erbnoc-pf-file)    (when (file-exists-p erbn-pf-file)
184           (ignore-errors (load erbnoc-pf-file))))           (ignore-errors (load erbn-pf-file))))
185    
186  (defun fsi-pv-load ()  (defun fsi-pv-load ()
187    (when (file-exists-p erbnoc-pv-file)    (when (file-exists-p erbn-pv-file)
188      (ignore-errors (load erbnoc-pv-file))))      (ignore-errors (load erbn-pv-file))))
189    
190                    
191    
192  (defun fsi-user-function-p (fcn)  (defun fsi-user-function-p (fcn)
193    (member    (member
194     fcn     fcn
195     (erbutils-functions-in-file erbnoc-pf-file)))     (erbutils-functions-in-file erbn-pf-file)))
196    
197    
198  (defun erbnoc-create-defun-new (sexps body)  (defun erbn-create-defun-new (sexps body)
199    (cons body sexps))    (cons body sexps))
200    
201  (defun erbnoc-create-defun-overwrite (sexps body fcn)  (defun erbn-create-defun-overwrite (sexps body fcn)
202    (cons body    (cons body
203          (remove          (remove
204           (first (member-if           (first (member-if
# Line 208  to query using PROMPT, or just return t. Line 208  to query using PROMPT, or just return t.
208    
209                                                    
210    
211  (defun erbnoc-write-sexps-to-file (file sexps &optional backup-rarity)  (defun erbn-write-sexps-to-file (file sexps &optional backup-rarity)
212    (unless backup-rarity (setq backup-rarity 1))    (unless backup-rarity (setq backup-rarity 1))
213    (when (zerop (random backup-rarity)) (erbutils-mkback-maybe file))    (when (zerop (random backup-rarity)) (erbutils-mkback-maybe file))
214    
# Line 222  to query using PROMPT, or just return t. Line 222  to query using PROMPT, or just return t.
222    (insert "\n\n\n")    (insert "\n\n\n")
223    (save-buffer))    (save-buffer))
224    
225  (defvar erbnoc-tmp-sexps)  (defvar erbn-tmp-sexps)
226  (defvar erbnoc-tmp-newbody)  (defvar erbn-tmp-newbody)
227    
228    
229    
# Line 250  to query using PROMPT, or just return t. Line 250  to query using PROMPT, or just return t.
250  ;;;###autoload  ;;;###autoload
251  (defun fsi-pv-save ()  (defun fsi-pv-save ()
252    (interactive)    (interactive)
253    (erbnoc-write-sexps-to-file    (erbn-write-sexps-to-file
254     erbnoc-pv-file     erbn-pv-file
255     (fs-pv-get-variables-values) 1000))     (fs-pv-get-variables-values) 1000))
256     ;; this should lead to a few saves every day... not too many one hopes..     ;; this should lead to a few saves every day... not too many one hopes..
257  ;;1000))  ;;1000))
258    
259    
260        
261  (defun erbnoc-readonly-check (sym)  (defun erbn-readonly-check (sym)
262    (if (get sym 'readonly)    (if (get sym 'readonly)
263        (error "The symbol %S can't be redefined! It is read-only!"        (error "The symbol %S can't be redefined! It is read-only!"
264               sym)))               sym)))
# Line 273  to query using PROMPT, or just return t. Line 273  to query using PROMPT, or just return t.
273    (unless (symbolp fcn)    (unless (symbolp fcn)
274      (error "Defun symbols only! :P"))      (error "Defun symbols only! :P"))
275    
276    (erbnoc-readonly-check fcn)    (erbn-readonly-check fcn)
277    
278    (erbnoc-write-sexps-to-file    (erbn-write-sexps-to-file
279     erbnoc-pf-file     erbn-pf-file
280     (erbnoc-create-defun-overwrite     (erbn-create-defun-overwrite
281      (erbutils-file-sexps erbnoc-pf-file)      (erbutils-file-sexps erbn-pf-file)
282      (cons 'defun (cons fcn body)) fcn))      (cons 'defun (cons fcn body)) fcn))
283    (fsi-pf-load)    (fsi-pf-load)
284    `(quote ,fcn))    `(quote ,fcn))
# Line 311  to query using PROMPT, or just return t. Line 311  to query using PROMPT, or just return t.
311    (setq sym    (setq sym
312          (erblisp-sandbox sym))          (erblisp-sandbox sym))
313    
314    (erbnoc-readonly-check sym)    (erbn-readonly-check sym)
315    
316    (let    (let
317        ;; this is to be returned..        ;; this is to be returned..
318        ((result (fmakunbound sym))        ((result (fmakunbound sym))
319         (sexps       (erbutils-file-sexps erbnoc-pf-file)))         (sexps       (erbutils-file-sexps erbn-pf-file)))
320                    
321      ;; now we want to remove any definition of sym from the user      ;; now we want to remove any definition of sym from the user
322      ;; file:      ;; file:
323            
324      (erbnoc-write-sexps-to-file      (erbn-write-sexps-to-file
325       erbnoc-pf-file       erbn-pf-file
326       (remove       (remove
327        (first        (first
328         (member-if         (member-if
# Line 333  to query using PROMPT, or just return t. Line 333  to query using PROMPT, or just return t.
333      result))      result))
334    
335    
336  (defvar erbnoc-tmpsetq nil)  (defvar erbn-tmpsetq nil)
337    
338  (defmacro fsi-setq (&rest args)  (defmacro fsi-setq (&rest args)
339    `(let ((erbnoc-tmpsetq    `(let ((erbn-tmpsetq
340            (setq ,@args)))            (setq ,@args)))
341       (fs-pv-save)       (fs-pv-save)
342       erbnoc-tmpsetq))       erbn-tmpsetq))
343    
344    
345    

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26