forked from austin-----/weibo.emacs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweibo-post.el
More file actions
50 lines (40 loc) · 1.81 KB
/
weibo-post.el
File metadata and controls
50 lines (40 loc) · 1.81 KB
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
;; Copyright (C) 2011 Austin<austiny.cn@gmail.com>
;; 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-post-buffer-name "*weibo-update*")
(defconst weibo-post-mode-name "发表微博")
(define-derived-mode weibo-post-mode fundamental-mode weibo-post-mode-name
"Major mode for posting weibo message"
(local-set-key "\C-c\C-c" 'weibo-send-post)
(local-set-key "\C-c\C-d" 'weibo-discard-post))
(defvar weibo-post-data nil)
(defvar weibo-post-send-func nil)
(defun weibo-create-post (initial-text mode-text move-begin
post-send-func
&rest data)
(interactive)
(select-window (split-window-vertically -8))
(switch-to-buffer (generate-new-buffer weibo-post-buffer-name))
(weibo-post-mode)
(set (make-local-variable 'weibo-post-send-func) post-send-func)
(set (make-local-variable 'weibo-post-data) data)
(when mode-text (setq mode-name mode-text))
(insert (concat initial-text))
(when move-begin (goto-char (point-min))))
(defun weibo-discard-post ()
(interactive)
(weibo-kill-close-window))
(defun weibo-send-post ()
(interactive)
(when (apply weibo-post-send-func (cons (buffer-string) weibo-post-data))
(weibo-discard-post)
(weibo-timeline-update)))
(provide 'weibo-post)