auctex
[Top][All Lists]
Advanced

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

Re: [AUCTeX] Include subdirectories in Reftex's completion


From: Ralf Angeli
Subject: Re: [AUCTeX] Include subdirectories in Reftex's completion
Date: Wed, 06 Oct 2010 22:28:10 +0200

* Mathias Lindner (2010-10-05) writes:

> During editing main.tex I want to include chapter.tex. So I hit C-C C-M, 
> choose
> include and hit Tab to list all files Reftex finds.

This is a functionality of AUCTeX, not RefTeX.

> The list now contains:
> main.tex    chapter.tex
> I choose chapter.tex and get:
> \include{chapter.tex}
> But what I expect is:
> \include{./subdir/chapter.tex}
>
> Why does Reftex omit the subdir information?

AUCTeX tries to list all files seen by kpsewhich (and therefore latex).
Those would not require directory information when given as a parameter
of \include.  Now when kpsewhich is not available or does not work (Are
you using MiKTeX?) then it resorts to finding relevant files below the
current directory.  But it still assumes that those can be seen by latex
(without knowing the path).  And this is a false assumption if the files
are in a subdirectory.

> And what can I do about it?

This would have to be changed in AUCTeX's code.  I'm a bit reluctant to
do this, though, because it would change the semantics of the function
`TeX-input-file' which is used here.  The function is described like
this:

,----[ (info "(auctex)Adding Macros") ]
| `TeX-arg-input-file'
|      Prompt for the name of an input file in TeX's search path, and use
|      it without the extension.  Run the style hooks for the file.
`----

Any opinions?

The patch would look like this, i.e. quite hackish:

--- latex.el    7 Mar 2010 09:15:54 -0000       5.458
+++ latex.el    6 Oct 2010 20:21:05 -0000
@@ -1693,12 +1693,17 @@
                  (completing-read
                   (TeX-argument-prompt optional prompt "File")
                   (TeX-delete-dups-by-car
-                   (append (mapcar 'list
-                                   (TeX-search-files '("./")
-                                                     TeX-file-extensions
-                                                     t t))
-                           (unless local
-                             TeX-global-input-files))))
+                   (append
+                    (mapcar 'list
+                            ;; If `local' is non-nil, inhibit the
+                            ;; kpathsea-based search and return file
+                            ;; names with directories.
+                            (let ((TeX-kpathsea-path-delimiter
+                                   (if local nil TeX-kpathsea-path-delimiter)))
+                              (TeX-search-files '("./") TeX-file-extensions
+                                                (not local) t)))
+                    (unless local
+                      TeX-global-input-files))))
                (read-file-name
                 (TeX-argument-prompt optional prompt "File")))))
     (if (null file)

-- 
Ralf



reply via email to

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