[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX] inverse search when comipling only part of the document
From: |
Ivan Andrus |
Subject: |
Re: [AUCTeX] inverse search when comipling only part of the document |
Date: |
Wed, 17 Aug 2011 12:35:22 +0200 |
On Aug 9, 2011, at 7:43 PM, Jonas Frey wrote:
> Hello,
>
> I have a problem with inverse search. I'm using pdflatex with synctex.
> When I have a document with multiple files and I compile only one file, using
> C-c C-b, then inverse search does not jump to this file in emacs, but to a
> temporary
> called _region_.tex.
>
> Of course, this is not what I want. If I find an error in the pdf for
> example, and use
> inverse search to jump to the source and correct it, then the correction will
> only be
> in the temporary file, and I might not even notice if I don't pay attention.
>
> Does anybody have a solution for this?
>
> Thanks a lot,
>
> Jonas
I think this should work--it has worked on the few tests I have done, but I
haven't used it for very long. Let me know if you have any problems.
(defadvice server-goto-line-column (after server-visit-region.tex
(line-col)
activate)
"When visiting a file from an external source, make sure that we
are not narrowed, since the external source almost certainly
uses absolute file line numbers."
(when (string-match "_region_.tex\\'" (buffer-file-name))
(save-excursion ;; in case we don't find the other file we at least want
the right line...
(if (re-search-backward
"\message{ !name(\\([^)]+\\))\\(?: !offset(\\([-0-9]+\\))\\)?\\s *}"
nil nil)
(let ((file-name (match-string 1))
(offset (match-string 2))
(line (car (ad-get-arg 0)))
(col (cdr (ad-get-arg 0))))
(if offset (setq line (+ line (string-to-number offset))))
(find-file file-name nil)
;; Ironic, but I think cleaner then reimplementing...
(server-goto-line-column (cons line col))
(message "Moved from _region_.tex to line %s of %s." line
file-name))
;; else
(message "This is _region_.tex, but I couldn't find the original
file!")))))
-Ivan