all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: auto indenting code blocks
Date: Sat, 13 Jun 2015 13:55:00 +0200	[thread overview]
Message-ID: <87616rlt63.fsf@web.de> (raw)
In-Reply-To: CAP_d_8VL7yHEPgaeUYVbj=oeE5QadfrWUOR3dvmgoV9CsB_5Rw@mail.gmail.com

Yuri Khan <yuri.v.khan@gmail.com> writes:

> (defun yk-electric-ret ()
>   (interactive)
>   (if (and (looking-at "\}") (looking-back "\{")))
>       (progn
>         (newline-and-indent)
>         (save-excursion
>           (newline-and-indent))
>         (indent-according-to-mode))
>     (newline-and-indent)))
>
> (defun yk-braces-keys ()
>   (local-set-key (kbd "RET") 'yk-electric-ret))
> (add-hook 'c-mode-common-hook 'yk-braces-keys)


Shouldn't `electric-indent-mode' be able to do this?

Michael.




  reply	other threads:[~2015-06-13 11:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-13 10:40 auto indenting code blocks Sam Halliday
2015-06-13 11:25 ` Yuri Khan
2015-06-13 11:55   ` Michael Heerdegen [this message]
2015-06-13 13:14     ` Yuri Khan
2015-06-13 23:30       ` Michael Heerdegen
2015-06-14  5:24         ` Yuri Khan
     [not found]         ` <mailman.4973.1434259496.904.help-gnu-emacs@gnu.org>
2015-06-14 19:54           ` Sam Halliday
2015-06-14 19:59           ` Stefan Monnier

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=87616rlt63.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --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.