unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Lilja <mindcooler@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: Why isn't C-m listed here?
Date: Mon, 16 Apr 2007 21:38:12 +0200	[thread overview]
Message-ID: <f00jat$enu$1@sea.gmane.org> (raw)
In-Reply-To: <20070416200316.GA2655@muc.de>

Alan Mackenzie wrote:
> 'Evening, Eric!
> 
> On Mon, Apr 16, 2007 at 04:43:17PM +0200, Eric Lilja wrote:
>> Miles Bader wrote:
>>> Eric Lilja [snip quoted raw email address] writes:
>>>> As the topic says: Why isn't C-m listed here:
> 
>>>> and if it was, what would its description be? Alias for <RET>?
> 
>>> It's not an alias for RET, it _is_ RET.
> 
>>> RET == C-m
> 
>> Ok, thanks for the quick reply. So, C-m is RET which means newline. C-j 
>>  is newline-and-indent (C-m + <TAB>) so if I wanted a 
>> newline-and-indent when I press <RET> in cc mode I could do:
>> (global-set-key "\C-m" "\C-j")
>> in my c mode common hook? Proper way to do it?
> 
> You could do this, but better might be this:
> 
> (defun my-c-initialization-hook ()
>   (define-key c-mode-base-map "\C-m" 'c-context-line-break))
> (add-hook 'c-initialization-hook 'my-c-initialization-hook)
> 
> , as suggested by the (current) CC Mode manual (page "Sample .emacs
> File").  
> 
> This gives you proper continuation of comments and macros as well as
> indentation of ordinary statements.  Note also that you don't need to use
> c-mode-common-hook here - it wouldn't do any harm, but you only need to
> bind the key once, not every time you open a fresh CC Mode buffer.
> 

Thanks for your reply, Alan! Actually, this is my c-mode-common-hook 
right now (edited today but before I saw this reply):

(defun my-c-mode-common-hook ()
   ;; my customizations for all of c-mode and related modes
   (message "Running my-c-mode-common-hook")
   (setq c-basic-offset 3)
   ; Use spaces, not tabs, for indentation.
   (setq-default indent-tabs-mode nil)
   ; Replace C-m (C-m == <RET> == newline) with C-j (newline-and-indent).
   (define-key c-mode-base-map "\C-m" 'newline-and-indent)
   ; Maybe on by default on windows and off by default on solaris?
   (delete-selection-mode 1)
   ; Since this is run for php-mode we want to be able to toggle to html
   ; mode while editing a .php-file with both php and html blocks.
   ; html-mode contains a key binding to toggle to php mode.
   (define-key c-mode-base-map "\C-c\C-h" 'html-mode)
   )
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

I will try c-context-line-break and also think about which of these I 
can move into the initialization hook.

- Eric

  reply	other threads:[~2007-04-16 19:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-16 14:15 Why isn't C-m listed here? Eric Lilja
2007-04-16 14:24 ` Miles Bader
2007-04-16 14:43   ` Eric Lilja
2007-04-16 18:43     ` Alan Mackenzie
2007-04-16 19:38       ` Eric Lilja [this message]
2007-04-16 14:54   ` Drew Adams

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='f00jat$enu$1@sea.gmane.org' \
    --to=mindcooler@gmail.com \
    --cc=emacs-devel@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).