[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: Jonas Frey
Subject: Re: [AUCTeX] inverse search when comipling only part of the document
Date: Thu, 18 Aug 2011 13:57:49 +0200

Thanks a lot for your answer -- it almost works!

I copied the definition that you gave to my .emacs, and now when inverse searching, the cursor jumps to the right line in both files (source file and region file), but it still activates the buffer with the region file.

How can I have the source file active after inverse search?

On Wed, Aug 17, 2011 at 12:35 PM, Ivan Andrus <address@hidden> wrote:

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
 "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!")))))


reply via email to

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