Fix byte-compile error
[riece] / lisp / riece-google.el
index b149774..d596a06 100644 (file)
@@ -1,4 +1,4 @@
-;;; riece-google.el --- Interface to Google API
+;;; riece-google.el --- search keywords by Google -*- lexical-binding: t -*-
 ;; Copyright (C) 2005 OHASHI Akira
 
 ;; Author: OHASHI Akira <bg66@koka-in.org>
 
 ;; 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:
 
-;; This add-on searches keywords by Google.
+;; NOTE: This is an add-on module for Riece.
 
 ;; Ruby code was stolen (and modified) from nadoka.
 
-;; To use, add the following line to your ~/.riece/init.el:
-;; (add-to-list 'riece-addons 'riece-google)
-
 ;;; Code:
 
 (require 'riece-message)
 
 (defgroup riece-google nil
-  "Interface to Google API."
+  "Search keywords by Google."
   :prefix "riece-"
   :group 'riece)
 
@@ -139,7 +136,7 @@ rescue Exception => e
 end
 ")
   "Ruby program for searching by Google."
-  :type 'list
+  :type 'sexp
   :group 'riece-google)
 
 (defcustom riece-google-license-key nil
@@ -147,23 +144,23 @@ end
   :type 'string
   :group 'riece-google)
 
-(defcustom riece-google-default-lang "lang_ja"
-  "*Default language for search keywords."
-  :type 'string
+(defcustom riece-google-default-lang '("lang_en" "lang_ja")
+  "*Default language for searching keywords."
+  :type '(repeat (choice (const "lang_en" :tag "English")
+                        (const "lang_ja" :tag "Japanese")
+                        (string :tag "The other language")))
   :group 'riece-google)
 
 (defconst riece-google-regexp
   "^go\\(o+\\)gle\\(:\\([a-z]+\\)\\)?>\\s-*\\(.*\\)")
 
-(defvar riece-google-enabled nil)
-
 (defconst riece-google-description
   "Search keywords by Google.")
 
 (defvar riece-google-target nil)
 
 (defun riece-google-display-message-function (message)
-  (when (and riece-google-enabled
+  (when (and (get 'riece-google 'riece-addon-enabled)
             (stringp riece-google-license-key)
             (string-match riece-google-regexp (riece-message-text message)))
     (let ((keywords (match-string 4 (riece-message-text message)))
@@ -178,6 +175,8 @@ end
          (coding-system-for-write 'binary)
          (process (start-process "Google" (generate-new-buffer " *Google*")
                                  riece-google-ruby-command)))
+      (when (listp lang)
+       (setq lang (mapconcat #'identity lang " ")))
       (setq riece-google-target (riece-message-target message))
       (process-send-string process
                           (apply #'concat
@@ -211,7 +210,7 @@ end
                                  (buffer-substring (point-min) (point)))
        (delete-region (point-min) (progn (beginning-of-line 2) (point)))))))
 
-(defun riece-google-sentinel (process string)
+(defun riece-google-sentinel (process _string)
   (delete-process process))
 
 (defun riece-google-send-string (target message)
@@ -233,11 +232,9 @@ end
   (add-hook 'riece-after-display-message-functions
            'riece-google-display-message-function))
 
-(defun riece-google-enable ()
-  (setq riece-google-enabled t))
-
-(defun riece-google-disable ()
-  (setq riece-google-enabled nil))
+(defun riece-google-uninstall ()
+  (remove-hook 'riece-after-display-message-functions
+              'riece-google-display-message-function))
 
 (provide 'riece-google)