2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
3 ;;;; kw-cheating-section.
\r
5 ;;hatena-kw-cheating ¤ò»È¤¦¾ì¹ç¡£`hatena-tools.pl' ¤Î¤¢¤ë¥Ç¥£¥ì¥¯¥È¥ê¡£
\r
6 ;;hatena-mode.el ¤ÈƱ¤¸¡£
\r
7 (defvar hatena-plugin-directory nil)
\r
9 (defconst hatena-kw-if nil
\r
10 "¥Ç¥Õ¥©¥ë¥È¤Ç kw-cheating(¾¿Í¤ÎÆüµ¤Îή¤·Æɤß) ¤ò¤¹¤ë¤«¤É¤¦¤«")
\r
12 (defvar hatena-kw-list-buf nil)
\r
13 (defvar hatena-kw-cheating-buf nil)
\r
14 (defvar hatena-edit-buf nil)
\r
16 (defvar hatena-kw-process nil
\r
19 (defun hatena-kw-init()
\r
21 ;;¤Þ¤ºÁë¤ò°ì¤Ä¤Ë¥ê¥»¥Ã¥È¤·¤Æ¤«¤é¡¢Æó¤Ä¤Ë³ä¤ë¡£
\r
22 ;;¤³¤¦¤¹¤ë¤È¡¢¤¤¤Ä `M-x hatena' ¤·¤Æ¤âÁ뤬Æó¤Ä¤¢¤ë¾õ¶·¤Ë¤Ê¤ë¡£
\r
23 (delete-other-windows)
\r
24 (setq hatena-edit-buf (current-buffer))
\r
25 ;;hatena-edit-wdw Æüµ¤ò½ñ¤¯¥Ð¥Ã¥Õ¥¡
\r
26 ;;hatena-keyword-cheating-wdw ¾¤ÎÆüµ¤ò¸«¤ë¥¦¥£¥ó¥É¥¦
\r
27 (setq hatena-edit-wdw (selected-window))
\r
28 (setq hatena-kw-cheating-wdw
\r
29 (split-window hatena-edit-wdw
\r
30 (floor (* (window-height)
\r
31 hatena-kw-window-split-ratio))))
\r
32 (save-selected-window
\r
33 (select-window hatena-kw-cheating-wdw)
\r
34 (setq hatena-kw-cheating-buf
\r
35 (switch-to-buffer "*hatena-keyword-cheating*"))
\r
36 (setq mode-name "Hatena kw-cheating"))
\r
38 (if hatena-kw-post-timer
\r
39 (cancel-timer hatena-kw-post-timer))
\r
40 (if hatena-kw-ruby-timer
\r
41 (cancel-timer hatena-kw-ruby-timer))
\r
42 (if hatena-kw-get-timer
\r
43 (cancel-timer hatena-kw-get-timer))
\r
44 (setq hatena-kw-post-timer
\r
47 'hatena-kw-post-func))
\r
48 (setq hatena-kw-ruby-timer
\r
49 (run-at-time (/ hatena-kw-repeat 4)
\r
51 'hatena-kw-ruby-func))
\r
52 (setq hatena-kw-get-timer
\r
53 (run-at-time (/ hatena-kw-repeat 2);; get ¤Ï post ¤è¤ê¾¯¤·Ã٤餻¤ë
\r
55 'hatena-kw-get-func))
\r
56 ;; ¤Ï¤Æ¤Ê¤Ë¥¡¼¥ï¡¼¥É¤òÌ䤤¹ç¤ï¤»¤ë¤¿¤á¤Î¥Ú¡¼¥¸¤òºî¤ë
\r
57 (hatena-kw-submit hatena-kw-temp-diary t)
\r
58 (message (concat "creating diary on " hatena-url "for kw-cheating"))
\r
61 (defun hatena-kw-final()
\r
63 (if hatena-kw-post-timer
\r
64 (cancel-timer hatena-kw-post-timer))
\r
65 (if hatena-kw-ruby-timer
\r
66 (cancel-timer hatena-kw-ruby-timer))
\r
67 (if hatena-kw-get-timer
\r
68 (cancel-timer hatena-kw-get-timer)))
\r
70 (defun hatena-kw-post-func()
\r
71 "`hatena-kw-temp-diary' ¤ËÈóƱ´ü¥Ý¥¹¥È. "
\r
72 ; (if (string-match "Hatena" mode-name)
\r
74 (hatena-kw-submit hatena-kw-temp-diary))
\r
75 ; (cancel-timer hatena-kw-post-timer));; hatena-diary-mode ¤Ç¤Ê¤±¤ì¤Ð¡¢Ä¾¤Á¤ËÄä»ß¤¹¤ë¡£
\r
78 (defun hatena-kw-get-func()
\r
79 "ruby ¤Î output ¤ò hatena-kw-cheating-buf ¤Ëɽ¼¨¤¹¤ë¡£"
\r
80 ; (if (string-match "Hatena" mode-name)
\r
82 (with-current-buffer (current-buffer)
\r
83 (set-buffer hatena-kw-cheating-buf)
\r
84 (delete-region (point-min) (point-max)) ;;Á´Éô¾Ã¤·¤Æ
\r
85 ;;from insert-file-contents-as-coding-system
\r
86 (let ((coding-system-for-read 'euc-jp)
\r
88 (insert-file-contents hatena-kw-result-file))
\r
90 (goto-char (point-min))
\r
91 (while (re-search-forward "<[^>]+>" nil t)
\r
92 (replace-match "" nil nil))
\r
93 (goto-char (point-min))
\r
94 (while (re-search-forward "\n\t+" nil t)
\r
95 (replace-match "\n" nil nil))
\r
96 (goto-char (point-min))
\r
97 (while (re-search-forward "\n+" nil t)
\r
98 (replace-match "\n" nil nil))
\r
102 ; (cancel-timer hatena-kw-get-timer) ;; hatena-diary-mode ¤Ç¤Ê¤±¤ì¤Ð¡¢Ä¾¤Á¤ËÄä»ß¤¹¤ë¡£
\r
103 ; (message "Hatena get-timer cancelled"))
\r
106 (defvar hatena-kw-process nil)
\r
107 (defun hatena-kw-perl-func(today)
\r
108 " hatena-tools.pl ¤Ë½èÍý¤òÅϤ¹¡£ "
\r
109 (start-process "hatena-kw-process"
\r
112 (concat hatena-plugin-directory "hatena-tools.pl")
\r
113 (concat hatena-directory today)
\r
119 ;(hatena-kw-perl-func "20051016")
\r
122 (defun hatena-current-second(number)
\r
123 "¸½ºß¤Þ¤Ç¤ÎÉÿô¤òÊÖ¤¹¡£emacs ¤Ç¤ÏÀ°¿ô¤¬¥±¥¿°î¤ì¤¹¤ë¤Î¤Ç¡¢ÉâÆ°¾®¿ôÅÀ¤Ç"
\r
124 (let* ((ct (current-time))
\r
125 (high (float (car ct)))
\r
126 (low (float (car (cdr ct))))
\r
128 (setq str (format "%f"(+
\r
129 (+ (* high (lsh 2 15)) low)
\r
131 (substring str 0 10) ;;
\r