From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard G Riley Newsgroups: gmane.emacs.help Subject: Re: help with makefile command line Date: Thu, 27 Mar 2008 18:28:20 +0100 Organization: http://www.gnu.org/software/emacs/ Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1206639693 32413 80.91.229.12 (27 Mar 2008 17:41:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Mar 2008 17:41:33 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 27 18:42:03 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jew6m-0000IR-SA for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Mar 2008 18:41:49 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jew6B-000695-2Q for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Mar 2008 13:41:11 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!feeder.erje.net!news.motzarella.org!motzarella.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 117 Original-X-Trace: feeder.motzarella.org U2FsdGVkX1+DAAM8kPQ1Ili5QRKfVGhDGkbrauci11kZ/aqGAdy6aow+LvQifMSqVXJ/jWzx54jxJvfWU0IK/U1QMPK66Pey77y7kDRNGeU2/fQIf4o0IccfFjmBEFeX6xfxBV3TVuqVGH3Z0/LdrQ== Original-X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers Original-NNTP-Posting-Date: Thu, 27 Mar 2008 17:28:29 +0000 (UTC) X-Auth-Sender: U2FsdGVkX19MHbuUSXysoddcJhIiKFrv/jO6qEcV3IG+xos/q4XNGw== Cancel-Lock: sha1:4td7QkeLzH/v0BLEPCjNzWHdZm4= User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux) Original-Xref: shelby.stanford.edu gnu.emacs.help:157377 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:52745 Archived-At: "Balaji V. Iyer" writes: > Hello Everyone, > I use the compile option extenstively in emacs. When I type "M-x > compile" the default line is "make -k" Many times I do not have a make > file thus I would lke the default line to be > > "gcc -ansi -O4 -Wall " > > How do I do this? > > I tried the following command but it doesn't seem to work (If anyone > have a better idea please let me know). > > (function > (lambda () > (unless (or (file-exists-p "makefile") > (file-exists-p "Makefile")) > (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 greatly appreciated. > > Thanks, Here is the section from my .emacs which might be of help to you - see the f10 binding to mycompile. ,---- | (defun my-c-init() | | (line-number-mode 1) | | (setq compilation-window-height 16) | (setq compilation-finish-functions | (lambda (buf str) | (if (string-match "exited abnormally" str) | | ;;there were errors | (message "compilation errors, F11 to goto next error.") | | ;;no errors, make the compilation window go away in 0.5 seconds | ;; (run-at-time 5.0 nil 'delete-windows-on buf) | (message "NO COMPILATION ERRORS!")))) | | | (c-set-style "linux") | | (setq gdb-show-main t) | (setq gdb-many-windows t) | | (let ((dl '( | ([f1] . jump-man-page) | ; ([backtab] . semantic-complete-analyze-inline) | ;; ([f5] . find-tag-noconfirm) | ([f6] . find-tag-repeat) | ([f7] . pop-tag-mark) | ([f2] . gdb-restore-windows) | ([f3] . cscope-find-global-definition-no-prompting) | ([f4] . repeat) | ([f10] . (lambda()(interactive)(mycompile))) | ([f11] . next-error) | ([f12] . gdb)))) | (dolist (i dl) | | (define-key c-mode-base-map (car i) (cdr i)) | ;; (define-key c-mode-map (car i) (cdr i)) | ;; (define-key c++-mode-map (car i) (cdr i)) | )) | | (define-key c-mode-map | "\C-c\C-f" | 'php-search-documentation) | | (define-key c-mode-map | "\C-c\C-m" | 'php-browse-manual) | | (define-key c-mode-map | "\C-c\C-c" | 'c-browse-faq) | | (global-unset-key "\M-/") | (show-paren-mode 1) | | ) | | (add-hook 'c-mode-common-hook 'my-c-init) | | (defun mycompile() | | (unless (or (file-exists-p "makefile") | (file-exists-p "Makefile")) | (set (make-local-variable 'compile-command) | (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 -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -g") | file))) | | ) | (compile compile-command) | ) | `----