Re: Python syntax in Lisp and Scheme
From: Joe Marshall (jrm_at_ccs.neu.edu)
Date: 10/08/03
- Next message: Thomas F. Bur***: "Re: Python syntax in Lisp and Scheme"
- Previous message: Thomas F. Bur***: "Re: Python syntax in Lisp and Scheme"
- In reply to: Doug Tolton: "Re: Python syntax in Lisp and Scheme"
- Next in thread: Brian Downing: "Re: Python syntax in Lisp and Scheme"
- Reply: Brian Downing: "Re: Python syntax in Lisp and Scheme"
- Reply: Doug Tolton: "Re: Python syntax in Lisp and Scheme"
- Reply: Jan Rychter: "Re: Python syntax in Lisp and Scheme"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 08 Oct 2003 14:50:19 -0400
Doug Tolton <doug@nospam.com> writes:
> On Tue, 07 Oct 2003 14:01:07 GMT, prunesquallor@comcast.net wrote:
>
>>The point was that even though I screwed up the indentation, it was
>>easily discovered and repaired with Emacs. If the program were
>>whitespace-sensitive, then the screwed-up version would be
>>mechanically indistinguishable from the intended one.
>
> How do you do that with Emacs? There have been several sections of
> code that I would've like to fix this way, but I don't know the
> command.
The obvious one is
M-C-q indent-sexp
Which will re-indent the sexp based on the parenthesis and symbols
in the CAR of the list. If the resulting indentation is bogus, you
probably have an unbalanced paren or something.
But it is *very* worthwhile to learn these:
M-( insert-parenthesis
Puts in a () pair and puts point between them.
M-C-f forward-sexp
M-C-b backward-sexp
Go forward or backward by s-exp.
M-C-k kill-sexp
M-C-del backward-kill-sexp
Delete an sexp.
M-C-t transpose-sexp
swaps the sexps on either side of point, moving point to behind
the last one. This sounds random, but it allows you to `drag'
sexps around in list structure. You can get an awful lot of
milage out of this one.
M-C-@ mark-sexp
Puts mark at end of next sexp, leaves point where it is.
If your emacs is set up to highlight the current region, this
will highlight the sexp.
These next two are a bit esoteric, but also worth knowing:
C-M-u backward-up-list
Go to the beginning of the *containing* list structure.
So suppose you are in the body of a LET expression. C-M-u
will put point just before the open paren of the LET.
C-M-d down-list
Go to the beginning of the next *contained* list structure.
These ones aren't particularly lisp-specific, but rather handy in lisp
mode:
C-M-a beginning-of-defun
Takes you to the current top level defun. At this point, if you
type C-M-f (forward-sexp) you'll either end up at the end of
the current defun, or your parens aren't balanced.
C-M-/ dabbrev-completion
If you type the first few letters of a symbol and hit this,
it will attempt to complete the symbol. If it guesses wrong,
hit it again. You can save a lot of typing with this and still
use reasonably descriptive identifiers.
You should also be using font-lock-mode. I have mine set up for *extreme*
coloring (much more than the usual maximum decoration). I have found that
what happens is that I no longer pay much conscious attention to the color,
but if the color is `wrong', the code looks `funny' and I'm alerted to the
error right away.
I suggest taking a day and forcing yourself to use these commands.
It'll be slow going for a little while (an hour or two), but then
you'll get the hang of it and you'll wonder how you ever did without.
- Next message: Thomas F. Bur***: "Re: Python syntax in Lisp and Scheme"
- Previous message: Thomas F. Bur***: "Re: Python syntax in Lisp and Scheme"
- In reply to: Doug Tolton: "Re: Python syntax in Lisp and Scheme"
- Next in thread: Brian Downing: "Re: Python syntax in Lisp and Scheme"
- Reply: Brian Downing: "Re: Python syntax in Lisp and Scheme"
- Reply: Doug Tolton: "Re: Python syntax in Lisp and Scheme"
- Reply: Jan Rychter: "Re: Python syntax in Lisp and Scheme"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]