1 ;;; infohack.el --- a hack to format info file.
2 ;; Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
4 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
30 (if (fboundp 'texinfo-copying)
32 ;; Support @copying and @insertcopying for Emacs 21.3 and lesser and
34 (defvar texinfo-copying-text ""
35 "Text of the copyright notice and copying permissions.")
37 (defun texinfo-copying ()
38 "Copy the copyright notice and copying permissions from the Texinfo file,
39 as indicated by the @copying ... @end copying command;
40 insert the text with the @insertcopying command."
41 (let ((beg (progn (beginning-of-line) (point)))
42 (end (progn (re-search-forward "^@end copying[ \t]*\n") (point))))
43 (setq texinfo-copying-text
44 (buffer-substring-no-properties
45 (save-excursion (goto-char beg) (forward-line 1) (point))
46 (save-excursion (goto-char end) (forward-line -1) (point))))
47 (delete-region beg end)))
49 (defun texinfo-insertcopying ()
50 "Insert the copyright notice and copying permissions from the Texinfo file,
51 which are indicated by the @copying ... @end copying command."
52 (insert (concat "\n" texinfo-copying-text)))
54 (defadvice texinfo-format-scan (before expand-@copying-section activate)
55 "Extract @copying and replace @insertcopying with it."
56 (goto-char (point-min))