(tex-first-line-header-regexp): New variable.
authorRichard M. Stallman <rms@gnu.org>
Sun, 29 Dec 1996 19:41:52 +0000 (19:41 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sun, 29 Dec 1996 19:41:52 +0000 (19:41 +0000)
(tex-region): Sometimes include the file's first line.

lisp/textmodes/tex-mode.el

index 4f19edc..c20c6b9 100644 (file)
@@ -41,6 +41,13 @@ You can make this `/tmp' if your TEXINPUTS has no relative directories in it
 and you don't try to apply \\[tex-region] or \\[tex-buffer] when there are
 `\\input' commands with relative directories.")
 
+;;;###autoload
+(defvar tex-first-line-header-regexp nil
+  "Regexp for matching a first line which `tex-region' should include.
+If this is non-nil, it should be a regular expression string;
+if it matches the first line of the file,
+`tex-region' always includes the first line in the TeX run.")
+
 ;;;###autoload
 (defvar tex-main-file nil
   "*The main TeX source file which includes this buffer's file.
@@ -1010,6 +1017,14 @@ The value of `tex-command' specifies the command to use to run TeX."
              (hbeg (point-min)) (hend (point-min))
              (default-directory zap-directory))
          (goto-char (point-min))
+          
+          ;; Maybe copy first line, such as `\input texinfo', to temp file.
+         (and tex-first-line-header-regexp
+              (looking-at tex-first-line-header-regexp)
+              (write-region (point) 
+                            (progn (forward-line 1) (point))
+                            tex-out-file nil nil))
+
          ;; Initialize the temp file with either the header or nothing
          (if (re-search-forward tex-start-of-header search-end t)
              (progn