forked from austin-----/weibo.emacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
weibo-status-comment.el
72 lines (59 loc) · 2.81 KB
/
weibo-status-comment.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
;; Copyright (C) 2011 Austin<[email protected]>
;; This program is free software: you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, either version 3 of
;; the License, or (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(defconst weibo-timeline-status-comment-buffer-name "*weibo-status-comment*")
(defconst weibo-api-status-comments-timeline "comments/show")
(defun weibo-pull-status-comments (data parse-func new status)
(let* ((id (and status (weibo-status-id status)))
(param (format "?id=%s" id)))
(with-temp-message "获取微博评论..."
(weibo-get-data weibo-api-status-comments-timeline
parse-func param t t))))
(defun weibo-status-comments-pretty-printer (comment &optional p)
(weibo-insert-comment comment nil))
(defun weibo-status-comments-header (status)
(with-temp-buffer
(setq fill-column 70)
(set (make-local-variable 'fill-nobreak-predicate) 'weibo-timeline-name-nobreak-p)
(insert "\n")
(weibo-insert-status status nil)
(buffer-string)))
(defun weibo-comment-status-comments (comment status)
(let ((id (and status (weibo-status-id status))))
(weibo-create-post "" "评论微博" nil 'weibo-send-comment id)))
(defun weibo-reply-status-comments (comment status)
(when comment
(let ((cid (weibo-comment-id comment))
(id (weibo-status-id (weibo-comment-status comment)))
(user_name (weibo-user-screen_name (weibo-comment-user comment))))
(weibo-create-post (format "回复@%s:" user_name) "回复评论" nil 'weibo-send-reply cid id))))
(defun weibo-status-comments-timeline-provider (status)
(make-weibo-timeline-provider
:key nil
:tag 'comments
:name "察看微博"
:make-function 'weibo-make-comment
:pretty-printer-function 'weibo-status-comments-pretty-printer
:pull-function 'weibo-pull-status-comments
:post-function 'weibo-post-status
:look-function nil
:retweet-function nil
:comment-function 'weibo-comment-status-comments
:reply-function 'weibo-reply-status-comments
:header-function 'weibo-status-comments-header
:data status))
(defun weibo-status-comment-buffer (provider)
(switch-to-buffer (get-buffer-create weibo-timeline-status-comment-buffer-name))
(setq weibo-timeline-current-provider provider)
(unless (eq major-mode 'weibo-timeline-mode)
(weibo-timeline-mode))
(weibo-timeline-refresh))
(provide 'weibo-status-comment)