--- pukiwiki-mode.el.old 2004-09-06 11:20:04.000000000 +0900 +++ pukiwiki-mode.el 2004-09-06 14:58:22.000000000 +0900 @@ -164,7 +164,7 @@ '("^[ ]*_ \\([0-9]+-[0-9]+-[0-9]+[ ]*([^)]+)[ ]*[0-9]+:[0-9]+:[0-9]+ \\[[^\r\n]+$\\)" 1 font-lock-comment-face) '("\\(^//[^\n\r]+$\\)" 1 font-lock-comment-face) '("\\(^[>]+[^\n\r]+$\\)" 1 font-lock-reference-face) - '("^\\([ ]*-+[^\n\r]+$\\)" 1 font-lock-keyword-face) + ;; '("^\\([ ]*-+[^\n\r]+$\\)" 1 font-lock-keyword-face) (cons (concat "^#\\(" (mapconcat 'identity pukiwiki-keywords "\\|") @@ -237,6 +237,17 @@ (defvar pukiwiki-search-word nil) +(defcustom pukiwiki-no-proxy-domains-list '("localhost") + "*Domain list that don't via proxy server." + :group 'pukiwiki + :type '(repeat (string :format "Domain name: %v +" :size 0))) + +(defcustom pukiwiki-process-sentinel-interval 20 + "*Sentinel time for end of process." + :group 'pukiwiki + :type '(integer :size 0)) + ;;; 汎用関数 (defun pukiwiki-mode-version () @@ -318,7 +329,7 @@ (defun pukiwiki-obsolete-check () (when pukiwiki-list (message "pukiwiki-list is OBSOLETE. Use pukiwiki-site-list.") - (sit-for 20) + (sit-for pukiwiki-process-sentinel-interval) (setq pukiwiki-site-list pukiwiki-list))) (defun pukiwiki-read-site-name (&optional string) @@ -582,7 +593,7 @@ ;; 文字コードのおかしい文字が無いか確認 (pukiwiki-check-encode-able (point-min) (point-max)) - (sit-for 20) + (sit-for pukiwiki-process-sentinel-interval) (setq password (pukiwiki-password-read (car pukiwiki-site-info) pukiwiki-pagename) freeze (if toggle (not password) (if password t))) @@ -666,7 +677,7 @@ buf contents post-data pagetitle password freeze keywords result (pbuf (current-buffer))) (message "Sending... ") - (sit-for 20) + (sit-for pukiwiki-process-sentinel-interval) (setq pagetitle pukiwiki-pagename) (setq contents (buffer-substring-no-properties (point-min) (point-max))) (add-to-list 'post-data (cons "cmd" "edit")) @@ -2658,12 +2669,12 @@ ;; 行を適当なところで折り返す (goto-char (point-min)) (while (re-search-forward - "^[^ |*->#\n\r]+[^\n\r]*$" nil t) + "^[^ |*->#~\n\r]+[^\n\r]*$" nil t) ;;(beginning-of-line) ;;(setq pt (point)) (setq pt (line-beginning-position)) (if (re-search-forward - "^[ |*->#]+[^\n\r]*$" nil t) + "^[ |*->#~]+[^\n\r]*$" nil t) ;;(setq end-pt (point)) (setq end-pt (line-beginning-position)) ;;(line-end-position)) (setq end-pt (point-max)) @@ -2722,15 +2733,15 @@ (let ((start nil) (str nil) (ov nil)) (while (re-search-forward (if pukiwiki-auto-insert - "\\([']+\\)\\([^']+\\)\\([']+\\)" - "\\([']+\\)\\([^'\n\r]+\\)\\([']+\\)") + "\\(['][']+\\)\\([^']+\\)\\(['][']+\\)" + "\\(['][']+\\)\\([^'\n\r]+\\)\\(['][']+\\)") nil t) (setq start (match-string 1)) (setq str (match-string 2)) (delete-region (match-beginning 0) (match-end 0)) (insert str) - (setq ov (make-overlay (line-beginning-position) + (setq ov (make-overlay (match-beginning 0) (point))) (if (= 2 (length start)) (overlay-put ov 'face 'bold) @@ -2806,15 +2817,59 @@ (insert " ") (setq str (- str 1))) (insert "-") - (let* ((fill-prefix " ") - (paragraph-start - "^\\($\\|[ ]*[+-]+\\)") - (paragraph-separate "^[ ]*[+- <\t\n\f]")) - (fill-region (line-beginning-position) - (line-end-position)) - ;;(fill-paragraph nil) + (let* ((fill-individual-varying-indent t) + (margin 2) + (paragraph-start "^\\($\\|[ ]*[+-]+\\)") + (paragraph-separate "^[ ]*[-+ <\t\n\f]")) + ;; filling. + (save-excursion + (re-search-forward "^[ ]*[-+ <\t\n\f]" nil t nil) + (setq fill-end-position (line-beginning-position))) + (save-excursion + ;; overlay set. + (setq ovr (make-overlay (- (point) 2) fill-end-position)) + (overlay-put ovr 'face 'font-lock-keyword-face) + (overlay-put ovr 'priority 1) + + (set-left-margin (point) fill-end-position margin) + (fill-individual-paragraphs (line-beginning-position) + fill-end-position t)) )))) +(defun pukiwiki-insert-paragraph () + "段落書式を整形する。 + +段落を現わす行頭書式文字 `~' が指定されているとき、以下の箇所に空行を挿入する。 +- 段落直前 +- 段落先頭行の直後の行が、異なる段落や書式の場合にその直前の行 + +;; 現状はこれだけで十分かと思います。" + + (goto-char (point-min)) + ;; 段落の直前には一行空行を挿入。 + (while (re-search-forward "^\\(~[ ]*\\)" nil t) + (save-excursion + (forward-line -1) + (unless (string-match + "^[\\s-]*$" + (buffer-substring (line-beginning-position) (line-end-position))) + (end-of-line) + (insert "\n")))) + ;; 段落の先頭行の次の行が字下げ、もしくは行頭書式文字なら空行を挿入。 + (goto-char (point-min)) + (while (re-search-forward "^\\(~[ ]*\\)" nil t) + (delete-region (match-beginning 0) + (match-end 0)) + (save-excursion + (forward-line 1) + (if (string-match + "^[ |*->#~]" + (buffer-substring + (line-beginning-position) (+ (line-beginning-position) 1))) + (progn + (beginning-of-line) + (insert "\n")))))) + (defun pukiwiki-delete-blank-line () (goto-char (point-min)) (while (re-search-forward @@ -2837,6 +2892,7 @@ (defun pukiwiki-mode-auto-insert () (save-excursion (pukiwiki-text-reformating) + (pukiwiki-insert-paragraph) (pukiwiki-insert-cite) (pukiwiki-insert-comment) (pukiwiki-insert-list) @@ -2922,12 +2978,6 @@ (setq pukiwiki-http-fetch-running nil)) ;; no-proxy-domain に対処。 -(defcustom pukiwiki-no-proxy-domains-list '("localhost") - "*Domain list that don't via proxy server." - :group 'pukiwiki - :type '(repeat (string :format "Domain name: %v -" :size 0))) - (defun pukiwiki-no-proxy-domain-p (url) "proxy server の指定があるときで、proxy を介さないドメインかを調べる。" (let (host domain) @@ -2974,8 +3024,10 @@ (open-network-stream (concat "*request to " server "*") buf - (if (pukiwiki-no-proxy-domain-p url) server (or http-proxy-server server)) - (if (pukiwiki-no-proxy-domain-p url) port (or http-proxy-port port))))) + (if (pukiwiki-no-proxy-domain-p url) server + (or http-proxy-server server)) + (if (pukiwiki-no-proxy-domain-p url) port + (or http-proxy-port port))))) (set-process-coding-system connection 'binary 'binary) ;;(set-process-sentinel connection 'ignore) (set-process-sentinel connection 'pukiwiki-http-fetch-sentinel) @@ -3002,7 +3054,7 @@ (while pukiwiki-http-fetch-running (unless (accept-process-output connection http-timeout) (error "HTTP fetch: Connection timeout!")) - (sit-for 20)) + (sit-for pukiwiki-process-sentinel-interval)) (delete-process connection) (goto-char (point-min)) (save-excursion @@ -3050,8 +3102,10 @@ (open-network-stream (concat "*request to " server "*") buf - (if (pukiwiki-no-proxy-domain-p url) server (or http-proxy-server server)) - (if (pukiwiki-no-proxy-domain-p url) port (or http-proxy-port port)))) + (if (pukiwiki-no-proxy-domain-p url) server + (or http-proxy-server server)) + (if (pukiwiki-no-proxy-domain-p url) port + (or http-proxy-port port)))) (set-process-coding-system connection 'binary 'binary) (set-process-sentinel connection 'pukiwiki-download-sentinel) (process-send-string @@ -3065,7 +3119,7 @@ "\r\n"))) (goto-char (point-min)) (while pukiwiki-download-running - (sit-for 20)) + (sit-for pukiwiki-process-sentinel-interval)) (delete-process connection) ) (set-buffer buf)