--- pukiwiki-mode.el.download-041006-3 2004-10-06 13:00:40.000000000 +0900 +++ pukiwiki-mode.el 2004-10-06 17:51:43.000000000 +0900 @@ -3151,6 +3151,33 @@ nil (point-min) (point-max))) (widen)) +(defun pukiwiki-insert-comment-str-pull-out-line (str &optional below) + (let ((count (if below + (1+ pukiwiki-view-comment-expansion-count) + pukiwiki-view-comment-expansion-count)) + delete-point) + (with-temp-buffer + (insert str) + (if below + (goto-char (point-min)) + (goto-char (point-max))) + + (catch 'count-finish + (while (if below + (re-search-forward "^-[^-]" nil t) + (re-search-backward "^-[^-]" nil t)) + (setq count (1- count)) + (when (< count 1) + (throw 'count-finish t)))) + (setq delete-point (line-beginning-position)) + + (if below + (when (not (= (point-max) delete-point)) + (delete-region delete-point (point-max))) + (when (not (= (point-min) delete-point)) + (delete-region (point-min) delete-point))) + (buffer-substring (point-min) (point-max))))) + (defun pukiwiki-replace-comment (regexp start end) "コメントの書式を変換する。" @@ -3222,9 +3249,17 @@ (widen) (point)) +(defvar pukiwiki-view-comment-expansion-count-default 10 + "`#pcomment' plugin で展開するコメント数のデフォルト値。") + +(defvar pukiwiki-view-comment-expansion-count 10 + "`#pcomment' plugin で展開するコメント数。") + (defun pukiwiki-insert-comment () "pcomment によるコメントを挿入する" (let ((comment nil) reply-option) + (setq pukiwiki-view-comment-expansion-count + pukiwiki-view-comment-expansion-count-default) (save-excursion (save-current-buffer (goto-char (point-min)) @@ -3232,19 +3267,20 @@ (while (re-search-forward "^#pcomment\\((\\([^)]*\\)reply\\([^)]*\\))\\)*$" nil t) (let ((options (concat (match-string 2) (match-string 3))) - option pname) - (catch 'match - (while (string-match "\\([^,]*\\) *, *\\(.*\\)" options) - (setq option (match-string 1 options)) - (setq options (match-string 2 options)) - (when (and (not (string= "" option)) - (not (string= "noname" option)) - (not (string= "nodate" option)) - (not (string= "above" option)) - (not (string= "below" option)) - (not (string-match "^[0-9]+$" option))) - (setq pname option) - (throw 'match t)))) + option pname below) + (while (string-match "\\([^,]*\\) *, *\\(.*\\)" options) + (setq option (match-string 1 options)) + (setq options (match-string 2 options)) + (when (and (not (string= "" option)) + (not (string= "noname" option)) + (not (string= "nodate" option)) + (not (string= "above" option))) + (if (string= "below" option) + (setq below t) + (if (string-match "^[0-9]+$" option) + (setq pukiwiki-view-comment-expansion-count + (string-to-number option)) + (setq pname option))))) (unless pname (setq pname (if (string-match "\\[\\[\\(.+\\)\\]\\]" pukiwiki-pagename) @@ -3260,7 +3296,11 @@ pukiwiki-site-info nil)) (forward-line 1) (if (cdr (assoc 'body comment)) - (pukiwiki-insert-comment-str (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) @@ -3589,7 +3629,7 @@ ((string-match "p*comment" plugin) (add-to-list 'post (assoc "msg" result-list)) (if (assoc "reply" result-list) - (setq order (1- (cdr (assoc "reply" result-list)))) + (setq order (cdr (assoc "reply" result-list))) (setq order (car (rassoc "0" (car (cdr (assoc "reply" post))))))) (when (string= plugin "pcomment") (when (assoc "reply" post) @@ -3781,10 +3821,13 @@ ;; pair が揃ったら cons にして返す。 ;; `reply' は nest させる。 (if (string= key "reply") - (progn - (setq reply-list - (cons (cons reply-count val) reply-list)) - (setq reply-count (1+ reply-count))) + ;; 名前入力の input タグにある `reply' は無視する。 + (when (not (string= val "0")) + (progn + (setq reply-list + (cons (cons + (setq reply-count (1+ reply-count)) + val) reply-list)))) (setq ret (cons (cons key val) ret))) (setq key nil val nil)))