[EMAIL PROTECTED] 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



_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

Reply via email to