Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support favorites timeline.

* twittering-mode.el: Support favorites timeline.
(twittering-timeline-spec-to-string): support favorites timeline
spec.
(twittering-extract-timeline-spec): likewise.
(twittering-timeline-spec-primary-p): add favorites timeline spec
is a primary timeline spec.
(twittering-call-api): support favorites timeline spec.
(twittering-read-timeline-spec-with-completion): add ":favorites"
as a candidate of completion. In addition, one can input a
username with completion for ":favorites/".
(twittering-goto-next-status): display an error message on the
oldest tweet on favorites timeline.
(twittering-goto-previous-status): likewise.
* test/test-twittering-mode.el: Add tests for favorites timeline
spec.
  • Loading branch information...
commit 138840d133dacccdfe0262569bb6112fae5a535d 1 parent d04436e
@cvmat cvmat authored
View
16 ChangeLog
@@ -60,6 +60,22 @@
original-id properties.
(twittering-enter): do not refer original-id property.
+ * twittering-mode.el: Support favorites timeline.
+ (twittering-timeline-spec-to-string): support favorites timeline
+ spec.
+ (twittering-extract-timeline-spec): likewise.
+ (twittering-timeline-spec-primary-p): add favorites timeline spec
+ is a primary timeline spec.
+ (twittering-call-api): support favorites timeline spec.
+ (twittering-read-timeline-spec-with-completion): add ":favorites"
+ as a candidate of completion. In addition, one can input a
+ username with completion for ":favorites/".
+ (twittering-goto-next-status): display an error message on the
+ oldest tweet on favorites timeline.
+ (twittering-goto-previous-status): likewise.
+ * test/test-twittering-mode.el: Add tests for favorites timeline
+ spec.
+
2011-01-09 Tadashi MATSUO <tad@mymail.twin.jp>
* twittering-mode.el: Ensure that encrypted strings are written
View
7 NEWS
@@ -102,6 +102,13 @@
from stucking on inputting characters on other buffer. The delay time is
specified by the new variable `twittering-url-request-sentinel-delay',
which is 1 second by default.
+* Support for favorites timeline.
+ ":favorites" and ":favorites/USER" are added as new timeline specs.
+ By using the latter, you can read favorites for other users.
+ Note that favorites are rendered in order of time when each tweet is
+ posted. This is because it is impossible to retrieve the time when a
+ tweet was favorited. At most, 20 favorites can be retrieved. Backward
+ retrieval of more previous favorites is not supported yet.
* ...
### Bug fixes
View
7 NEWS.ja
@@ -104,6 +104,13 @@
から行うようにしました。待ち時間は変数
`twittering-url-request-sentinel-delay'で指定できます。デフォルトの
待ち時間は1秒です。
+* 「お気に入り」に対応
+ 「お気に入り」一覧を表示するtimeline specとして":favorites"と
+ ":favorites/USER"を追加しました。":favorites/USER"で指定したユーザの
+ 「お気に入り」を見ることができます。 「お気に入り」は元々のtweetの
+ 投稿時刻の順に表示されるので注意してください。これは「お気に入り」に
+ 登録した時刻を取得する方法がないためです。また、取得できる「お気に入
+ り」は最大20件です。より過去にさかのぼっての取得は未対応です。
* ...
### バグ修正
View
10 test/test-twittering-mode.el
@@ -220,6 +220,16 @@
(test-restore-timeline-spec
":retweets_of_me" '(retweets_of_me) '(retweets_of_me))
'(t t))
+
+ (test-assert-equal
+ (test-restore-timeline-spec
+ ":favorites" '(favorites) '(favorites))
+ '(t t))
+
+ (test-assert-equal
+ (test-restore-timeline-spec
+ ":favorites/USER" '(favorites "USER") '(favorites "USER"))
+ '(t t))
)
(defun format-status (status format-str)
View
83 twittering-mode.el
@@ -2943,6 +2943,8 @@ BEG and END mean a region that had been modified."
;;;
;;; - (direct_messages): received direct messages.
;;; - (direct_messages_sent): sent direct messages.
+;;; - (favorites): favorites timeline for the current user.
+;;; - (favorites USER): favorites timeline for the specified user.
;;; - (friends): friends timeline.
;;; - (home): home timeline.
;;; - (mentions): mentions timeline.
@@ -2973,6 +2975,7 @@ BEG and END mean a region that had been modified."
;;; LISTNAME ::= /[a-zA-Z0-9_-]+/
;;; DIRECT_MESSSAGES ::= ":direct_messages"
;;; DIRECT_MESSSAGES_SENT ::= ":direct_messages_sent"
+;;; FAVORITES ::= ":favorites" | ":favorites/" USER
;;; FRIENDS ::= ":friends"
;;; HOME ::= ":home" | "~"
;;; MENTIONS ::= ":mentions"
@@ -3012,6 +3015,10 @@ If SHORTEN is non-nil, the abbreviated expression will be used."
;; simple
((eq type 'direct_messages) ":direct_messages")
((eq type 'direct_messages_sent) ":direct_messages_sent")
+ ((eq type 'favorites)
+ (if value
+ (concat ":favorites/" (car value))
+ ":favorites"))
((eq type 'friends) ":friends")
((eq type 'home) (if shorten "~" ":home"))
((eq type 'mentions) ":mentions")
@@ -3083,6 +3090,11 @@ Return cons of the spec and the rest string."
((assoc type alist)
(let ((first-spec (list (cdr (assoc type alist)))))
(cons first-spec following)))
+ ((string= type "favorites")
+ (if (string-match "^:favorites/\\([a-zA-Z0-9_-]+\\)" str)
+ (let ((rest (substring str (match-end 0))))
+ `((favorites ,(match-string 1 str)) . ,rest))
+ `((favorites) . ,following)))
((string= type "search")
(if (string-match "^:search/\\(\\(.*?[^\\]\\)??\\(\\\\\\\\\\)*\\)??/"
str)
@@ -3179,7 +3191,7 @@ Return nil if SPEC-STR is invalid as a timeline spec."
(let ((primary-spec-types
'(user list
direct_messages direct_messages_sent
- friends home mentions public replies
+ favorites friends home mentions public replies
search
retweeted_by_me retweeted_to_me retweets_of_me))
(type (car spec)))
@@ -3554,6 +3566,8 @@ retrieve-timeline -- Retrieve a timeline.
the buffer associated to the process. This is used as an argument
CLEAN-UP-SENTINEL of `twittering-send-http-request' via
`twittering-http-get'.
+ page -- (optional and valid only for favorites timeline) which page will
+ be retrieved.
get-list-index -- Retrieve list names owned by a user.
Valid key symbols in ARGS-ALIST:
username -- the username.
@@ -3620,23 +3634,28 @@ send-direct-message -- Send a direct message.
(min (max 1 number) max-number)))
(number-str (number-to-string number))
(max_id (cdr (assq 'max_id args-alist)))
+ (page (cdr (assq 'page args-alist)))
(since_id (cdr (assq 'since_id args-alist)))
(word (when (eq 'search spec-type)
(cadr spec)))
(parameters
- `(,@(when max_id `(("max_id" . ,max_id)))
- ,@(when since_id `(("since_id" . ,since_id)))
- ,@(cond
- ((eq spec-type 'search)
- `(("q" . ,word)
- ("rpp" . ,number-str)))
- ((eq spec-type 'list)
- `(("per_page" . ,number-str)))
- ((memq spec-type '(user friends mentions public))
- `(("count" . ,number-str)
- ("include_rts" . "true")))
- (t
- `(("count" . ,number-str))))))
+ (cond
+ ((eq spec-type 'favorites)
+ `(,@(when page `(("page" . ,page)))))
+ (t
+ `(,@(when max_id `(("max_id" . ,max_id)))
+ ,@(when since_id `(("since_id" . ,since_id)))
+ ,@(cond
+ ((eq spec-type 'search)
+ `(("q" . ,word)
+ ("rpp" . ,number-str)))
+ ((eq spec-type 'list)
+ `(("per_page" . ,number-str)))
+ ((memq spec-type '(user friends mentions public))
+ `(("count" . ,number-str)
+ ("include_rts" . "true")))
+ (t
+ `(("count" . ,number-str))))))))
(format (if (eq spec-type 'search)
"atom"
"xml"))
@@ -3662,6 +3681,11 @@ send-direct-message -- Send a direct message.
(let ((username (elt spec 1))
(list-name (elt spec 2)))
(twittering-api-path username "/lists/" list-name "/statuses")))
+ ((eq spec-type 'favorites)
+ (let ((user (elt spec 1)))
+ (if user
+ (twittering-api-path "favorites/" user)
+ (twittering-api-path "favorites"))))
((eq spec-type 'search)
twittering-search-api-method)
((assq spec-type simple-spec-list)
@@ -6566,13 +6590,22 @@ been initialized yet."
(let* ((dummy-hist
(append twittering-timeline-history
(twittering-get-usernames-from-timeline)
- '(":direct_messages" ":direct_messages_sent" ":friends"
+ '(":direct_messages" ":direct_messages_sent"
+ ":favorites" ":friends"
":home" ":mentions" ":public" ":replies"
":retweeted_by_me" ":retweeted_to_me" ":retweets_of_me")))
(spec-string (twittering-completing-read prompt dummy-hist
nil nil initial 'dummy-hist))
(spec-string
(cond
+ ((string-match "^:favorites/$" spec-string)
+ (let ((username
+ (twittering-read-username-with-completion
+ "whose favorites: " ""
+ (twittering-get-usernames-from-timeline))))
+ (if username
+ (concat ":favorites/" username)
+ nil)))
((string-match "^\\([a-zA-Z0-9_-]+\\)/$" spec-string)
(let* ((username (match-string 1 spec-string))
(list-index (twittering-get-list-index-sync username))
@@ -7124,10 +7157,14 @@ Return nil if no statuses are rendered."
(let ((id (or (get-text-property (point) 'id)
(let ((prev (twittering-get-previous-status-head)))
(when prev
- (get-text-property prev 'id))))))
- (when id
+ (get-text-property prev 'id)))))
+ (spec-type (car (twittering-current-timeline-spec))))
+ (cond
+ ((eq spec-type 'favorites)
+ (message "Backward retrieval of favorites is not supported yet."))
+ (id
(message "Get more previous timeline...")
- (twittering-get-and-render-timeline nil id)))))))
+ (twittering-get-and-render-timeline nil id))))))))
(defun twittering-get-next-status-head (&optional pos)
"Search forward from POS for the nearest head of a status.
@@ -7166,10 +7203,14 @@ Otherwise, return a positive integer greater than POS."
(let ((id (or (get-text-property (point) 'id)
(let ((next (twittering-get-next-status-head)))
(when next
- (get-text-property next 'id))))))
- (when id
+ (get-text-property next 'id)))))
+ (spec-type (car (twittering-current-timeline-spec))))
+ (cond
+ ((eq spec-type 'favorites)
+ (message "Backward retrieval of favorites is not supported yet."))
+ (id
(message "Get more previous timeline...")
- (twittering-get-and-render-timeline nil id))))
+ (twittering-get-and-render-timeline nil id)))))
(t
(message "The latest status.")))))
Please sign in to comment.
Something went wrong with that request. Please try again.