松尾です。

From: "Kensuke Matsuzaki" <za...@peppermint.jp>
Subject: [twmode-users] 日本語ハッシュタグ対応
Date: 22 Aug 2011 23:58:42 +0900

> NTEmacs の 23.3.1 では内部コードが Unicode になっているおかげか
> twitter-text-js の正規表現をほぼそのまま使うことができました。
> しかし、Emacs 22.1系列の Meadow では「-」での範囲指定が出来ず、かといっ
> て展開すると数十MB単位の正規表現になってしまいます。
> 
> 何か良い方法はないでしょうか。

厳密に実装するなら、categoryを使えば良いんじゃないでしょうか。
"Categories - GNU Emacs Lisp Reference Manual"
http://www.gnu.org/software/emacs/manual/html_node/elisp/Categories.html#Categories
これなら正規表現のサイズも抑えられると思います。

ただ、そこまで厳密にする必要があるか、という気もしています。
とりあえずは[a-zA-Z0-9_-]の代わりに[[:alpha:]0-9_-]を使った実装を
試しているのですが、こちらのEmacs21,22,23(Debian,cygwin)では特に
問題なく動いているようです。
いかがでしょうか。

diff -r 3ca4ce899bf7 twittering-mode.el
--- a/twittering-mode.el        Fri Aug 26 23:12:19 2011 +0900
+++ b/twittering-mode.el        Fri Aug 26 23:20:56 2011 +0900
@@ -3480,7 +3480,7 @@
     `((home) . ,(substring str (match-end 0))))
    ((string-match (concat "^" twittering-regexp-atmark) str)
     `((replies) . ,(substring str (match-end 0))))
-   ((string-match (concat "^" twittering-regexp-hash "\\([a-zA-Z0-9_-]+\\)")
+   ((string-match (concat "^" twittering-regexp-hash "\\([[:alpha:]0-9_-]+\\)")
                  str)
     (let* ((tag (match-string 1 str))
           (rest (substring str (match-end 0))))
@@ -5915,7 +5915,7 @@
          'identity
          (list
           ;; hashtag
-          (concat regexp-hash "\\([a-zA-Z0-9_-]+\\)")
+          (concat regexp-hash "\\([[:alpha:]0-9_-]+\\)")
           ;; @USER/LIST
           (concat regexp-atmark
                   "\\(\\([a-zA-Z0-9_-]+\\)/\\([a-zA-Z0-9_-]+\\)\\)")
@@ -7299,7 +7299,7 @@
           (hashtags
            (twittering-extract-matched-substring-all
             (concat twittering-regexp-hash
-                    "\\([a-zA-Z0-9_-]+\\)")
+                    "\\([[:alpha:]0-9_-]+\\)")
             text))
           (footer
            (mapconcat (lambda (tag) (concat "#" tag))
@@ -7312,7 +7312,7 @@
             current-spec))
           (hashtag-list
            (twittering-extract-matched-substring-all
-            (concat "\\(" twittering-regexp-hash "[a-zA-Z0-9_-]+\\)")
+            (concat "\\(" twittering-regexp-hash "\\([[:alpha:]0-9_-]+\\)")
             query-string)))
       (when hashtag-list
        (let ((footer (mapconcat 'identity hashtag-list " ")))

t.coによる短縮URLを考慮した文字数カウントと一緒に、近いうちにcommit
するつもりです。

---
松尾 直志 <t...@mymail.twin.jp>

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
twmode-users mailing list
twmode-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/twmode-users

メールによる返信