unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* help with c-mode-common-hook
@ 2007-05-02 18:00 Hadron
  2007-05-02 18:22 ` Robert Thorpe
  0 siblings, 1 reply; 11+ messages in thread
From: Hadron @ 2007-05-02 18:00 UTC (permalink / raw)
  To: help-gnu-emacs


This is one of those "used to work last time I tried but now it's
broken". Maybe I messed something up in the my-compile?

I have a function which sets the compile command per C file. If a
makefile exists, use it, else use gcc.

,----
| (defun my-compile ()
|   (message "in my-compile")
|   (lambda ()
|     (unless (file-exists-p "Makefile")
|       (set (make-local-variable 'compile-command)
| 	   ;; emulate make's .c.o implicit pattern rule, but with
| 	   ;; different defaults for the CC, CPPFLAGS, and CFLAGS
| 	   ;; variables:
| 	   ;; $(CC) -c -o $@ $(GTKFLAGS) $(CPPFLAGS) $(CFLAGS) $<
| 	   (let ((file (file-name-nondirectory buffer-file-name)))
| 	     (format "%s -o %s %s %s %s %s"
| 		     (or (getenv "CC") "gcc")
| 		     (file-name-sans-extension file)
| 		     (or (getenv "GTKFLAGS") "")
| 		     (or (getenv "CPPFLAGS")"-DDEBUG=9")
| 		     (or (getenv "CFLAGS") "-std=c99 -pedantic -Wall -Werror -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion  -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -g")
| 		     file)))))
|   )
`----

which is called from my c-init

,----
| (defun my-c-init()
| 
| ;; *SNIP*
| 
|   ;;  (defvar gud-gdb-command-name "gdb -q")
|   (setq gud-gdb-command-name "gdb -q")
|  
|   (my-compile)
| 
|   )
`----

my-c-init is in turn added as c file hook:

,----
| (add-hook 'c-mode-common-hook 'my-c-init)
`----

I put "message" calls in so I know the functions are calling each other
but for some reason the compile command is staying at the default "make
-k" even if there is no makefile in the c files directory. What have I
broken? It used to work. Or something similar used to work....

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

end of thread, other threads:[~2007-05-06 18:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-02 18:00 help with c-mode-common-hook Hadron
2007-05-02 18:22 ` Robert Thorpe
2007-05-02 18:37   ` Hadron
2007-05-03  0:24     ` Hadron
2007-05-03  6:26       ` Kevin Rodgers
     [not found]       ` <mailman.158.1178174006.32220.help-gnu-emacs@gnu.org>
2007-05-03 10:08         ` Hadron
2007-05-03 14:09           ` Kai Grossjohann
     [not found]           ` <mailman.175.1178201800.32220.help-gnu-emacs@gnu.org>
2007-05-03 14:48             ` Hadron
2007-05-03 15:42               ` Kai Grossjohann
2007-05-03 17:11               ` Robert Thorpe
     [not found]               ` <mailman.180.1178207394.32220.help-gnu-emacs@gnu.org>
2007-05-06 18:29                 ` Hadron

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