Update .gitignore
[riece] / lisp / riece-doctor.el
index 1f83c7c..ebb3652 100644 (file)
@@ -1,4 +1,4 @@
-;;; riece-doctor.el --- pretend to be a psychotherapist
+;;; riece-doctor.el --- pretend to be a psychotherapist -*- lexical-binding: t -*-
 ;; Copyright (C) 1998-2003 Daiki Ueno
 
 ;; Author: Daiki Ueno <ueno@unixuser.org>
@@ -18,8 +18,8 @@
 
 ;; 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.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -49,8 +49,6 @@
 
 (defvar riece-doctor-patients nil)
 
-(defvar riece-doctor-enabled nil)
-
 (defconst riece-doctor-description
   "Pretend to be a psychotherapist.")
 
@@ -73,7 +71,7 @@
   (riece-send-string (format "NOTICE %s :%s\r\n" target string)))
 
 (defun riece-doctor-after-privmsg-hook (prefix string)
-  (if riece-doctor-enabled
+  (if (get 'riece-doctor 'riece-addon-enabled)
       (let* ((user (riece-prefix-nickname prefix))
             (parameters (riece-split-parameters string))
             (targets (split-string (car parameters) ","))
@@ -83,9 +81,8 @@
                (riece-doctor-reply
                 (car targets)
                 (format "%s: You are already talking with me." user))
-             (save-excursion
-               (set-buffer (get-buffer-create
-                            (riece-doctor-buffer-name user)))
+             (with-current-buffer (get-buffer-create
+                                   (riece-doctor-buffer-name user))
                (erase-buffer)
                (doctor-mode))
              (setq riece-doctor-patients (cons user riece-doctor-patients))
@@ -107,8 +104,7 @@ Please, describe your problems."
                   (format "%s: Good bye." user))))
            (if (riece-identity-member user riece-doctor-patients t)
                (let (string)
-                 (save-excursion
-                   (set-buffer (get-buffer (riece-doctor-buffer-name user)))
+                 (with-current-buffer (riece-doctor-buffer-name user)
                    (goto-char (point-max))
                    (insert message "\n")
                    (let ((point (point)))
@@ -129,12 +125,6 @@ Please, describe your problems."
 (defun riece-doctor-uninstall ()
   (remove-hook 'riece-after-privmsg-hook 'riece-doctor-after-privmsg-hook))
 
-(defun riece-doctor-enable ()
-  (setq riece-doctor-enabled t))
-
-(defun riece-doctor-disable ()
-  (setq riece-doctor-enabled nil))
-
 (provide 'riece-doctor)
 
 ;;; riece-doctor.el ends here