From 1a911aa2a44cbc5ee8f876887be2966e7b9b2812 Mon Sep 17 00:00:00 2001 From: kaoru Date: Sat, 10 Nov 2007 00:02:09 +0000 Subject: [PATCH] Import from gnus-doc-ja: 2007-10-17 Katsumi Yamaoka * ptexinfmt.el (texinfo-copying-text, texinfo-copying) (texinfo-insertcopying, texinfo-format-scan): Move from infohack.el. --- utils/ChangeLog | 5 +++++ utils/ptexinfmt.el | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/utils/ChangeLog b/utils/ChangeLog index 303c47a..4412fc5 100644 --- a/utils/ChangeLog +++ b/utils/ChangeLog @@ -1,3 +1,8 @@ +2007-11-10 Katsumi Yamaoka + + * ptexinfmt.el (texinfo-copying-text, texinfo-copying) + (texinfo-insertcopying, texinfo-format-scan): Move from infohack.el. + 2007-11-09 Katsumi Yamaoka * ptexinfmt.el (ptexinfmt-broken-facility, ptexinfmt-defun-if-broken) diff --git a/utils/ptexinfmt.el b/utils/ptexinfmt.el index cdf03fa..24c834e 100644 --- a/utils/ptexinfmt.el +++ b/utils/ptexinfmt.el @@ -960,6 +960,40 @@ This command is executed when texinfmt sees @item inside @multitable." (texinfo-sort-region opoint (point)) (shell-command-on-region opoint (point) "sort -fd" 1)))) + +;; @copying ... @end copying +;; that Emacs 21.4 and lesser and XEmacs don't support. +(if (fboundp 'texinfo-copying) + nil + (defvar texinfo-copying-text "" + "Text of the copyright notice and copying permissions.") + + (defun texinfo-copying () + "Copy the copyright notice and copying permissions from the Texinfo file, +as indicated by the @copying ... @end copying command; +insert the text with the @insertcopying command." + (let ((beg (progn (beginning-of-line) (point))) + (end (progn (re-search-forward "^@end copying[ \t]*\n") (point)))) + (setq texinfo-copying-text + (buffer-substring-no-properties + (save-excursion (goto-char beg) (forward-line 1) (point)) + (save-excursion (goto-char end) (forward-line -1) (point)))) + (delete-region beg end))) + + (defun texinfo-insertcopying () + "Insert the copyright notice and copying permissions from the Texinfo file, +which are indicated by the @copying ... @end copying command." + (insert (concat "\n" texinfo-copying-text))) + + (defadvice texinfo-format-scan (before expand-@copying-section activate) + "Extract @copying and replace @insertcopying with it." + (goto-char (point-min)) + (when (search-forward "@copying" nil t) + (texinfo-copying)) + (while (search-forward "@insertcopying" nil t) + (delete-region (match-beginning 0) (match-end 0)) + (texinfo-insertcopying)))) + (provide 'ptexinfmt) ;;; ptexinfmt.el ends here -- 1.7.10.4