all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Deniz Dogan <deniz.a.m.dogan@gmail.com>
To: Marcelo de Moraes Serpa <celoserpa@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Textmate like code block alignment (ruby-mode)
Date: Tue, 6 Jul 2010 19:01:27 +0200	[thread overview]
Message-ID: <AANLkTimmh3Hm2YiaworqaQf1eHWDVk4H9TgewIpVUsbI@mail.gmail.com> (raw)
In-Reply-To: <AANLkTilzz7Z8qPah79ewfzDmA-fAOQ5sPqzP_ablBUQh@mail.gmail.com>

2010/7/6 Marcelo de Moraes Serpa <celoserpa@gmail.com>:
> Hey list,
>
> I have ruby-mode setup and it works pretty well. One thing though is
> that it doesn't automatically align blocks, and I have to type C-a TAB
> to make it align the end with a def for example:
>
> def func <when I press ENTER here>
>      |<the pointer goes here>
>
> I'd like it to behave like Textmate, where when you press enter after
> the beginning of a code block, it automatically aligns the end to like
> so:
>
> def func <when I press ENTER here>
> |<the cursor goes here, where it should be>
>
> It's really annoying having to align manually.
>
> Any ideas?
>
> Thanks in advance,
>
> Marcelo.
>
>

You could try binding RET to newline-and-indent (bound to C-j by default).

Try something like this (untested):

(add-hook 'ruby-mode-hook
  (lambda ()
    (define-key ruby-mode-map (kbd "RET") 'newline-and-indent)))

By the way, you normally don't have to move the cursor anywhere to
indent the current line. Just hit TAB with the cursor anywhere on the
line you wish to indent "correctly" and it will work just as well.

-- 
Deniz Dogan



  reply	other threads:[~2010-07-06 17:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-06 16:51 Textmate like code block alignment (ruby-mode) Marcelo de Moraes Serpa
2010-07-06 17:01 ` Deniz Dogan [this message]
2010-07-06 17:05   ` Marcelo de Moraes Serpa
2010-07-06 23:27     ` Lennart Borgman

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=AANLkTimmh3Hm2YiaworqaQf1eHWDVk4H9TgewIpVUsbI@mail.gmail.com \
    --to=deniz.a.m.dogan@gmail.com \
    --cc=celoserpa@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.
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.