--- pukiwiki-mode.el.old 2004-10-07 15:19:28.000000000 +0900 +++ pukiwiki-mode.el 2004-10-07 16:00:19.000000000 +0900 @@ -3267,46 +3267,62 @@ (goto-char (point-min)) (setq pname nil) (while (re-search-forward - "^#pcomment\\((\\([^)]*\\)reply\\([^)]*\\))\\)*$" nil t) - (let ((options (concat (match-string 2) (match-string 3))) - option pname below) - (while (string-match "\\([^,]*\\) *, *\\(.*\\)" options) - (setq option (match-string 1 options)) - (setq options (match-string 2 options)) + "^#pcomment\\((\\([^)]*\\))\\)*$" nil t) + (let ((options (match-string 2)) + option pname below reply pname-invalid match-flag) + (while (or (setq match-flag + (string-match "\\([^,]*\\) *, *\\(.*\\)" options)) + (not (string= "" options))) + (if match-flag + (progn + (setq option (match-string 1 options)) + (setq options (match-string 2 options))) + (setq option options) + (setq 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) - ;; 1.3 系の BracketName - (concat "[[" "コメント/" - (match-string 1 pukiwiki-pagename) "]]") - (concat "コメント/" pukiwiki-pagename)))) - - (message "Inserting comment...") - (setq comment - (pukiwiki-fetch-source-in-order - 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)))))) + (cond + ((string= "reply" option) + (setq reply t)) + ((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 + (if (string-match "\\[\\[\\(.+\\)\\]\\]" + pukiwiki-pagename) + ;; 1.3 系の BracketName + (concat "[[" "コメント/" + (match-string 1 pukiwiki-pagename) "]]") + (concat "コメント/" pukiwiki-pagename)))) + + (message "Inserting comment...") + (setq comment + (pukiwiki-fetch-source-in-order + 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) + ) + ))))) (message "Inserting comment...done!")) ;; comment form に対応。 @@ -5245,22 +5261,23 @@ (save-excursion ;; 直前の空き bracket. (goto-char pos1) - (when (> (point) (point-min)) ; バッファ先頭ならもう進めない。 + (when (> (point) (point-min)) ; バッファ先頭ならもう進めない。 (forward-char -1)) (while (= (char-after) ?\[) (delete-char 1) (setq count1 (1+ count1)) - (when (> (point) (point-min)) ; バッファ先頭ならもう進めない。 + (when (> (point) (point-min)) ; バッファ先頭ならもう進めない。 (forward-char -1))) ;; 直後の閉じ bracket. (setq pos2 (- pos2 count1)) (goto-char pos2) - (catch 'reaching-point-max - (while (= (char-after) ?\]) - (delete-char 1) - (setq count2 (1+ count2)) - (when (>= (point) (point-max)) ; バッファ末尾になったら抜ける。 - (throw 'reaching-point-max t)))) + (unless (= (point) (point-max)) ; バッファ末尾なら削除できない。 + (catch 'reaching-point-max + (while (= (char-after) ?\]) + (delete-char 1) + (setq count2 (1+ count2)) + (when (>= (point) (point-max)) ; バッファ末尾になったら抜ける。 + (throw 'reaching-point-max t))))) (setq pos2 (- pos2 count2)) (cons count1 count2))) (cons 0 0)))