From: Drew Adams <drew.adams@oracle.com>
To: Andrey Tykhonov <atykhonov@gmail.com>, help-gnu-emacs@gnu.org
Subject: RE: Break code lines fluently
Date: Wed, 12 Mar 2014 07:25:07 -0700 (PDT) [thread overview]
Message-ID: <ea4c5f29-0181-4986-b283-ac51e0bbbfdd@default> (raw)
In-Reply-To: <87wqg0t1jz.fsf@gmail.com>
> (defun test ()
> (let ((test t))
> (if test
> (message "True")
> (mes|sage "False"))))
> Point is located in the middle of "message" function. And I would like to
> insert more code to the `let' form (after the `if').
Here is one approach:
C-- 2 C-M-u RET
C-M-u is `backward-up-list'. You give it a negative prefix arg to go
forward instead of backward. -2 means go forward and up past (-1) the
`message' sexp and then (-2) past the `if' sexp. RET then indents
(with recent Emacs dev snapshots - use C-j with older versions).
If you don't want to count, just repeat C-- C-M-u until you get where
you want to go.
You can also bind `up-list' to a key, and use that to do the same
thing as C-M-u with a negative arg. E.g.
M-x global-set-key C-o RET up-list RET
C-o C-o RET ; move up & forward 2 list levels, then newline & indent
The real advantage of binding a key to `up-list' is that you can
just hold that key (C-o or whatever) down until you get where you
want (the same as you can do with `backward-up-list', C-M-u).
Prefix key `C-M-' introduces Lisp stuff in Emacs-Lisp mode, including
commands that move over lists: e.g., C-M-u, C-M-d, C-M-n, C-M-p. And
commands that move over sexps, whether lists or not: C-M-f, C-M-b.
Others will no doubt give you other ways, in particular that make use
of 3rd-party libraries. There are many ways to skin this cat.
(If you use a mouse, you can of course also just click where you want
to insert the newline: direct access. That's sometimes easier or
quicker, since you can see the destination and you don't need to move
there incrementally or by counting list levels. But it does take one
hand off the keyboard.)
next prev parent reply other threads:[~2014-03-12 14:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-12 5:42 Break code lines fluently Andrey Tykhonov
2014-03-12 10:07 ` Andreas Röhler
2014-03-12 14:25 ` Drew Adams [this message]
2014-03-12 15:55 ` Drew Adams
2014-03-13 0:14 ` Andrey Tykhonov
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ea4c5f29-0181-4986-b283-ac51e0bbbfdd@default \
--to=drew.adams@oracle.com \
--cc=atykhonov@gmail.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).