diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-15 05:40:38 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-15 05:40:38 +0000 |
| commit | ef7c29d679c6aaf8dda55772e65800097c46f163 (patch) | |
| tree | 543f39f09bfaa6d44606804c18babff26470d4f8 /chess-database.el | |
| parent | 6fbcc92505250d896b5d408483822b115bc614c7 (diff) | |
*** no comment ***
Diffstat (limited to 'chess-database.el')
| -rw-r--r-- | chess-database.el | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/chess-database.el b/chess-database.el index 2f2655b..35cbc44 100644 --- a/chess-database.el +++ b/chess-database.el @@ -4,16 +4,9 @@ ;; ;; $Revision$ -(defvar chess-database-event-handler nil) +(defvar chess-database-handler nil) -(make-variable-buffer-local 'chess-database-event-handler) - -(defmacro chess-with-current-buffer (buffer &rest body) - `(let ((buf ,buffer)) - (if buf - (with-current-buffer buf - ,@body) - ,@body))) +(make-variable-buffer-local 'chess-database-handler) (chess-message-catalog 'english '((no-such-database . "There is no such chess database module '%s'"))) @@ -21,21 +14,19 @@ (defun chess-database-open (module file) "Returns the opened database object, or nil." (let* ((name (symbol-name module)) - (handler (intern-soft (concat name "-handler"))) - buffer) + (handler (intern-soft (concat name "-handler")))) (unless handler (chess-error 'no-such-database name)) (when (setq buffer (funcall handler 'open file)) (with-current-buffer buffer - (setq chess-database-event-handler handler) + (setq chess-database-handler handler) (add-hook 'kill-buffer-hook 'chess-database-close nil t) (add-hook 'after-revert-hook 'chess-database-rescan nil t) (current-buffer))))) (defsubst chess-database-command (database event &rest args) - (chess-with-current-buffer database - (apply 'chess-database-event-handler nil (current-buffer) - event args))) + (with-current-buffer database + (apply chess-database-handler event args))) (defun chess-database-close (&optional database) (let ((buf (or database (current-buffer)))) @@ -67,12 +58,6 @@ (defun chess-database-query (database &rest terms) (chess-database-command database 'query terms)) -(defun chess-database-event-handler (game database event &rest args) - (if (eq event 'shutdown) - (chess-database-close database) - (chess-with-current-buffer database - (apply chess-database-event-handler event args)))) - (provide 'chess-database) ;;; chess-database.el ends here |
