author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Wed, 16 Nov 2011 17:08:05 +0200 | |
changeset 829 | 093b6699e903 |
parent 827 | 8a775af1d487 |
permissions | -rwxr-xr-x |
810
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
1 |
;;; stmcrblog-mode.el --- static micro-blogging engine from Emacs |
565
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
2 |
|
810
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
3 |
;; Copyright (C) 2011 by Oleksandr Gavenko <gavenkoa@gmail.com> |
565
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
4 |
|
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
5 |
;; You can do anything with this file without any warranty. |
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
6 |
|
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
7 |
;; Author: Oleksandr Gavenko <gavenkoa@gmail.com> |
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
8 |
;; Maintainer: Oleksandr Gavenko <gavenkoa@gmail.com> |
810
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
9 |
;; Created: 2011-11-10 |
565
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
10 |
;; Version: 0.1 |
810
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
11 |
;; Keywords: blog, microblog, blogging, gtd |
565
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
12 |
|
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
13 |
;;; Commentary: |
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
14 |
;; |
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
15 |
;; Very pure release. |
827
8a775af1d487
Depricated. Use 'jdone' mode.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
815
diff
changeset
|
16 |
;; |
8a775af1d487
Depricated. Use 'jdone' mode.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
815
diff
changeset
|
17 |
;; Depricated. Use 'jdone' mode. |
565
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
18 |
|
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
19 |
;;; Code: |
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
20 |
|
810
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
21 |
(defconst stmcrblog-major-version 0 |
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
22 |
"stmcrblog major version.") |
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
23 |
|
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
24 |
(defconst stmcrblog-minor-version 1 |
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
25 |
"stmcrblog major version.") |
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
26 |
|
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
27 |
(defun stmcrblog-version (&optional here) |
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
28 |
"Return stmcrblog version." |
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
29 |
(interactive "P") |
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
30 |
(let ( (version-string (format "stmcrblog %d.%d" stmcrblog-major-version stmcrblog-minor-version)) ) |
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
31 |
(if here |
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
32 |
(insert version-string) |
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
33 |
(if (called-interactively-p 'interactive) |
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
34 |
(message "%s" version-string) |
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
35 |
version-string)) |
565
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
36 |
)) |
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
37 |
|
811
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
38 |
(defvar stmcrblog-file "~/.stmcrblog" |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
39 |
"Blog entries storage file name.") |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
40 |
|
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
41 |
(defvar stmcrblog-after-add-entry-hook nil |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
42 |
"`stmcrblog-after-add-entry-hook' called after adding entries. |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
43 |
You can use this hook to render and publish `stmcrblog-file'.") |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
44 |
|
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
45 |
(defun stmcrblog-add-entry (msg) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
46 |
"Add post to blog. |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
47 |
Automatically set time to current value. Only first line of MSG |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
48 |
was added. |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
49 |
|
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
50 |
`stmcrblog-after-add-entry-hook' called after adding entries. You |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
51 |
can use this hook to render and publish `stmcrblog-file'." |
812
2a406d085196
Set coding system for blog storage to utf-8.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
811
diff
changeset
|
52 |
(let ( |
2a406d085196
Set coding system for blog storage to utf-8.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
811
diff
changeset
|
53 |
(coding-system-for-read 'utf-8) |
2a406d085196
Set coding system for blog storage to utf-8.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
811
diff
changeset
|
54 |
(coding-system-for-write 'utf-8) |
2a406d085196
Set coding system for blog storage to utf-8.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
811
diff
changeset
|
55 |
pos |
2a406d085196
Set coding system for blog storage to utf-8.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
811
diff
changeset
|
56 |
) |
811
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
57 |
(setq pos (string-match "\n" msg)) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
58 |
(when pos |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
59 |
(setq msg (substring msg 0 pos))) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
60 |
(save-excursion ;save-window-excursion |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
61 |
(find-file stmcrblog-file) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
62 |
(beginning-of-buffer) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
63 |
(insert |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
64 |
(format-time-string "%Y-%m-%d %H:%M" (current-time)) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
65 |
" " |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
66 |
msg |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
67 |
"\n") |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
68 |
(save-buffer) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
69 |
(kill-buffer) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
70 |
) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
71 |
(run-hooks 'stmcrblog-after-add-entry-hook) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
72 |
)) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
73 |
|
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
74 |
(defvar stmcrblog-buffer-name "*stmcrblog-entry*" |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
75 |
"`stmcrblog' buffer name for composing editing message") |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
76 |
|
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
77 |
(defun stmcrblog-post-edit (&optional msg) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
78 |
(let ( |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
79 |
(buffer (get-buffer-create stmcrblog-buffer-name)) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
80 |
(current-buffer (current-buffer)) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
81 |
) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
82 |
(switch-to-buffer buffer) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
83 |
(local-key-binding ) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
84 |
(kill-buffer buffer) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
85 |
(error "not-implemented") |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
86 |
)) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
87 |
|
813
cd42d50dcef0
Add 'autoload's for stmcrblog mode.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
812
diff
changeset
|
88 |
;;;###autoload |
811
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
89 |
(defun stmcrblog-post (&optional prefix start end) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
90 |
"Post entry. |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
91 |
Interactively, in Transient Mark mode when the mark is active, |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
92 |
operate on the contents of the region. Otherwise, open |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
93 |
`stmcrblog-buffer-name' buffer for message editing." |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
94 |
(interactive "P\nr") |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
95 |
(let ( msg ) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
96 |
(when (and (called-interactively-p 'interactive) transient-mark-mode mark-active) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
97 |
(setq msg (buffer-substring-no-properties start end)) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
98 |
) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
99 |
(if msg |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
100 |
(stmcrblog-add-entry msg) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
101 |
) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
102 |
)) |
336ca7359658
Allow post to file. Provide hook to render and publish file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
810
diff
changeset
|
103 |
|
814
91b9a35fc284
Add post current line function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
813
diff
changeset
|
104 |
;;;###autoload |
91b9a35fc284
Add post current line function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
813
diff
changeset
|
105 |
(defun stmcrblog-post-current-line (prefix) |
815 | 106 |
"Post current line. |
107 |
With prefix remove current line." |
|
814
91b9a35fc284
Add post current line function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
813
diff
changeset
|
108 |
(interactive "P") |
91b9a35fc284
Add post current line function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
813
diff
changeset
|
109 |
(stmcrblog-add-entry (buffer-substring-no-properties (line-beginning-position) (line-end-position))) |
91b9a35fc284
Add post current line function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
813
diff
changeset
|
110 |
(when prefix |
91b9a35fc284
Add post current line function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
813
diff
changeset
|
111 |
(move-beginning-of-line 1) |
91b9a35fc284
Add post current line function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
813
diff
changeset
|
112 |
(kill-line) |
91b9a35fc284
Add post current line function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
813
diff
changeset
|
113 |
) |
91b9a35fc284
Add post current line function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
813
diff
changeset
|
114 |
) |
91b9a35fc284
Add post current line function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
813
diff
changeset
|
115 |
|
810
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
116 |
(provide 'stmcrblog-mode) |
565
a9f4afeefe2a
Major mode for error logs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
117 |
|
810
4c2010d424ed
Add base 'stmcrblog' mode code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
572
diff
changeset
|
118 |
;;; stmcrblog-mode.el ends here |