unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* C++-Mode
@ 2003-01-07 15:23 Boris H.
  2003-01-07 16:29 ` C++-Mode kgold
  2003-01-08 15:17 ` C++-Mode Dave Sumsky
  0 siblings, 2 replies; 7+ messages in thread
From: Boris H. @ 2003-01-07 15:23 UTC (permalink / raw)


Hi all!

How can I make Emacs separately
1. compile the current buffer with g++
2. run the generated file?
in C++-mode?

Boris

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C++-Mode
  2003-01-07 15:23 C++-Mode Boris H.
@ 2003-01-07 16:29 ` kgold
  2003-01-08 10:39   ` C++-Mode Boris H.
  2003-01-13  8:44   ` C++-Mode Lee Sau Dan
  2003-01-08 15:17 ` C++-Mode Dave Sumsky
  1 sibling, 2 replies; 7+ messages in thread
From: kgold @ 2003-01-07 16:29 UTC (permalink / raw)



1

The default for emacs using M-x compile is to call make.

While you could change the default, experienced programmers typically
create a makefile.

2

I typically start a shell within emacs and run the program from the
command line.

Alternatively, you could create a "run" target in the makefile,
and call "make run" from emacs.

"Boris H." <nosp@m.de> writes:

> How can I make Emacs separately
> 1. compile the current buffer with g++
> 2. run the generated file?
> in C++-mode?


-- 
Ken Goldman   kgold@watson.ibm.com   914-784-7646

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C++-Mode
  2003-01-07 16:29 ` C++-Mode kgold
@ 2003-01-08 10:39   ` Boris H.
  2003-01-08 18:18     ` C++-Mode Kevin Rodgers
  2003-01-13  8:44     ` C++-Mode Lee Sau Dan
  2003-01-13  8:44   ` C++-Mode Lee Sau Dan
  1 sibling, 2 replies; 7+ messages in thread
From: Boris H. @ 2003-01-08 10:39 UTC (permalink / raw)


kgold wrote:

> The default for emacs using M-x compile is to call make.
> 
> While you could change the default, experienced programmers typically
> create a makefile.

I know, but since I only write small programms, there's no real need for a 
makefile. 
In Ada-mode, there are commands ada-compile-application and 
ada-run-application. I want this facility in C++-mode, too.

Boris

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C++-Mode
  2003-01-07 15:23 C++-Mode Boris H.
  2003-01-07 16:29 ` C++-Mode kgold
@ 2003-01-08 15:17 ` Dave Sumsky
  1 sibling, 0 replies; 7+ messages in thread
From: Dave Sumsky @ 2003-01-08 15:17 UTC (permalink / raw)


Boris H. wrote:
> Hi all!
> 
> How can I make Emacs separately
> 1. compile the current buffer with g++
> 2. run the generated file?
> in C++-mode?
> 
> Boris
> 
> 
And how about eshell - shell for EMACS?
I use it for these simple situations ... :-)
And for easy of use, I have this shortcut defined in my .emacs:

(global-uset-key [f7])
(global-set-key [f7] 'my-eshell)

(defun my-eshell()
   (interactive)
   (if (string-match "eshell" (buffer-name))
	(switch-to-buffer w)
       (progn
	(setq w (buffer-name))
	      (eshell))))

(global-set-key [S-f7] 'eshell-command)

HTH, Dave

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C++-Mode
  2003-01-08 10:39   ` C++-Mode Boris H.
@ 2003-01-08 18:18     ` Kevin Rodgers
  2003-01-13  8:44     ` C++-Mode Lee Sau Dan
  1 sibling, 0 replies; 7+ messages in thread
From: Kevin Rodgers @ 2003-01-08 18:18 UTC (permalink / raw)


Boris H. wrote:

> kgold wrote:
>>The default for emacs using M-x compile is to call make.
>>
>>While you could change the default, experienced programmers typically
>>create a makefile.
> 
> I know, but since I only write small programms, there's no real need for a 
> makefile. 


make has implicit rules to build an executable from its source file.  So all
you should need to do in the foo.cc buffer is `M-! make foo'.  If that works,
it's just a matter of how you want to automate it:

1. Use the `M-x compile' command, with the compile-command customized as
    described in its doc string.

2. Write your own `M-x compile-buffer' command:

(defun compile-buffer (&optional buffer)
   "Compile the file visited in BUFFER (by default, the selected buffer)."
   (interactive "bCompile buffer: ")
   (or buffer
       (setq buffer (selected-buffer)))
   (save-excursion
     (set-buffer buffer)
     (compile (format "make %s" (file-name-sans-extension
				(file-name-nondirectory buffer-file-name))))))

> In Ada-mode, there are commands ada-compile-application and 
> ada-run-application. I want this facility in C++-mode, too.

Can those be easily adapted to C++?  If not, you can use the compile-buffer

example above; just use shell-command or term instead of compile.

-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C++-Mode
  2003-01-07 16:29 ` C++-Mode kgold
  2003-01-08 10:39   ` C++-Mode Boris H.
@ 2003-01-13  8:44   ` Lee Sau Dan
  1 sibling, 0 replies; 7+ messages in thread
From: Lee Sau Dan @ 2003-01-13  8:44 UTC (permalink / raw)


>>>>> "kgold" == kgold  <kgold@watson.ibm.com> writes:

    kgold> The default for emacs using M-x compile is to call make.

    kgold> While you could change the default, experienced programmers
    kgold> typically create a makefile.

With GNU make, you don't even need a Makefile for simple tasks.  Just

        make foobar

And it will compile foobar.cc automagically!


-- 
Lee Sau Dan                     李守敦(Big5)                    ~{@nJX6X~}(HZ) 

E-mail: danlee@informatik.uni-freiburg.de
Home page: http://www.informatik.uni-freiburg.de/~danlee

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: C++-Mode
  2003-01-08 10:39   ` C++-Mode Boris H.
  2003-01-08 18:18     ` C++-Mode Kevin Rodgers
@ 2003-01-13  8:44     ` Lee Sau Dan
  1 sibling, 0 replies; 7+ messages in thread
From: Lee Sau Dan @ 2003-01-13  8:44 UTC (permalink / raw)


>>>>> "Boris" == Boris H <nosp@m.de> writes:

    >> While you could change the default, experienced programmers
    >> typically create a makefile.

    Boris> I know, but since I only write small programms, there's no
    Boris> real need for a makefile.  

You don't need one if you're using GNU make.  Try:

        make foobar

and watch!  :)



-- 
Lee Sau Dan                     李守敦(Big5)                    ~{@nJX6X~}(HZ) 

E-mail: danlee@informatik.uni-freiburg.de
Home page: http://www.informatik.uni-freiburg.de/~danlee

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-01-13  8:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-07 15:23 C++-Mode Boris H.
2003-01-07 16:29 ` C++-Mode kgold
2003-01-08 10:39   ` C++-Mode Boris H.
2003-01-08 18:18     ` C++-Mode Kevin Rodgers
2003-01-13  8:44     ` C++-Mode Lee Sau Dan
2003-01-13  8:44   ` C++-Mode Lee Sau Dan
2003-01-08 15:17 ` C++-Mode Dave Sumsky

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).