Mercurial > hg > xemacs-beta
comparison lisp/mu/mu-cite.el @ 16:0293115a14e9 r19-15b91
Import from CVS: tag r19-15b91
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:49:20 +0200 |
parents | 49a24b4fd526 |
children | d95e72db5c07 |
comparison
equal
deleted
inserted
replaced
15:ad457d5f7d04 | 16:0293115a14e9 |
---|---|
1 ;;; mu-cite.el --- yet another citation tool for GNU Emacs | 1 ;;; mu-cite.el --- yet another citation tool for GNU Emacs |
2 | 2 |
3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp> | 5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp> |
6 ;; MINOURA Makoto <minoura@netlaputa.or.jp> | 6 ;; MINOURA Makoto <minoura@netlaputa.or.jp> |
7 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp> | 7 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp> |
8 ;; Maintainer: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp> | 8 ;; Maintainer: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp> |
9 ;; Version: $Revision: 1.3 $ | 9 ;; Version: $Revision: 1.4 $ |
10 ;; Keywords: mail, news, citation | 10 ;; Keywords: mail, news, citation |
11 | 11 |
12 ;; This file is part of tl (Tiny Library). | 12 ;; This file is part of MU (Message Utilities). |
13 | 13 |
14 ;; This program is free software; you can redistribute it and/or | 14 ;; This program is free software; you can redistribute it and/or |
15 ;; modify it under the terms of the GNU General Public License as | 15 ;; modify it under the terms of the GNU General Public License as |
16 ;; published by the Free Software Foundation; either version 2, or (at | 16 ;; published by the Free Software Foundation; either version 2, or (at |
17 ;; your option) any later version. | 17 ;; your option) any later version. |
52 | 52 |
53 ;;; @ version | 53 ;;; @ version |
54 ;;; | 54 ;;; |
55 | 55 |
56 (defconst mu-cite/RCS-ID | 56 (defconst mu-cite/RCS-ID |
57 "$Id: mu-cite.el,v 1.3 1996/12/29 00:15:00 steve Exp $") | 57 "$Id: mu-cite.el,v 1.4 1997/02/02 05:05:45 steve Exp $") |
58 (defconst mu-cite/version (get-version-string mu-cite/RCS-ID)) | 58 (defconst mu-cite/version (get-version-string mu-cite/RCS-ID)) |
59 | 59 |
60 | 60 |
61 ;;; @ formats | 61 ;;; @ formats |
62 ;;; | 62 ;;; |
388 )) | 388 )) |
389 | 389 |
390 | 390 |
391 ;;; @ message editing utilities | 391 ;;; @ message editing utilities |
392 ;;; | 392 ;;; |
393 | 393 |
394 (defvar cited-prefix-regexp "^[^ \t>]*[>|]+[ \t#]*" | 394 (defvar citation-mark-chars ">}|" |
395 "*Regexp to match the citation prefix.") | 395 "*String of characters for citation delimiter. [mu-cite.el]") |
396 | |
397 (defun detect-paragraph-cited-prefix () | |
398 (save-excursion | |
399 (goto-char (point-min)) | |
400 (let ((i 0) | |
401 (prefix | |
402 (buffer-substring | |
403 (progn (beginning-of-line)(point)) | |
404 (progn (end-of-line)(point)) | |
405 )) | |
406 str ret) | |
407 (while (and (= (forward-line) 0) | |
408 (setq str (buffer-substring | |
409 (progn (beginning-of-line)(point)) | |
410 (progn (end-of-line)(point)))) | |
411 (setq ret (string-compare-from-top prefix str)) | |
412 ) | |
413 (setq prefix | |
414 (if (stringp ret) | |
415 ret | |
416 (second ret))) | |
417 (setq i (1+ i)) | |
418 ) | |
419 (cond ((> i 1) prefix) | |
420 ((> i 0) | |
421 (goto-char (point-min)) | |
422 (save-restriction | |
423 (narrow-to-region (point) | |
424 (+ (point)(length prefix))) | |
425 (goto-char (point-max)) | |
426 (if (re-search-backward | |
427 (concat "[" citation-mark-chars "]") nil t) | |
428 (progn | |
429 (goto-char (match-end 0)) | |
430 (if (looking-at "[ \t]+") | |
431 (goto-char (match-end 0)) | |
432 ) | |
433 (buffer-substring (point-min)(point)) | |
434 ) | |
435 prefix))) | |
436 ((progn | |
437 (goto-char (point-max)) | |
438 (re-search-backward (concat "[" citation-mark-chars "]") | |
439 nil t) | |
440 ) | |
441 (goto-char (match-end 0)) | |
442 (if (looking-at "[ \t]+") | |
443 (goto-char (match-end 0)) | |
444 ) | |
445 (buffer-substring (point-min)(point)) | |
446 ) | |
447 (t "")) | |
448 ))) | |
396 | 449 |
397 (defun fill-cited-region (beg end) | 450 (defun fill-cited-region (beg end) |
398 (interactive "*r") | 451 (interactive "*r") |
399 (save-excursion | 452 (save-excursion |
400 (save-restriction | 453 (save-restriction |
401 (goto-char end) | 454 (goto-char end) |
402 (while (not (eolp)) | 455 (and (search-backward "\n" nil t) |
403 (backward-char) | 456 (setq end (match-end 0)) |
404 ) | 457 ) |
405 (setq end (point)) | |
406 (narrow-to-region beg end) | 458 (narrow-to-region beg end) |
407 (goto-char (point-min)) | 459 (let* ((fill-prefix (detect-paragraph-cited-prefix)) |
408 (let* ((fill-prefix | 460 (pat (concat fill-prefix "\n")) |
409 (let* ((str1 (buffer-substring | |
410 (progn (beginning-of-line)(point)) | |
411 (progn (end-of-line)(point)) | |
412 )) | |
413 (str2 (let ((p0 (point))) | |
414 (forward-line) | |
415 (if (> (count-lines p0 (point)) 0) | |
416 (buffer-substring | |
417 (progn (beginning-of-line)(point)) | |
418 (progn (end-of-line)(point)) | |
419 )))) | |
420 (ret (string-compare-from-top str1 str2)) | |
421 ) | |
422 (if ret | |
423 (let ((prefix (nth 1 ret))) | |
424 (if (string-match cited-prefix-regexp prefix) | |
425 (substring prefix 0 (match-end 0)) | |
426 prefix)) | |
427 (goto-char (point-min)) | |
428 (if (re-search-forward cited-prefix-regexp nil t) | |
429 (buffer-substring (match-beginning 0) (match-end 0)) | |
430 )))) | |
431 (pat (concat "\n" fill-prefix)) | |
432 ) | 461 ) |
433 (goto-char (point-min)) | 462 (goto-char (point-min)) |
434 (while (search-forward pat nil t) | 463 (while (search-forward pat nil t) |
435 (let ((b (match-beginning 0)) | 464 (let ((b (match-beginning 0)) |
436 (e (match-end 0)) | 465 (e (match-end 0)) |
447 )) | 476 )) |
448 ) | 477 ) |
449 (goto-char (point-min)) | 478 (goto-char (point-min)) |
450 (fill-region (point-min) (point-max)) | 479 (fill-region (point-min) (point-max)) |
451 )))) | 480 )))) |
452 | |
453 (defvar citation-mark-chars ">}|") | |
454 | 481 |
455 (defun compress-cited-prefix () | 482 (defun compress-cited-prefix () |
456 (interactive) | 483 (interactive) |
457 (save-excursion | 484 (save-excursion |
458 (goto-char (point-min)) | 485 (goto-char (point-min)) |