-;;; riece-google.el --- Interface to Google API
+;;; riece-google.el --- search keywords by Google
;; 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)
: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)))
(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
(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)