David Kastrup <[EMAIL PROTECTED]> writes:

> Ah, I thought of something else: file names with spaces in them.  It
> would be nice to get those working.

Here is a first sketch.  It is, well, not exactly an example of pretty
programming.

The idea is to move "\... sequences to behind option arguments, and
use \input only when such sequences are present (in which case file
names with spaces won't work).

This is just a patch for AUCTeX.  preview-latex takes more work.

Comments?  Apart from that there are far too many non-byte-compiled
lambda functions that have no real business in TeX-command-list?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Index: tex.el
===================================================================
RCS file: /sources/auctex/auctex/tex.el,v
retrieving revision 5.586
diff -u -r5.586 tex.el
--- tex.el	20 Sep 2006 10:20:19 -0000	5.586
+++ tex.el	22 Sep 2006 18:00:24 -0000
@@ -157,10 +157,10 @@
 
 (defcustom TeX-command-list
   ;; Changed to double quotes for Windows afflicted people.
-  `(("TeX" "%(PDF)%(tex) %S%(PDFout) \"%(mode)\\input %t\""
+  `(("TeX" "%(PDF)%(tex) %S%(PDFout) %(mode) %T"
      TeX-run-TeX nil
      (plain-tex-mode ams-tex-mode texinfo-mode) :help "Run plain TeX")
-    ("LaTeX" "%l \"%(mode)\\input{%t}\""
+    ("LaTeX" "%l %(mode) %T"
      TeX-run-TeX nil
      (latex-mode doctex-mode) :help "Run LaTeX")
 	;; Not part of standard TeX.
@@ -168,13 +168,13 @@
      (texinfo-mode) :help "Run Makeinfo with Info output")
     ("Makeinfo HTML" "makeinfo --html %t" TeX-run-compile nil
      (texinfo-mode) :help "Run Makeinfo with HTML output")
-    ("AmSTeX" "%(PDF)amstex %S%(PDFout) \"%(mode)\\input %t\""
+    ("AmSTeX" "%(PDF)amstex %S%(PDFout) %(mode) %T"
      TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
     ;; support for ConTeXt  --pg
     ;; first version of ConTeXt to support nonstopmode: 2003.2.10
-    ("ConTeXt" "texexec --once --texutil %(execopts)%t"
+    ("ConTeXt" "texexec --once --texutil %(execopts)%T"
      TeX-run-TeX nil (context-mode) :help "Run ConTeXt once")
-    ("ConTeXt Full" "texexec %(execopts)%t"
+    ("ConTeXt Full" "texexec %(execopts)%T"
      TeX-run-TeX nil
      (context-mode) :help "Run ConTeXt until completion")
     ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help "Run BibTeX")
@@ -446,7 +446,7 @@
     ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d")
     ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d")
     ("^dvi$" "." "%(o?)xdvi %dS %d")
-    ("^pdf$" "." "xpdf -remote \"%s\" -raise %o %(outpage)")
+    ("^pdf$" "." "xpdf -remote %s -raise %o %(outpage)")
     ("^html?$" "." "netscape %o"))
   "List of output file extensions and view options.
 
@@ -510,7 +510,7 @@
     ("%(mode)" (lambda ()
 		 (if TeX-interactive-mode
 		     ""
-		   "\\nonstopmode")))
+		   "-interaction=nonstopmode")))
     ("%(o?)" (lambda () (if TeX-Omega-mode "o" "")))
     ("%(tex)" (lambda () (if TeX-Omega-mode
 			     TeX-Omega-command
@@ -528,10 +528,38 @@
     ;; `file' means to call `TeX-master-file' or `TeX-region-file'
     ("%s" file nil t)
     ("%t" file t t)
+    (" \"\\" (lambda nil
+	       (setq TeX-command-pos pos
+		     pos (+ 3 pos))
+	       nil))
+    ("\"" (lambda nil (if TeX-command-pos
+			  (setq TeX-command-text
+				(concat
+				 TeX-command-text
+				 (substring command
+					    TeX-command-pos
+					    (1+ pos)))
+				command
+				(concat
+				 (substring command
+					    0
+					    TeX-command-pos)
+				 (substring command
+					    (1+ pos)))
+				pos TeX-command-pos
+				TeX-command-pos nil)
+			"\"")))
+    ("%T" (lambda ()
+	    (concat TeX-command-text
+		    (when TeX-command-text
+			 (setq pos (+ pos 10 (length TeX-command-text))
+			       TeX-command-text nil)
+			 " \"\\input\" ")
+		    (funcall file t t))))
     ("%n" TeX-current-line)
     ("%d" file "dvi" t)
     ("%f" file "ps" t)
-    ("%o" TeX-view-output-file)
+    ("%o" (lambda nil (funcall file (TeX-output-extension) t)))
     ;; for source specials the file name generated for the xdvi
     ;; command needs to be relative to the master file, just in
     ;; case the file is in a different subdirectory
Index: tex-buf.el
===================================================================
RCS file: /sources/auctex/auctex/tex-buf.el,v
retrieving revision 1.253
diff -u -r1.253 tex-buf.el
--- tex-buf.el	20 Sep 2006 10:20:19 -0000	1.253
+++ tex-buf.el	22 Sep 2006 18:00:26 -0000
@@ -290,8 +290,10 @@
 `%%' can be used to produce a single `%' sign in the output
 without further expansion."
   (let (pat
+	(file `(lambda (&rest args)
+		 (shell-quote-argument (apply ',file args))))
 	pos
-	entry
+	entry TeX-command-text TeX-command-pos
 	case-fold-search string expansion arguments)
     (setq list (cons
 		(list "%%" (lambda nil
@@ -304,15 +306,16 @@
 	    entry (assoc string list)
 	    expansion (car (cdr entry)) ;Second element
 	    arguments (cdr (cdr entry)) ;Remaining elements
-	    command (replace-match
-		     (save-match-data
-		       (cond ((TeX-function-p expansion)
-			      (apply expansion arguments))
-			     ((boundp expansion)
-			      (apply (eval expansion) arguments))
-			     (t
-			      (error "Nonexpansion %s" expansion))))
-		     t t command))))
+	    string (save-match-data
+		     (cond ((TeX-function-p expansion)
+			    (apply expansion arguments))
+			   ((boundp expansion)
+			    (apply (eval expansion) arguments))
+			   (t
+			    (error "Nonexpansion %s" expansion)))))
+      (if (stringp string)
+	  (setq command
+		(replace-match string t t command)))))
   command)
 
 (defun TeX-check-files (derived originals extensions)
@@ -445,10 +448,6 @@
 				TeX-output-extension)
 	TeX-output-extension)))
 
-(defun TeX-view-output-file ()
-  "Get the name of the current TeX output file"
-  (TeX-active-master (TeX-output-extension) t))
-
 (defun TeX-view-mouse (event)
   "Start `TeX-view' at mouse position."
   (interactive "e")
_______________________________________________
auctex-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to