松尾です。

やたがわさんのsearch-mode branchに機能を追加する
パッチを書いてみました。

・0001-Add-new-timeline-spec-string-for-hashtag.patch
  「#hashtag」の形のtimeline spec
specとしては '(search "#hashtag") に変換されます。

・0002-Support-functional-alias-as-a-timeline-spec-string.patch
  functional alias
aliasに関数を指定できるようになります

(setq twittering-timeline-spec-alias
      `(("related-to" .
         ,(lambda (username)
            (if username
                (format ":search/to:%s OR from:%s OR @%s/"
                        username username username)
              ":home")))
        ))

としておくと、"$related-to(USER)"というspec stringを指定すると
":search/to:USER OR from:USER OR @USER/"を指定したものとして
解釈されます。

この例はUSERが自分がfollowしていない人としている会話も見られる
timelineです。
手元では更に
("r" . ,(lambda (username) (format "$related-to(%s)" username)))
も追加して"$r(USER)"で使えるようにしてたりします。

どうでしょうか。

---
松尾 直志 <t...@mymail.twin.jp>
>From f8eb736e0b8f9e8cf92d57325213b70bc159ea2a Mon Sep 17 00:00:00 2001
From: Tadashi MATSUO <t...@mymail.twin.jp>
Date: Fri, 29 Jan 2010 00:54:21 +0900
Subject: [PATCH] Add new timeline spec string for hashtag.

* twittering-mode.el (twittering-extract-timeline-spec): add new
timeline spec string for hashtag.
---
 ChangeLog          |    5 +++++
 twittering-mode.el |    5 +++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f104759..658ae65 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,11 @@
        is non-nil to avoid error "Non-X frame used" under Emacs which is
        using a text-only terminal.
 
+2010-01-25  Tadashi MATSUO  <t...@mymail.twin.jp>
+
+       * twittering-mode.el (twittering-extract-timeline-spec): add new
+       timeline spec string for hashtag.
+
 2010-01-23  Satoshi Yatagawa  <yata_git...@y.haun.org>
 
        * twittering-mode.el (twittering-json-to-status-datum): Don't
diff --git a/twittering-mode.el b/twittering-mode.el
index 0c4c197..dfcd17f 100755
--- a/twittering-mode.el
+++ b/twittering-mode.el
@@ -672,6 +672,11 @@ Return cons of the spec and the rest string."
     `((home) . ,(substring str (match-end 0))))
    ((string-match "^@" str)
     `((replies) . ,(substring str (match-end 0))))
+   ((string-match "^#\\([a-zA-Z0-9_-]+\\)" str)
+    (let* ((tag (match-string 1 str))
+          (query (concat "#" tag))
+          (rest (substring str (match-end 0))))
+      `((search ,query) . ,rest)))
    ((string-match "^:\\([a-z_-]+\\)" str)
     (let ((type (match-string 1 str))
          (following (substring str (match-end 0)))
-- 
1.5.6.5

>From 1443a9cda429bc84d69f0a9f39051759ed186b9a Mon Sep 17 00:00:00 2001
From: Tadashi MATSUO <t...@mymail.twin.jp>
Date: Fri, 29 Jan 2010 00:59:27 +0900
Subject: [PATCH] Support functional alias as a timeline spec string.

* twittering-mode.el (twittering-extract-timeline-spec): support
functional alias.
---
 ChangeLog          |    5 +++++
 twittering-mode.el |   42 ++++++++++++++++++++++++++++++------------
 2 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 658ae65..542bed1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -55,6 +55,11 @@
        * twittering-mode.el (twittering-format-status): fix an incorrect
        index on filling text for the specifier "%t".
 
+2010-01-24  Tadashi MATSUO  <t...@mymail.twin.jp>
+
+       * twittering-mode.el (twittering-extract-timeline-spec): support
+       functional alias.
+
 2010-01-23  Tadashi MATSUO  <t...@mymail.twin.jp>
 
        * twittering-mode.el (twittering-timeline-spec-to-host-method):
diff --git a/twittering-mode.el b/twittering-mode.el
index dfcd17f..fc7d881 100755
--- a/twittering-mode.el
+++ b/twittering-mode.el
@@ -131,13 +131,24 @@ dangerous.")
 
 (defvar twittering-timeline-spec-alias nil
   "*Alist for aliases of timeline spec.
-Each element is (NAME . SPEC-STRING), where NAME and SPEC-STRING are
-strings. The alias can be referred as \"$NAME\" in timeline spec
-string.
+Each element is (NAME . SPEC-STRING), where NAME is a string and
+SPEC-STRING is a string or a function that returns a timeline spec string.
+
+The alias can be referred as \"$NAME\" or \"$NAME(ARG)\" in timeline spec
+string. If SPEC-STRING is a string, ARG is simly ignored.
+If SPEC-STRING is a function, it is called with a string argument.
+For the style \"$NAME\", the function is called with nil.
+For the style \"$NAME(ARG)\", the function is called with a string ARG.
 
 For example, if you specify
  '((\"FRIENDS\" . \"(USER1+USER2+USER3)\")
-   (\"to_me\" . \"(:mentions+:retweets_of_me+:direct-messages)\")),
+   (\"to_me\" . \"(:mentions+:retweets_of_me+:direct-messages)\")
+   (\"related-to\" .
+            ,(lambda (username)
+               (if username
+                   (format \":search/to:%s OR from:%s OR @%s/\"
+                           username username username)
+                 \":home\")))),
 then you can use \"$to_me\" as
 \"(:mentions+:retweets_of_me+:direct-messages)\".")
 
@@ -717,17 +728,24 @@ Return cons of the spec and the rest string."
          nil))
        (t
        nil))))
-   ((string-match "^\\$\\([a-zA-Z0-9_-]+\\)" str)
+   ((string-match "^\\$\\([a-zA-Z0-9_-]+\\)\\(?:(\\([^)]*\\))\\)?" str)
     (let* ((name (match-string 1 str))
-          (rest (substring str (match-end 1)))
-          (value (cdr-safe (assoc name twittering-timeline-spec-alias))))
+          (rest (substring str (match-end 0)))
+          (value (cdr-safe (assoc name twittering-timeline-spec-alias)))
+          (arg (match-string 2 str)))
       (if (member name unresolved-aliases)
          (error "Alias \"%s\" includes a recursive reference" name)
-       (if value
-           (twittering-extract-timeline-spec
-            (concat value rest)
-            (cons name unresolved-aliases))
-         (error "Alias \"%s\" is undefined" name)))))
+       (cond
+        ((stringp value)
+         (twittering-extract-timeline-spec
+          (concat value rest)
+          (cons name unresolved-aliases)))
+        ((functionp value)
+         (twittering-extract-timeline-spec
+          (funcall value arg)
+          (cons name unresolved-aliases)))
+        (t
+         (error "Alias \"%s\" is undefined" name))))))
    ((string-match "^(" str)
     (let* ((rest (concat "+" (substring str (match-end 0))))
           (result '()))
-- 
1.5.6.5

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
twmode-users mailing list
twmode-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/twmode-users

メールによる返信