Takeshi UME Imai
takes****@tt*****
2005年 7月 18日 (月) 22:07:27 JST
今井です。 hiki-mode.elを修正しました。修正点は以下です。 ・0.8.1対応 ・編集時にタイムスタンプが更新されるようにした ・未ログイン時に凍結ページを編集しようとした時のエラーメッセージ表示 以下、patchです。 --- hiki-mode.el.orig 2005-07-12 22:55:39.000000000 +0900 +++ hiki-mode.el 2005-07-18 21:58:46.000000000 +0900 @@ -79,6 +79,10 @@ (defvar hiki-md5hex nil) +(defvar hiki-session-id nil) + +(defvar hiki-update-timestamp nil) + (defvar hiki-edit-newpage nil) (defvar hiki-password-alist nil) @@ -149,6 +153,8 @@ (make-local-variable 'hiki-newpage) (make-local-variable 'hiki-pagename) (make-local-variable 'hiki-md5hex) + (make-local-variable 'hiki-session-id) + (make-local-variable 'hiki-update-timestamp) (setq require-final-newline t indent-tabs-mode nil) (hiki-edit-setup-keys) @@ -694,6 +700,8 @@ (let ((result (hiki-display-page pagename site-info t))) (when result (setq hiki-md5hex (cdr (assq 'md5hex result))) + (setq hiki-session-id (cdr (assq 'session-id result))) + (setq hiki-update-timestamp (cdr (assq 'update-timestamp result))) (setq hiki-pagename pagename) (setq hiki-pagetitle (or (cdr (assq 'pagetitle result)) pagename)) (setq hiki-site-info site-info) @@ -730,9 +738,11 @@ "Hiki の ソースを取得する。 '((md5hex . \"...\") + (session-id . \"...\") (body . \"...\") (pagetitle . (...)) (keyword . (...)) + (update-timestamp . t/nil) (password . t/nil)) を返す。" (let (buf start end pt result) (setq buf (hiki-http-request 'get "edit" pagename site-url)) @@ -742,9 +752,12 @@ ;; md5hex (re-search-forward "<input [^>]+name=\"md5hex\" value=\"\\([^>\"]*\\)\">" nil t nil) (setq result (cons (cons 'md5hex (match-string 1)) result)) + ;; session id + (re-search-forward "<input [^>]+name=\"session_id\" value=\"\\([^>\"]*\\)\">" nil t nil) + (setq result (cons (cons 'session-id (match-string 1)) result)) (setq pt (point)) ;; textarea - (re-search-forward "<textarea [^>]+name=\"contents\"[^>]+>" nil t nil) + (re-search-forward "<textarea [^>]+name=\"contents\"[^>]*>" nil t nil) (setq start (match-end 0)) (re-search-forward "</textarea>" nil t nil) (setq end (match-beginning 0)) @@ -753,6 +766,10 @@ (goto-char pt) (re-search-forward "<input [^>]+name=\"page_title\" [^>]+value=\"\\([^>\"]*\\)\">" nil t nil) (setq result (cons (cons 'pagetitle (hiki-replace-entity-refs (match-string 1))) result)) + ;; update timestamp? + (if (re-search-forward "<input type=\"checkbox\" name=\"update_timestamp\" value=\"on\" checked>" nil t nil) + (setq result (cons (cons 'update-timestamp t) result)) + (setq result (cons (cons 'update-timestamp nil) result))) ;; keyword (when (re-search-forward "<textarea [^>]+name=\"keyword\" [^>]+>" nil t nil) (setq start (match-end 0)) @@ -785,7 +802,9 @@ (add-to-list 'post-data (cons "page_title" pagetitle)) (add-to-list 'post-data (cons "keyword" (or keywords ""))) (add-to-list 'post-data (cons "md5hex" hiki-md5hex)) - (add-to-list 'post-data (cons "password" password)) + (add-to-list 'post-data (cons "session_id" hiki-session-id)) + (if (not (null hiki-update-timestamp)) + (add-to-list 'post-data (cons "update_timestamp" "on"))) (if (not (null hiki-freeze)) (add-to-list 'post-data (cons "freeze" "on"))) (add-to-list 'post-data (cons "contents" contents)) @@ -1064,11 +1083,20 @@ buf) ((equal code "302") buf) + ((equal code "404") + (cons code (hiki-get-error-message buf))) (t (cons code desc))))))))) (defun hiki-http-cookie-expired () (setq hiki-http-cookie nil)) +(defun hiki-get-error-message (buf) + (set-buffer buf) + (re-search-forward "<h1 class=\"header\">Error</h1>" nil t nil) + (goto-char (match-end 0)) + (re-search-forward "<div>\\([^<]+\\)</div>" nil t nil) + (match-string 1)) + (provide 'hiki-mode) ;;; hiki-mode.el ends here