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

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

Re: subsitute for current file name in buffer in emacs


From: Kevin Rodgers
Subject: Re: subsitute for current file name in buffer in emacs
Date: Wed, 30 Jan 2008 22:35:26 -0700
User-agent: Thunderbird 2.0.0.9 (Macintosh/20071031)

shankarrg wrote:
suppose i need to use the file name which is currently present in buffer
opened before me in emacs ..

now suppose it is a .cpp file say abc.cpp
now to compile this file i have to use        ...\g++  abc.cpp


now  instead for putting abc.cpp  is there a variable or command which
substitutes itself as the file name in current buffer when used ?

Even better, perhaps:

(add-hook 'find-file-hook
          (lambda ()
            (when (string-match "\\.cpp\\'" buffer-file-name)
              (set (make-local-variable 'compile-command)
                   (format "g++ %s"
                           (file-name-nondirectory buffer-file-name))))))

--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

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