emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r113184: info-xref.el: Update for Texinfo 5 change i


From: Glenn Morris
Subject: [Emacs-diffs] trunk r113184: info-xref.el: Update for Texinfo 5 change in *note format
Date: Wed, 26 Jun 2013 01:52:14 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113184
revision-id: address@hidden
parent: address@hidden
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Tue 2013-06-25 18:52:09 -0700
message:
  info-xref.el: Update for Texinfo 5 change in *note format
  
  * lisp/info-xref.el (info-xref-node-re, info-xref-note-re): New constants.
  (info-xref-check-buffer): Use info-xref-note-re.
  
  * test/automated/info-xref.el: New file.
added:
  test/automated/info-xref.el    infoxref.el-20130626015103-9one3hc3rycla2w1-1
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/info-xref.el              
infoxref.el-20091113204419-o5vbwnq5f7feedwu-2552
  test/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-8588
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-06-26 00:50:50 +0000
+++ b/lisp/ChangeLog    2013-06-26 01:52:09 +0000
@@ -1,3 +1,9 @@
+2013-06-26  Glenn Morris  <address@hidden>
+
+       * info-xref.el: Update for Texinfo 5 change in *note format.
+       (info-xref-node-re, info-xref-note-re): New constants.
+       (info-xref-check-buffer): Use info-xref-note-re.
+
 2013-06-26  Stefan Monnier  <address@hidden>
 
        * simple.el (set-variable): Use read-from-minibuffer (bug#14710).

=== modified file 'lisp/info-xref.el'
--- a/lisp/info-xref.el 2013-01-01 09:11:05 +0000
+++ b/lisp/info-xref.el 2013-06-26 01:52:09 +0000
@@ -367,13 +367,28 @@
                     (forward-line)))
               (info-xref-check-buffer))))))))
 
+(defconst info-xref-node-re "\\(?1:\\(([^)]*)\\)[^.,]+\\)"
+  "Regexp with subexp 1 matching (manual)node.")
+
+;; "@xref{node,crossref,manual}." produces:
+;; texinfo 4 or 5:
+;; *Note crossref: (manual)node.
+;; "@xref{node,,manual}." produces:
+;; texinfo 4:
+;; *Note node: (manual)node.
+;; texinfo 5:
+;; *Note (manual)node::.
+(defconst info-xref-note-re
+  (concat "\\*[Nn]ote[ \n\t]+\\(?:"
+          "[^:]*:[ \n\t]+" info-xref-node-re "\\|"
+          info-xref-node-re "::\\)[.,]")
+  "Regexp matching a \"*note...\" link.")
+
 (defun info-xref-check-buffer ()
   "Check external references in the info file in the current buffer.
 This should be the raw file contents, not `Info-mode'."
   (goto-char (point-min))
-  (while (re-search-forward
-          "\\*[Nn]ote[ \n\t]+[^:]*:[ \n\t]+\\(\\(([^)]*)\\)[^.,]+\\)[.,]"
-          nil t)
+  (while (re-search-forward info-xref-note-re nil t)
     (save-excursion
       (goto-char (match-beginning 1)) ;; start of nodename as error position
       (info-xref-check-node (match-string 1)))))

=== modified file 'test/ChangeLog'
--- a/test/ChangeLog    2013-06-25 02:24:32 +0000
+++ b/test/ChangeLog    2013-06-26 01:52:09 +0000
@@ -1,3 +1,7 @@
+2013-06-26  Glenn Morris  <address@hidden>
+
+       * automated/info-xref.el: New file.
+
 2013-06-25  Glenn Morris  <address@hidden>
 
        * automated/occur-tests.el (occur-test-create): New function.

=== added file 'test/automated/info-xref.el'
--- a/test/automated/info-xref.el       1970-01-01 00:00:00 +0000
+++ b/test/automated/info-xref.el       2013-06-26 01:52:09 +0000
@@ -0,0 +1,148 @@
+;;; info-xref.el --- tests for info-xref.el
+
+;; Copyright (C) 2013 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'ert)
+(require 'info-xref)
+
+(defun info-xref-test-internal (body result)
+  "Body of a basic info-xref ert test.
+BODY is a string from an info buffer.
+RESULT is a list (NBAD NGOOD NUNAVAIL)."
+  (get-buffer-create info-xref-output-buffer)
+  (setq info-xref-xfile-alist nil)
+  (require 'info)
+  (let ((Info-directory-list '("."))
+        Info-additional-directory-list)
+    (info-xref-with-output
+     (with-temp-buffer
+       (insert body)
+       (info-xref-check-buffer))))
+  (should (equal result (list info-xref-bad info-xref-good info-xref-unavail)))
+  ;; If there was an error, we can leave this around.
+  (kill-buffer info-xref-output-buffer))
+
+(ert-deftest info-xref-test-node-crossref ()
+  "Test parsing of @xref{node,crossref,,manual} with Texinfo 4/5."
+  (info-xref-test-internal "
+*Note crossref: (manual-foo)node.  Texinfo 4/5 format with crossref.
+" '(0 0 1)))
+
+(ert-deftest info-xref-test-node-4 ()
+  "Test parsing of @xref{node,,,manual} with Texinfo 4."
+  (info-xref-test-internal "
+*Note node: (manual-foo)node.  Texinfo 4 format with no crossref.
+" '(0 0 1)))
+
+(ert-deftest info-xref-test-node-5 ()
+  "Test parsing of @xref{node,,,manual} with Texinfo 5."
+  (info-xref-test-internal "
+*Note (manual-foo)node::.  Texinfo 5 format with no crossref.
+" '(0 0 1)))
+
+;; TODO Easier to have static data files in the repo?
+(defun info-xref-test-write-file (file body)
+  "Write BODY to texi FILE."
+  (with-temp-buffer
+    (insert "\
+\input texinfo
address@hidden "
+            (format "%s.info\n" (file-name-sans-extension file))
+            "\
address@hidden test
+
address@hidden
address@hidden Top
address@hidden test
address@hidden ifnottex
+
address@hidden
+* Chapter One::
address@hidden menu
+
address@hidden Chapter One
address@hidden Chapter One
+
+text.
+
+"
+            body
+            "\
address@hidden
+"
+            )
+    (write-region nil nil file nil 'silent))
+  (should (equal 0 (call-process "makeinfo" file))))
+
+(ert-deftest info-xref-test-makeinfo ()
+  "Test that info-xref can parse basic makeinfo output."
+  :expected-result (if (executable-find "makeinfo") :passed :failed)
+  (should (executable-find "makeinfo"))
+  (let ((tempfile (make-temp-file "info-xref-test" nil ".texi"))
+        (tempfile2 (make-temp-file "info-xref-test2" nil ".texi"))
+        (errflag t))
+    (unwind-protect
+        (progn
+          ;; tempfile contains xrefs to various things, including tempfile2.
+          (info-xref-test-write-file
+           tempfile
+           (concat "\
address@hidden,,,missing,Missing Manual}.
+
address@hidden,crossref,title,missing,Missing Manual}.
+
address@hidden One}.
+
address@hidden One,Something}.
+
+"
+                   (format "@xref{Chapter One,,,%s,Present Manual}.\n"
+                           (file-name-sans-extension (file-name-nondirectory
+                                                      tempfile2)))))
+          ;; Something for tempfile to xref to.
+          (info-xref-test-write-file tempfile2 "")
+          (require 'info)
+          (save-window-excursion
+            (let ((Info-directory-list
+                   (list
+                    (or (file-name-directory tempfile) ".")))
+                  Info-additional-directory-list)
+              (info-xref-check (format "%s.info" (file-name-sans-extension
+                                                  tempfile))))
+            (should (equal (list info-xref-bad info-xref-good
+                                 info-xref-unavail)
+                           '(0 1 2)))
+            (setq errflag nil)
+            ;; If there was an error, we can leave this around.
+            (kill-buffer info-xref-output-buffer)))
+      ;; Useful diagnostic in case of problems.
+      (if errflag
+          (with-temp-buffer
+            (call-process "makeinfo" nil t nil "--version")
+            (message "%s" (buffer-string))))
+      (mapc 'delete-file (list tempfile tempfile2
+                               (format "%s.info" (file-name-sans-extension
+                                                  tempfile))
+                               (format "%s.info" (file-name-sans-extension
+                                                  tempfile2)))))))
+
+;;; info-xref.el ends here


reply via email to

[Prev in Thread] Current Thread [Next in Thread]