X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Friece-google.el;h=465d068d1fa0f974ad0dcaa0af624253fbf87ab7;hb=ca8af75ed72408baadf78fc5e0570d4bbf30253e;hp=b14977472842b3447b5fbca2fb2783c24bd1ba12;hpb=cf6bb0b92f75973dcf661b9884a5a7033d9e91ed;p=elisp%2Friece.git diff --git a/lisp/riece-google.el b/lisp/riece-google.el index b149774..465d068 100644 --- a/lisp/riece-google.el +++ b/lisp/riece-google.el @@ -1,4 +1,4 @@ -;;; riece-google.el --- Interface to Google API +;;; riece-google.el --- search keywords by Google ;; Copyright (C) 2005 OHASHI Akira ;; Author: OHASHI Akira @@ -19,24 +19,21 @@ ;; 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 @@ -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)