[logaling-commit] logaling/logalimacs [master] Use Regexp of Ruby instead of Emacs lisp Regexp

Back to archive index

Yuta Yamada null+****@clear*****
Wed Aug 22 00:29:14 JST 2012


Yuta Yamada	2012-08-22 00:29:14 +0900 (Wed, 22 Aug 2012)

  New Revision: aed76e446a75834d574432d6c2f13fe9abc397b3
  https://github.com/logaling/logalimacs/commit/aed76e446a75834d574432d6c2f13fe9abc397b3

  Log:
    Use Regexp of Ruby instead of Emacs lisp Regexp

  Modified files:
    logalimacs.el

  Modified: logalimacs.el (+11 -1)
===================================================================
--- logalimacs.el    2012-08-22 00:15:22 +0900 (d11cffa)
+++ logalimacs.el    2012-08-22 00:29:14 +0900 (2ea8741)
@@ -250,6 +250,9 @@ Example:
       (async-shell-command (concat cmd " " arg) "*logalimacs*")
     (ansi-color-apply (shell-command-to-string (concat cmd " " arg " &")))))
 
+(defun loga-do-ruby (body)
+  (shell-command-to-string (concat "ruby -e " "'" body "'")))
+
 (defun loga-from-symbol-to-string (symbol)
   (replace-regexp-in-string ":" "" (symbol-name symbol)))
 
@@ -559,11 +562,18 @@ Because it escape character"
             loga-current-language-option)))))
 
 (defun loga-check-language (word)
-  (cond ((string-match "[ぁ-んァ-ン上-黑]" word)
+  (cond ((loga-japanese-p word)
          "ja")
         ((string-match "[a-zA-Z]" word)
          "en")))
 
+(defun loga-japanese-p (word)
+  (zerop
+   (string-to-number
+    (loga-do-ruby
+     (concat "puts %s/" word "/ =~ /\\p{hiragana}|\\p{katakana}|\\p{Han}/ "
+             "? 0 : 1")))))
+
 ;;;###autoload
 (defun loga-lookup-at-manually ()
   "Search word from logaling.
-------------- next part --------------
An HTML attachment was scrubbed...
Download 



More information about the logaling-commit mailing list
Back to archive index