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

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

Re: gcc on xemacs


From: Kevin Rodgers
Subject: Re: gcc on xemacs
Date: Mon, 06 Jun 2005 10:54:05 -0600
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

arya.punit@gmail.com wrote:
> how do i compile a single c/c++ file using gcc on xemacs in the
> minibuffer. on clicking compile in menubar i get "make -k" in
> minibuffer, but i want to change this command permanently so that it
> displays "gcc -Wall" followed by the current active buffer file.c or
> file.cpp. i donot know howto edit that custom settings elisp file in a
> texteditor.

,----[ C-h v compile-command RET ]
| 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'.
`----

I think you want something like:

(add-hook 'c-mode-hook
          (lambda ()
            (set (make-local-variable 'compile-command)
                 (format "gcc -Wall %s.o"
                         (file-name-sans-extension
                          (file-name-nondirectory buffer-file-name))))))

Although make's default rules and macros will work:

(add-hook 'c-mode-hook
          (lambda ()
            (set (make-local-variable 'compile-command)
                 (format "make %s.o"
                         (file-name-sans-extension
                          (file-name-nondirectory buffer-file-name))))))

in conjunction with these shell settings:

CC=gcc; export CC
CFLAGS=-Wall; export CFLAGS

--
Kevin Rodgers





reply via email to

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