unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* auto complile the C program in the current buffer
@ 2005-02-13 18:51 GVK
  2005-02-14 18:41 ` Kevin Rodgers
  0 siblings, 1 reply; 6+ messages in thread
From: GVK @ 2005-02-13 18:51 UTC (permalink / raw)


Hello,
	I have the following lines in my .emacs for python mode

(add-hook 'python-mode-hook
           '(lambda()
              (define-key py-mode-map "\C-c\C-c" 'py-execute-prog)
              (define-key py-mode-map "\C-c\C-g" 'py-call-pdb)
              (define-key py-mode-map "\C-c\C-w" 'py-checker)))
(load "py-mode-ext.el")


When I type C-c C-c in python mode, the python program in the current 
buffer will be interepreted. How can I do the same with C? I have the 
following lines for C mode

(define-key c-mode-map "\C-c\C-c" 'compile)
(setq compile-command "gcc ")

But when I type C-c C-c, all I get in minibuffer is the line

gcc

How can I make C-c C-c compile the C prog in the current buffer?

Regards,
GVK

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

* Re: auto complile the C program in the current buffer
  2005-02-13 18:51 auto complile the C program in the current buffer GVK
@ 2005-02-14 18:41 ` Kevin Rodgers
  2005-02-15  4:17   ` GVK
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Rodgers @ 2005-02-14 18:41 UTC (permalink / raw)


GVK wrote:
 > I have the following lines for C mode
 >
 > (define-key c-mode-map "\C-c\C-c" 'compile)
 > (setq compile-command "gcc ")
 >
 > But when I type C-c C-c, all I get in minibuffer is the line
 >
 > gcc
 >
 > How can I make C-c C-c compile the C prog in the current buffer?

`C-h v compile-command' has that very example.

-- 
Kevin Rodgers

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

* Re: auto complile the C program in the current buffer
  2005-02-14 18:41 ` Kevin Rodgers
@ 2005-02-15  4:17   ` GVK
  2005-02-15 18:36     ` Kevin Rodgers
  0 siblings, 1 reply; 6+ messages in thread
From: GVK @ 2005-02-15  4:17 UTC (permalink / raw)


Kevin Rodgers wrote:
>
> `C-h v compile-command' has that very example.
> 

compile-command's value is "gcc "

Documentation:
not documented as a variable.

GVK

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

* Re: auto complile the C program in the current buffer
  2005-02-15  4:17   ` GVK
@ 2005-02-15 18:36     ` Kevin Rodgers
  2005-02-15 22:40       ` Hendrik Sattler
  2005-02-16  8:40       ` GVK
  0 siblings, 2 replies; 6+ messages in thread
From: Kevin Rodgers @ 2005-02-15 18:36 UTC (permalink / raw)


GVK wrote:
 > Kevin Rodgers wrote:
 >> `C-h v compile-command' has that very example.
 >
 > compile-command's value is "gcc "
 >
 > Documentation:
 > not documented as a variable.

I don't know how you could have deleted compile-command's doc string,
but in `emacs-21.3 -q --no-site-file -l compile`:

compile-command's value is "make -k "

Documentation:
*Last shell command used to do a compilation; default for next compilation.

Sometimes it is useful for files to supply local values for this variable.
You might also use mode hooks to specify it in certain modes, like this:

     (add-hook 'c-mode-hook
        (lambda ()
	 (unless (or (file-exists-p "makefile")
		     (file-exists-p "Makefile"))
	   (set (make-local-variable 'compile-command)
		(concat "make -k "
		        (file-name-sans-extension buffer-file-name))))))

You can customize this variable.

Defined in `compile'.

-- 
Kevin Rodgers

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

* Re: auto complile the C program in the current buffer
  2005-02-15 18:36     ` Kevin Rodgers
@ 2005-02-15 22:40       ` Hendrik Sattler
  2005-02-16  8:40       ` GVK
  1 sibling, 0 replies; 6+ messages in thread
From: Hendrik Sattler @ 2005-02-15 22:40 UTC (permalink / raw)


Kevin Rodgers wrote:

> I don't know how you could have deleted compile-command's doc string,
> but in `emacs-21.3 -q --no-site-file -l compile`:
> 
> compile-command's value is "make -k "

But that does not compile the file in the current buffer but runs the
default makefile rule (or the specified one). To compile the current
buffer, you have to aditionally specify the target file.
I guess that's not what the OP wanted.

HS

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

* Re: auto complile the C program in the current buffer
  2005-02-15 18:36     ` Kevin Rodgers
  2005-02-15 22:40       ` Hendrik Sattler
@ 2005-02-16  8:40       ` GVK
  1 sibling, 0 replies; 6+ messages in thread
From: GVK @ 2005-02-16  8:40 UTC (permalink / raw)


Kevin Rodgers wrote:
>
> 
> Sometimes it is useful for files to supply local values for this variable.
> You might also use mode hooks to specify it in certain modes, like this:
> 
>     (add-hook 'c-mode-hook
>        (lambda ()
>      (unless (or (file-exists-p "makefile")
>              (file-exists-p "Makefile"))
>        (set (make-local-variable 'compile-command)
>         (concat "make -k "
>                 (file-name-sans-extension buffer-file-name))))))
> 

Thanks a lot. I added the following lines in my .emacs and it's working.

(if
     (or (file-exists-p "makefile") (file-exists-p "Makefile"))
     (set 'compile-command "make -k ")
   (set 'compile-command (concat "gcc " buffer-file-name)))


Regards,
GVK

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

end of thread, other threads:[~2005-02-16  8:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-13 18:51 auto complile the C program in the current buffer GVK
2005-02-14 18:41 ` Kevin Rodgers
2005-02-15  4:17   ` GVK
2005-02-15 18:36     ` Kevin Rodgers
2005-02-15 22:40       ` Hendrik Sattler
2005-02-16  8:40       ` GVK

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