all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: Very simple IDE for programming newbie
Date: Sat, 02 Jan 2010 22:07:36 +0100	[thread overview]
Message-ID: <87pr5susfb.fsf@hubble.informatimago.com> (raw)
In-Reply-To: m2ws00gx0y.fsf@sean-mcafees-macbook-pro.local.i-did-not-set--mail-host-address--so-tickle-me

Sean McAfee <eefacm@gmail.com> 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 [<status-code>]) when done.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


  reply	other threads:[~2010-01-02 21:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-02 18:51 Very simple IDE for programming newbie Sean McAfee
2010-01-02 21:07 ` Pascal J. Bourguignon [this message]
2010-01-03 16:10   ` Sean McAfee
2010-01-03 16:44     ` Pascal J. Bourguignon
2010-01-03 17:17     ` Richard Riley
2010-01-03 19:24     ` Peter Dyballa
     [not found]     ` <mailman.662.1262546694.18930.help-gnu-emacs@gnu.org>
2010-01-03 21:02       ` Sean McAfee
2010-01-03 21:49         ` despen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pr5susfb.fsf@hubble.informatimago.com \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.