Commits

Anonymous committed 198679a

packages: Fix printindex handling (found by xemacs.texi test case) in texinfm.el, minor sync with GNU Emacs

-------------------- ChangeLog entries follow: --------------------

xemacs-packages/texinfo/ChangeLog addition:

2005-09-25 Adrian Aichner <adrian@xemacs.org>

* texinfmt.el: Minor sync with GNU Emacs texinfmt-version "2.41 of
1 Mar 2005".
* texinfmt.el (texinfmt-version): New.
* texinfmt.el (texinfo-format-buffer): Restore use of
coding-system-for-write (sync)
* texinfmt.el (texinfo-pre-format-hook): New.
* texinfmt.el (texinfo-format-region): Run texinfo-pre-format-hook
(sync).
* texinfmt.el (texinfo-format-buffer-1): Use buffer-disable-undo
(sync).
* texinfmt.el (texinfo-append-refill): Generalize refill regexp
(sync).
* texinfmt.el (texinfo-paragraphindent): Use string-to-number (sync).
* texinfmt.el (texinfo-format-printindex): My genuine fix for
Message-ID: <9ea6aaa80503091939552b5e23@mail.gmail.com>.
* texinfmt.el (texinfo-print-index): Adjust index entry format (sync).
* texinfo.el: Minor sync with GNU Emacs.
* texinfo.el (texinfo): Typo fix sync.
* texinfo.el (texinfo-mode-hook): New. Not used yet.
* texinfo.el (texinfo-imenu-generic-expression): Typo fix sync.
* texinfo.el (texinfo-environments): Ditto.
* texinfo.el (texinfo-environment-regexp): Ditto.
* texinfo.el (texinfo-font-lock-keywords): Ditto.
* texinfo.el (texinfo-insert-quote): Ditto.
* texinfo.el (texinfo-show-structure): Ditto.

Comments (0)

Files changed (3)

+2005-09-25  Adrian Aichner  <adrian@xemacs.org>
+
+	* texinfmt.el: Minor sync with GNU Emacs texinfmt-version "2.41 of
+	1 Mar 2005".
+	* texinfmt.el (texinfmt-version): New.
+	* texinfmt.el (texinfo-format-buffer): Restore use of
+	coding-system-for-write (sync)
+	* texinfmt.el (texinfo-pre-format-hook): New.
+	* texinfmt.el (texinfo-format-region): Run texinfo-pre-format-hook
+	(sync).
+	* texinfmt.el (texinfo-format-buffer-1): Use buffer-disable-undo
+	(sync).
+	* texinfmt.el (texinfo-append-refill): Generalize refill regexp
+	(sync).
+	* texinfmt.el (texinfo-paragraphindent): Use string-to-number (sync).
+	* texinfmt.el (texinfo-format-printindex): My genuine fix for
+	Message-ID: <9ea6aaa80503091939552b5e23@mail.gmail.com>.
+	* texinfmt.el (texinfo-print-index): Adjust index entry format (sync).
+	* texinfo.el: Minor sync with GNU Emacs.
+	* texinfo.el (texinfo): Typo fix sync.
+	* texinfo.el (texinfo-mode-hook): New.  Not used yet.
+	* texinfo.el (texinfo-imenu-generic-expression): Typo fix sync.
+	* texinfo.el (texinfo-environments): Ditto.
+	* texinfo.el (texinfo-environment-regexp): Ditto.
+	* texinfo.el (texinfo-font-lock-keywords): Ditto.
+	* texinfo.el (texinfo-insert-quote): Ditto.
+	* texinfo.el (texinfo-show-structure): Ditto.
+
 2005-03-26  Norbert Koch  <viteno@xemacs.org>
 
 	* Makefile (VERSION): XEmacs package 1.29 released.
     (defmacro defcustom (var value doc &rest ignore)
       `(defvar ,var ,value ,doc)))
 
+(defvar texinfmt-version "2.41 of  1 Mar 2005")
+
 (or (fboundp 'match-string-no-properties) ;; XEmacs: not in 21.4
 (defun match-string-no-properties (num &optional string)
   "Return string of text matched by last search, without text properties.
 and don't split the file if large.  You can use Info-tagify and
 Info-split to do these manually."
   (interactive "P")
-  (let ((lastmessage "Formatting Info file..."))
-        ;; XEmacs change.
-        ;; FSF Emacs 20.4 hungs up waiting for coding-system if Texinfo file
-        ;; contains non ASCII character.
-;;;     (coding-system-for-write buffer-file-coding-system))
+  (let ((lastmessage "Formatting Info file...")
+	;; XEmacs change removed here 2005-09-25.
+	(coding-system-for-write buffer-file-coding-system))
     (message lastmessage)
     (widen)
     (texinfo-format-buffer-1)
 (defvar texinfo-region-buffer-name "*Info Region*"
   "*Name of the temporary buffer used by \\[texinfo-format-region].")
 
+(defvar texinfo-pre-format-hook nil
+  "Hook called before the conversion of the Texinfo file to Info format.
+The functions on this hook are called with argument BUFFER, the buffer
+containing the Texinfo file.")
+
 ;; These come from tex-mode.el.
 (defvar tex-start-of-header)
 (defvar tex-end-of-header)
      input-buffer
      (max region-beginning header-end)
      region-end)
+    (run-hook-with-args 'texinfo-pre-format-hook input-buffer)
     ;; Make sure region ends in a newline.
     (or (= (preceding-char) ?\n)
         (insert "\n"))
     (find-file outfile)
     (texinfo-mode)
     (erase-buffer)
+    (buffer-disable-undo)
 
     (message "Formatting Info file: %s" outfile)
     (setq texinfo-format-filename
     (set-syntax-table texinfo-format-syntax-table)
 
     (insert-buffer-substring input-buffer)
+    (run-hook-with-args 'texinfo-pre-format-hook input-buffer)
     (message "Converting %s to Info format..." (buffer-name input-buffer))
 
     ;; Insert @include files so `texinfo-raise-lower-sections' can
           ;; 4. Else go to end of paragraph and insert @refill
           (forward-paragraph)
           (forward-line -1)
-          (let ((line-beg (point)))
-            (end-of-line)
-            (delete-region
-             (point)
-             (save-excursion (skip-chars-backward " \t") (point)))
-            (forward-char 1)
-            (unless (re-search-backward "@c[ \t\n]\\|@comment[ \t\n]" line-beg t)
-              (forward-char -1))
-            (unless (re-search-backward "@refill\\|@bye" line-beg t)
-              (insert "@refill")))
+	  (let ((line-beg (point)))
+	    (end-of-line)
+	    (delete-region
+	     (point)
+	     (save-excursion (skip-chars-backward " \t") (point)))
+	    (forward-char 1)
+	    (unless (re-search-backward "@c[ \t\n]\\|@comment[ \t\n]" line-beg t)
+	      (forward-char -1))
+	    (unless (re-search-backward "@refill\\|^[ \t]*@" line-beg t)
+	      (insert "@refill")))
           (forward-line 1))))))
 
 
   (let ((arg  (texinfo-parse-arg-discard)))
     (if (string= "asis" arg)
         (setq texinfo-paragraph-indent "asis")
-      (setq texinfo-paragraph-indent (string-to-int arg)))))
+      (setq texinfo-paragraph-indent (string-to-number arg)))))
 
 (put 'refill 'texinfo-format 'texinfo-format-refill)
 (defun texinfo-format-refill ()
   (let ((indexelts (symbol-value
                     (cdr (assoc (texinfo-parse-arg-discard)
                                 texinfo-indexvar-alist))))
-        opoint)
+        opoint npoint)
     (insert "\n* Menu:\n\n")
     (setq opoint (point))
     (texinfo-print-index nil indexelts)
-
+    (setq npoint (point))
     (if (memq system-type '(vax-vms windows-nt ms-dos))
-        (texinfo-sort-region opoint (point))
-      (shell-command-on-region opoint (point) "sort -fd" 1))))
+	(texinfo-sort-region opoint npoint)
+      (shell-command-on-region opoint npoint "sort -fd" 1))
+    (goto-char npoint)))
 
 (defun texinfo-print-index (file indexelts)
   (while indexelts
           (indent-to 54)
           (insert
            (if (nth 2 (car indexelts))
-               (format "  %d." (nth 2 (car indexelts)))
+               (format "  (line %3d)" (1+ (nth 2 (car indexelts))))
              "")
            "\n"))
       ;; index entries from @include'd file
 (eval-when-compile (require 'tex-mode) (require 'cl) (require 'regexp-opt))
 
 (defgroup texinfo nil
-  "Texinfo Mode"
+  "Texinfo Mode."
   :group 'docs)
 
 ;;;###autoload
   :type 'string
   :group 'texinfo)
 
+(defcustom texinfo-mode-hook nil
+  "Normal hook run when entering Texinfo mode."
+  :type 'hook
+  :options '(turn-on-auto-fill flyspell-mode)
+  :group 'texinfo)
+
 
 ;;; Autoloads:
 
 (defvar texinfo-imenu-generic-expression
   '((nil "^@\\(node\\|anchor\\)[ \t]+\\([^,\n]*\\)" 2)
     ("Chapters" "^@chapter[ \t]+\\(.*\\)$" 1))
-
   "Imenu generic expression for Texinfo mode.  See `imenu-generic-expression'.")
 
 (defvar texinfo-font-lock-syntactic-keywords
     "macro" "menu" "multitable" "quotation" "smalldisplay"
     "smallexample" "smallformat" "smalllisp" "table" "tex"
     "titlepage" "verbatim" "vtable")
-  "List of TeXinfo environments.")
+  "List of Texinfo environments.")
 
 (defconst texinfo-environment-regexp
   (concat "^@" (regexp-opt (cons "end" texinfo-environments) t) "\\>")
-  "Regexp for environment-like TexInfo list commands.
+  "Regexp for environment-like Texinfo list commands.
 Subexpression 1 is what goes into the corresponding `@end' statement.")
 
 (defface texinfo-heading-face
     ;;  1 (texinfo-clone-environment (match-beginning 1) (match-end 1)) keep)
     (,(concat "^@" (regexp-opt (mapcar 'car texinfo-section-list) t)
 	       ".*\n") 0 texinfo-heading-face t))
-  "Additional expressions to highlight in TeXinfo mode.")
+  "Additional expressions to highlight in Texinfo mode.")
 
 (defun texinfo-clone-environment (start end)
   (let ((endp nil))
 	 (not (match-end 1)))))
 
 (defun texinfo-insert-quote (&optional arg)
-  "Insert the appropriate quote mark for TeXinfo.
+  "Insert the appropriate quote mark for Texinfo.
 Usually inserts the value of `texinfo-open-quote' (normally ``) or
 `texinfo-close-quote' (normally ''), depending on the context.
 With prefix argument or inside @code or @example, inserts a plain \"."
                 (progn
                   (beginning-of-line)
                   (buffer-substring (point) (progn (end-of-line) (point)))))
-        ;; else point is located before before any section command
+        ;; else point is located before any section command.
         (setq current-location "tex")))
     ;; Second, create and format an *Occur* buffer
     (save-excursion