--- pukiwiki-mode.el.old 2004-10-08 08:28:46.000000000 +0900 +++ pukiwiki-mode.el 2004-10-09 10:33:18.000000000 +0900 @@ -1141,7 +1141,7 @@ (defun pukiwiki-view-setup-keys () "Set up keymap for pukiwiki-edit-mode. If you want to set up your own key bindings, use `pukiwiki-edit-mode-hook'." - (local-set-key "q" 'pukiwiki-diff-exit) + (local-set-key "q" 'pukiwiki-view-exit) (local-set-key "b" 'scroll-down) (local-set-key " " 'scroll-up) (local-set-key "B" 'pukiwiki-view-backward-page) @@ -1157,6 +1157,17 @@ (local-set-key "s" 'pukiwiki-view-local-style-set) ) +(defun pukiwiki-view-exit () + "現在ページを破棄してインデックスを更新する。" + (interactive) + (pukiwiki-diff-exit) + + (let ((pos (point)) + (top (window-start))) + (pukiwiki-index pukiwiki-site-info nil pukiwiki-pagename) + (goto-char pos) + (set-window-start (selected-window) top))) + (defun pukiwiki-view-edit-current-page () "現在行のページを編集する。" (interactive) @@ -1224,7 +1235,9 @@ (pukiwiki-index-highlight-off-current-line) ;; highlighi する region を特定する。 (setq start (line-beginning-position)) - (setq end (1+ (line-end-position))) + (setq end (if (= (line-end-position) (point-max)) + (line-end-position) + (1+ (line-end-position)))) ;; overlay set. (setq ovr-temp (make-overlay start end)) @@ -3074,7 +3087,8 @@ (end (or region-end (1+ (point)))) (end-marker (make-marker))) - (if str + (if (and (not (null str)) + (not (string= "" str))) (progn (set-marker end-marker end) (insert str) @@ -3164,6 +3178,7 @@ (goto-char (point-min)) (goto-char (point-max))) + ;; 抽出するポイントを、最上位のコメントアウトを数え上げて検索。 (catch 'count-finish (while (if below (re-search-forward "^-[^-]" nil t) @@ -3173,6 +3188,7 @@ (throw 'count-finish t)))) (setq delete-point (line-beginning-position)) + ;; 向きに合わせて不要なコメントを削除。 (if below (when (not (= (point-max) delete-point)) (delete-region delete-point (point-max))) @@ -3278,25 +3294,27 @@ (progn (setq option (match-string 1 options)) (setq options (match-string 2 options))) - (setq option options) + (setq option (or options "")) (setq options "")) - (if option () (setq option "reply")) ;; #pcomment 時の default (when (and (not (string= "" option)) + ;; 今のところ noname, nodate, above は無視。 (not (string= "noname" option)) (not (string= "nodate" option)) (not (string= "above" option))) (cond - ((string= "reply" option) + ((string= "reply" option) ; リプライ可能 (setq reply t)) - ((string= "below" option) + ((string= "below" option) ; 上に向かって新しい順に並べる。 (setq below t)) ((string-match "^[0-9]+$" option) (setq pukiwiki-view-comment-expansion-count (string-to-number option))) (t ; 何れでも無ければページ名と判断。 (if (or pname (string-match "\"#&<>" option)) + ;; 指定できない文字があった。 (setq pname-invalid t) (setq pname option)))))) + (unless pname-invalid (unless pname (setq pname @@ -3313,20 +3331,54 @@ pname pukiwiki-site-info nil)) (forward-line 1) - (if (cdr (assoc 'body comment)) - (pukiwiki-insert-comment-str - ;; 展開するコメントを、指定された数に絞って挿入する。 - (pukiwiki-insert-comment-str-pull-out-line - (cdr (assoc 'body comment)) below))) - - ;; 2004.09.20 reply 対象のコメントを選択可能に。 - (pukiwiki-view-comment-form-pcomment-reformat) - - (pukiwiki-replace-entity-refs) - ) - ))))) + + ;; コメントの挿入。 + (let ((pos (point)) exist) + ;; コメントを整形して挿入。 + (if (cdr (assoc 'body comment)) + (pukiwiki-insert-comment-str + ;; 展開するコメントを、指定された数に絞って挿入する。 + (pukiwiki-insert-comment-str-pull-out-line + (cdr (assoc 'body comment)) below))) + + ;; point が動いていたら、コメントが存在する。 + (setq exist (not (= pos (point)))) + ;; 挿入コメントのアナウンスを表示。 + (save-excursion + (goto-char pos) + (pukiwiki-insert-comment-announce + pname pukiwiki-view-comment-expansion-count exist))) + + ;; reply 対象のコメントを選択可能にする。 + (when reply (pukiwiki-view-comment-form-pcomment-reformat)) + + (pukiwiki-replace-entity-refs))))))) (message "Inserting comment...done!")) +(defun pukiwiki-insert-comment-announce (page-name + display-count-str comment-exist) + (let ((name page-name) + (count-str display-count-str) + (exist comment-exist)) + + ;; 表示件数のアナウンス挿入。 + (insert + (if exist + (concat "最新の" (number-to-string count-str) "件を表示しています。") + (concat "コメントはありません。"))) + + ;; コメントページへのリンクを挿入。 + (let ((start (point)) end) + (if exist + (insert "コメントページを参照") + (insert name)) + (setq end (point)) + (insert "\n\n") + + ;; set property and overlay. + (pukiwiki-insert-anchor-subr 'pagename name + 'pukiwiki-view-anchor-face start end)))) + ;; comment form に対応。 (defcustom pukiwiki-view-form-text-input-style 'form "*comment form のテキスト入力項目の表示、入力形式。"