* Changing the Compile-Command in C/C++ Mode
@ 2006-01-27 13:43 Balaji V. Iyer
2006-01-28 0:45 ` Kevin Rodgers
0 siblings, 1 reply; 2+ messages in thread
From: Balaji V. Iyer @ 2006-01-27 13:43 UTC (permalink / raw)
Hi Everyone,
I do not always use a make file and I would like the emacs (version
21.2.1) to modify the compile-command line to "g++ -Wall -O4 filename.c. I
thought this script did the trick but it didn't. I do not get any syntax
error, but when I hit the M-x compile command I still get "make -k"
How can I fix this? If you have an alternative implementation, I am willing
to use that too.
(function
(lambda ()
(unless (or (file-exists-p "makefile")
(file-exists-p "Makefile"))
(make-local-variable 'compile-command)
(setq compile-command
(concat "gcc -Wall -O3 -o"
(file-name-sans-extension
(file-name-nondirectory buffer-file-name))
" "
(file-name-nondirectory buffer-file-name))))))
Any help is highly appreciated.
Thanking You,
Yours Sincerely,
Balaji V. Iyer.
PS. Please CC me when replying since I am not a subscribed member to this
mailing list.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Changing the Compile-Command in C/C++ Mode
2006-01-27 13:43 Changing the Compile-Command in C/C++ Mode Balaji V. Iyer
@ 2006-01-28 0:45 ` Kevin Rodgers
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Rodgers @ 2006-01-28 0:45 UTC (permalink / raw)
Balaji V. Iyer wrote:
> Hi Everyone,
> I do not always use a make file and I would like the emacs (version
> 21.2.1) to modify the compile-command line to "g++ -Wall -O4 filename.c. I
> thought this script did the trick but it didn't. I do not get any syntax
> error, but when I hit the M-x compile command I still get "make -k"
> How can I fix this? If you have an alternative implementation, I am willing
> to use that too.
>
> (function
> (lambda ()
> (unless (or (file-exists-p "makefile")
> (file-exists-p "Makefile"))
> (make-local-variable 'compile-command)
> (setq compile-command
> (concat "gcc -Wall -O3 -o"
> (file-name-sans-extension
> (file-name-nondirectory buffer-file-name))
> " "
> (file-name-nondirectory buffer-file-name))))))
If that's precisely what is in your .emacs, it doesn't accomplish
anything because all you've done is define an anonymous function without
ensuring that it will ever be called.
Since that compile-command is only useful for C files, do what the doc
string for compile-command suggests:
(add-hook 'c-mode-hook (lambda () ...))
Better yet, rely on make's default rules and macros (e.g. CC and CFLAGS):
(add-hook 'c-mode-hook
(lambda ()
(set (make-local-variable 'compile-command)
(concat "make "
(file-name-sans-extension
(file-name-nondirectory buffer-file-name))))))
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-01-28 0:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-27 13:43 Changing the Compile-Command in C/C++ Mode Balaji V. Iyer
2006-01-28 0:45 ` Kevin Rodgers
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.