From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: subsitute for current file name in buffer in emacs Date: Sat, 26 Jan 2008 15:30:26 -0800 (PST) Organization: http://groups.google.com Message-ID: <91b0d7ff-20c6-464e-b877-fa458f71dc3a@h11g2000prf.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1201390846 27189 80.91.229.12 (26 Jan 2008 23:40:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 26 Jan 2008 23:40:46 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jan 27 00:41:06 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JIue0-0005wg-9q for geh-help-gnu-emacs@m.gmane.org; Sun, 27 Jan 2008 00:41:04 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JIudZ-0003wV-Jt for geh-help-gnu-emacs@m.gmane.org; Sat, 26 Jan 2008 18:40:37 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!h11g2000prf.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 57 Original-NNTP-Posting-Host: 69.236.102.115 Original-X-Trace: posting.google.com 1201390226 25031 127.0.0.1 (26 Jan 2008 23:30:26 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sat, 26 Jan 2008 23:30:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: h11g2000prf.googlegroups.com; posting-host=69.236.102.115; posting-account=qPxGtQkAAADb6PWdLGiWVucht1ZDR6fn User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/523.12.2 (KHTML, like Gecko) Version/3.0.4 Safari/523.12.2, gzip(gfe), gzip(gfe) Original-Xref: shelby.stanford.edu gnu.emacs.help:155613 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:50998 Archived-At: you might be interested in the following code. It allows you to press a button, and have emacs compile the file in the current buffer. (defun run-current-file () "Execute or compile the current file. For example, if the current buffer is the file x.pl, then it'll call =E2=80=9Cperl x.pl=E2=80=9D in a shell. The file can be php, perl, python, bash, java. File suffix is used to determine what program to run." (interactive) (let (ext-map file-name file-ext prog-name cmd-str) ; get the file name ; get the program name ; run it (setq ext-map '( ("php" . "php") ("pl" . "perl") ("py" . "python") ("sh" . "bash") ("java" . "javac") ) ) (setq file-name (buffer-file-name)) (setq file-ext (file-name-extension file-name)) (setq prog-name (cdr (assoc file-ext ext-map))) (setq cmd-str (concat prog-name " " file-name)) (shell-command cmd-str))) Full explanation of this code is here: http://xahlee.org/emacs/elisp_run_current_file.html in your case, you might add: ("cpp" . "path-to-your-g++") Xah xah@xahlee.org =E2=88=91 http://xahlee.org/ =E2=98=84 On Jan 26, 8:03 am, 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 ? > -- > View this message in context:http://www.nabble.com/subsitute-for-current-f= ile-name-in-buffer-in-em... > Sent from the Emacs - Help mailing list archive at Nabble.com.