help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: opening correct source file on compile error


From: Kevin Rodgers
Subject: Re: opening correct source file on compile error
Date: Tue, 24 Oct 2006 15:53:23 -0600
User-agent: Thunderbird 1.5.0.7 (Windows/20060909)

kl.vanw@gmail.com wrote:
Kevin Rodgers wrote:
Ah, it works in Emacs 22.  To make it work in older versions, use
find-file-hooks (plural) instead of find-file-hook.

Yes, I have Emacs 21.3.1. I couldn't get that to work either. Maybe I'm
messing up the paths. To be more explicit, the files I edit are in
~/project/math/src/lib/math/ and gmake puts them in
~/project/math/include/math/.

Ah, you didn't mention that the src/lib and include directories had
their own subdirectory structure, so I assumed otherwise.

(add-hook 'find-file-hooks
          (lambda ()
            (let ((alternate-file
                   (replace-regexp-in-string "/include/"
                                             "/src/lib/"
                                             buffer-file-name
                                             t ; fixedcase
                                             t))) ; literal
              (when (and (not (equal buffer-file-name alternate-file))
                         (file-exists-p alternate-file))
                (find-alternate-file alternate-file)))))

--
Kevin





reply via email to

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