unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: opening correct source file on compile error
Date: Mon, 23 Oct 2006 14:07:31 -0600	[thread overview]
Message-ID: <ehj7fh$ia3$1@sea.gmane.org> (raw)
In-Reply-To: <m1ods3vt2k.fsf@yaman.ce.berkeley.edu>

Ushnish Basu wrote:
> Kevin Rodgers <ihs_4664@yahoo.com> writes:
> 
>> kl.vanw@gmail.com wrote:
>>> Here's my situation. My header files (C++) are located in a dir named
>>> src/lib. These are the files I edit and are CVS managed. When I run
>>> 'make', make copies the headers into include/, which my other source
>>> files include. Then if there was an error in one of the headers, and I
>>> use 'next-error' in the compilation buffer to open the header, emacs
>>> opens the file in the include/ directory, but I really need it to open
>>> the header in src/lib. Can I some how help emacs find the right file?
>>> Unfortunately, I don't have the option of changing the way our makefile
>>> works or the #include statements.
>> Try this:
>>
>> (add-hook 'find-file-hook
>> 	  (lambda ()
>> 	    (let* ((file (file-name-nondirectory buffer-file-name))
>> 		   (directory (file-name-directory buffer-file-name))
>> 		   (alternate-file (expand-file-name file "../src/lib")))
>> 	      (when (and (equal (file-name-nondirectory
>> 				 (directory-file-name directory))
>> 				"include")
>> 			 (file-exists-p alternate-file))
>> 		(find-alternate-file alternate-file)))))
>>
>> -- 
>> Kevin
>>
> 
> I have a similar problem, except that my CVS has *.F files (in say ../src) for
> the fortran preprocessor, and make gives me corresponding *.f files in the
> current directory. How would one modify the above example for this case?

(add-hook 'find-file-hook
  	  (lambda ()
  	    (let* ((file (file-name-nondirectory buffer-file-name))
  		   alternate-file)
  	      (when (and (equal (file-name-extension file) "f")
			 (file-exists-p
			  (setq alternate-file
				(expand-file-name (concat (file-name-sans-extension file)
							  ".F")
						  "../src"))))
  		(find-alternate-file alternate-file)))))

> Sorry, I don't understand (e)lisp well enough to do it myself, but I am
> planning to learn. 

You will be greatly rewarded for your efforts!

-- 
Kevin

  reply	other threads:[~2006-10-23 20:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-18 16:08 opening correct source file on compile error kl.vanw
2006-10-19 16:14 ` Kevin Rodgers
     [not found] ` <mailman.98.1161274520.2130.help-gnu-emacs@gnu.org>
2006-10-20 14:00   ` kl.vanw
2006-10-23 16:15     ` Kevin Rodgers
     [not found]     ` <mailman.162.1161620177.27805.help-gnu-emacs@gnu.org>
2006-10-24 12:04       ` kl.vanw
2006-10-24 12:46         ` Burton Samograd
2006-10-24 14:10           ` kl.vanw
2006-10-24 22:31             ` Burton Samograd
2006-10-24 21:53         ` Kevin Rodgers
     [not found]         ` <mailman.216.1161726966.27805.help-gnu-emacs@gnu.org>
2006-10-25 11:41           ` kl.vanw
2006-10-23 17:29   ` Ushnish Basu
2006-10-23 20:07     ` Kevin Rodgers [this message]
     [not found]     ` <mailman.175.1161634161.27805.help-gnu-emacs@gnu.org>
2006-10-23 22:23       ` Ushnish Basu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='ehj7fh$ia3$1@sea.gmane.org' \
    --to=ihs_4664@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).