Editing Lisp Code with ErgoEmacs Keybinding without ParEdit

,

This page shows you how to edit lisp code using ErgoEmacs keybinding and without paredit mode.

For programing lisp in emacs, there's a mode called “paredit-mode”, see: ParEdit.

Jorge Dias posted in twitter, asking how to get it to work with ErgoEmacs Keybinding, because a lot keys clash.

I never tried ParEdit mode, because i'm not sure by principle it is efficient. Here's what i do.

Setting Up Bracket Highlighting

When cursor is on a bracket, the entire bracketed region is highlighted. For how to setup, see: How to Edit Lisp Code with Emacs.

Brackets Are ALWAYS Inserted/Removed in Pairs

Any brackets are ALWAYS inserted and removed in pairs. For how to setup, see: How to Edit Lisp Code with Emacs.

Navigating Brackets

To navigate nested brackets as tree structure, use built-in keys provided by GNU Emacs. e.g. 【Ctrl+Alt+】【Ctrl+Alt+】【Ctrl+Alt+】【Ctrl+Alt+】. For detail, see: How to Edit Lisp Code with Emacs.

To move cursor to previous/next brackets freely, i use custom commands with these keys {【Alt+】,【Alt+】,【Alt+】,【Alt+】}. See: Emacs: Commands and Keys to Navigate Brackets.

Selecting/Moving/Deleting Lisp Expressions

To select a lisp expression, put cursor on the beginning bracket, press the key 【Alt+8】 to select the entire expression, 【Alt+x】 to cut.

Both are in ErgoEmacs keybinding. For the code and detail, see:

Remove Empty Lines; Compact Ending Brackets

To remove empty lines, type 【Alt+w】 (shrink-whitespaces)

To compact ending brackets, place your cursor there then press 【Alt+q】 (compact-uncompact-block)

Pretty Format Lisp Code

When you need to make the format pretty, do them in batch on a region. Select text or whole file, then use the built-in command 【Ctrl+Alt+\】 (indent-region).

One principle i adhere is this: programers should NEVER HAVE TO SPEND EFFORT TO MANUALLY PRETTY FORMAT CODE. In particular, never on a line-by-line basis.

Ideally, the formatting should be done automatically, as in auto-fill-mode and Mathematica. I haven't coded this in ErgoEmacs yet. See:

elisp abbrev + yasnippet + auto-complete-mode

For name completion and function templates, i use {elisp abbrev, auto-complete-mode, yasnippet}, all are bundled and with ErgoEmacs and already configured.

blog comments powered by Disqus