From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: Very simple IDE for programming newbie Date: Sat, 02 Jan 2010 22:07:36 +0100 Organization: Informatimago Message-ID: <87pr5susfb.fsf@hubble.informatimago.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1262468457 25573 80.91.229.12 (2 Jan 2010 21:40:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 2 Jan 2010 21:40:57 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jan 02 22:40:50 2010 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 1NRBiL-0000bK-9e for geh-help-gnu-emacs@m.gmane.org; Sat, 02 Jan 2010 22:40:49 +0100 Original-Received: from localhost ([127.0.0.1]:58183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NRBiL-0005Tu-Fu for geh-help-gnu-emacs@m.gmane.org; Sat, 02 Jan 2010 16:40:49 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 125 Original-X-Trace: individual.net S6N+g8wDUNvfLQjSBoJ6vAqLQF+MgP16kxVv8A+4EYrhU/Mgh5 Cancel-Lock: sha1:ZGExMTEwY2M1OGMxODJiNTIxOGI1ZDdlMTczYzljNTMzMzczNzIyYw== sha1:SsyKD/4fYiKe3wRH8frPW8TwaHk= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.101 (Gnus v5.10.10) Emacs/22.3 (gnu/linux) Original-Xref: news.stanford.edu gnu.emacs.help:175954 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:71025 Archived-At: Sean McAfee writes: > I've started teaching my fiancée some basic C programming. After the > first few lessons on her Windows laptop, using Notepad as the editor > and a Cygwin shell for compiling and running, I decided that a more > integrated environment was called for (not to mention a more capable > editor). > > Although I use Emacs every day, I thought that it might be too > overwhelming for someone with little programming experience. If emacs can be used by american secretaries, why couldn't it be used by your fiancée? http://www.gnu.org/gnu/rms-lisp.html > [...] So, I was finally led back to > consider Emacs again. I've been working through the tutorial with > her, and her response has been quite gratifying. After learning about > Emacs's cursor-motion commands, she was excited that she'd be able to > save a lot of time at work (she's a nurse and has to enter a lot of > text using a dedicated application). I sadly had to disappoint her by > telling her that her new skills weren't widely applicable outside of > Emacs. But it was nice to see her get excited about editing text. Depends. On MacOSX, most applications do not disable the "standard" emacs keybindings of the NSTextField, so that there's no too much pain in using MacOSX applications. > So now we're just about done with the tutorial and ready to get back > into actual coding again. I've been thinking of whipping up a very > simple development environment for her, maybe as simple as a single > command that does the following: > > * Execute the compile command using "gcc this-file.c" as the command > to run. M-x compile RET this-file RET M-x recompile RET Notice that make is able to compile a single-file C program without a Makefile. > * If there were any errors, halt. (Then I teach her about > next-error). C-x ` > * Otherwise, launch the terminal emulator, killing any that might > already exist, and run the newly-compiled executable in it. M-x shell RET ./this-file Also, for non-interactive programs, you can do it at once with: M-x compile RET C-e && ./this-file RET I also use this: (defvar *compile-and-run-cflags* (let ((prefix ".")) (format "-I%s -L%s" prefix prefix))) (defun compile-and-run (mode) (interactive "p") (flet ((name (path) (when (string-match "^.*/\\([^./]*\\)\\.[^/.]*$" path) (match-string 1 path))) (type (path) (when (string-match "^.*/[^./]*\\.\\([^/.]*\\)$" path) (match-string 1 path)))) (let* ((src (buffer-file-name (current-buffer))) (compiler (or (cdr (assoc* (type src) '(("c++" . "g++") ("cpp" . "g++") ("cxx" . "g++") ("C" . "g++")) :test (function string=))) "gcc"))) (message "src=%S" src) (message "exe=%S" (name src)) (compile (format "SRC=%S ; EXE=%S ; %s %s -g3 -ggdb3 -o ${EXE} ${SRC} && %s ./${EXE} && echo status = $?" src (name src) compiler *compile-and-run-cflags* (case mode ((4) "valgrind") (otherwise ""))))))) which allows you to compile and run a single-file program with some additionnal libraries configured in *Compile-and-run-cflags*. > Something this simple should suffice for quite some time, I think. My > question is, does something similar already exist, possibly with other > useful features that I haven't thought of? There are more sophisticated features available in emacs, (eg. speedbar, cedet, etc) but frankly, 99% of my C programming in emacs is done only with those. One thing that could be useful once you get at multi-file projects, is etags and M-. > If nothing like that exists, I could use some pointers about detecting > when the (asynchronous) compile command has finished running, and > whether there were any errors. That's the one part I haven't quite > figured out how to do yet. You don't have to wait for the end of the compilation to browse the errors. Otherwise, just watch the status bar of the *compilation* window, it will say (Compilation:exit []) when done. -- __Pascal Bourguignon__ http://www.informatimago.com/