X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=texi%2Finfohack.el;h=31fd01937dbf04920aca687f11c30bc23a4bd3c9;hb=cbf4c3ca1603cb756c7c895caefa5bbcbd57610c;hp=ad4abd03d0565e0352a3396202bc2ad649e34b9f;hpb=d1b6d13953a652e136e4f86647dc1935cc7997b1;p=elisp%2Fgnus.git- diff --git a/texi/infohack.el b/texi/infohack.el index ad4abd0..31fd019 100644 --- a/texi/infohack.el +++ b/texi/infohack.el @@ -1,5 +1,5 @@ ;;; infohack.el --- a hack to format info file. -;; Copyright (C) 2001 Free Software Foundation, Inc. +;; Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc. ;; Author: Shenghuo Zhu ;; Keywords: info @@ -32,6 +32,39 @@ (setq load-path (mapcar 'expand-file-name load-path))) (load-file (expand-file-name "ptexinfmt.el" "./")) +(if (fboundp 'texinfo-copying) + nil + ;; Support @copying and @insertcopying for Emacs 21.3 and lesser and + ;; XEmacs. + (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)))) + (defun infohack-remove-unsupported () (goto-char (point-min)) (while (re-search-forward "@\\(end \\)?ifnottex" nil t) @@ -45,6 +78,10 @@ (let ((dest-directory default-directory) (max-lisp-eval-depth (max max-lisp-eval-depth 600)) coding-system) + ;; Emacs 21.3 doesn't support @documentencoding + (unless (get 'documentencoding 'texinfo-format) + (put 'documentencoding 'texinfo-format + 'texinfo-discard-line-with-args)) (find-file file) (setq buffer-read-only nil) (setq coding-system buffer-file-coding-system)