I am thinking to switch from vim + latex-vim module to emacs + evil + auctex,etc modules for editing latex files. I am completely new for emacs.
I have a lot of latex projects written for vim-latex with many files on different levels of a project directory. In vim-latex the master file is defined by a file {master-file-name}.latexmain, e.g., if the main file is main.tex, then in the same directory there is main.tex.latexmain. I would like to have similar behavior in emacs (ideally accomplished with the emacs variable approach when it is necessarily, e.g., several master files in the same project directory).
Below you find the code for finding the name of the master file (it is my first elisp code, so any comments about how it can be ameliorated are very welcome)
(defun texmode-find-master-file ()
"Finds the master file for TeX/LaTeX project by searching for '{file-name}.latexmain' in the rood directories"
(let (foundFiles (currPath (expand-file-name "./")) result)
(while (and (not foundFiles) (not (equal currPath "/")) )
(setq foundFiles (directory-files currPath t ".*\.latexmain"))
(setq currPath (expand-file-name (concat currPath "../")))
)
(setq result (file-name-sans-extension (car foundFiles)))
(and (file-exists-p result) result)
)
)
However, I was not able to find where I can insert this code to modify the behavior of finding master files in AUCTeX. But may be there is a simpler or more beautiful way?
The related questions are
- What should I modify in order to open (by means of find-file-at-point or similar)
\input{tex/blabla2.tex}
starting from the master path directory rather than the current directory? For example, I have three files: projdir/main.tex, projdir/tex/blabla1.tex, projdir/tex/blabla2.tex; and if I am editing blabla2.tex and there is\input{tex/blabla1.tex}
how can I open this file? - How to force AUCTeX to define the same type of document as it is in the master file, e.g., if the main file type is 'latex', then all the files in the same project directory are also 'latex' (if not specified explicitly), not 'tex' as it is defined for some of files in my current settings.