all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* using auctex key bindings in C/C++ mode
@ 2017-02-26 17:31 Sivaram Neelakantan
  2017-02-26 17:47 ` Óscar Fuentes
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sivaram Neelakantan @ 2017-02-26 17:31 UTC (permalink / raw
  To: help-gnu-emacs

I'd like to use C-c C-c for compilation and C; for commenting out code
in C/C++.  These are the default in Auctex mode.  Question is, is
there anything I'd break if use the same in C/C++ mode when writing C
code?

And is there a canonical way to unbind and rebind the defaults in
C/C++ mode?

sivaram
-- 




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: using auctex key bindings in C/C++ mode
  2017-02-26 17:31 using auctex key bindings in C/C++ mode Sivaram Neelakantan
@ 2017-02-26 17:47 ` Óscar Fuentes
  2017-02-27  2:45   ` Sivaram Neelakantan
  2017-02-26 18:36 ` Nathanael Schweers
  2017-02-27  4:40 ` Stefan Monnier
  2 siblings, 1 reply; 6+ messages in thread
From: Óscar Fuentes @ 2017-02-26 17:47 UTC (permalink / raw
  To: help-gnu-emacs

Sivaram Neelakantan <nsivaram.net@gmail.com> writes:

> I'd like to use C-c C-c for compilation and C; for commenting out code
> in C/C++.  These are the default in Auctex mode.  Question is, is
> there anything I'd break if use the same in C/C++ mode when writing C
> code?

I don't think so.

> And is there a canonical way to unbind and rebind the defaults in
> C/C++ mode?

See help for functions `local-set-key', `local-unset-key' and variable
`c-mode-common-hook'.

For instance (untested):

(defun my-c-mode-common-hook ()
  (local-set-key (kbd "C-c C-c") 'compile)
  (local-set-key (kbd "C-;") 'comment-region))

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)


For learning more, read about "Hooks" and "Key Bindinds" on the Emacs
manual.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: using auctex key bindings in C/C++ mode
  2017-02-26 17:31 using auctex key bindings in C/C++ mode Sivaram Neelakantan
  2017-02-26 17:47 ` Óscar Fuentes
@ 2017-02-26 18:36 ` Nathanael Schweers
  2017-02-27  2:44   ` Sivaram Neelakantan
  2017-02-27  4:40 ` Stefan Monnier
  2 siblings, 1 reply; 6+ messages in thread
From: Nathanael Schweers @ 2017-02-26 18:36 UTC (permalink / raw
  To: Sivaram Neelakantan; +Cc: help-gnu-emacs

Sivaram Neelakantan <nsivaram.net@gmail.com> writes:

> I'd like to use C-c C-c for compilation and C; for commenting out code
> in C/C++.  These are the default in Auctex mode.  Question is, is
> there anything I'd break if use the same in C/C++ mode when writing C
> code?

I’m not sure, as I don’t write that much C or C++ code.  You can find
out easily what those particalar bindings are for your configuration.
Just press C-h k C-c C-c to check what the current binding is (there may
be none, which would be good).  The same goes for C-h k C-;

> And is there a canonical way to unbind and rebind the defaults in
> C/C++ mode?

I’m not sure if it’s canonical; just say something like this:

(add-hook
 'c++-mode-hook
 (lambda () (define-key c++-mode-map (kbd "C-c C-c") 'compile)))

I’m not entirely sure about which exact mode you’d like to use.  I have
at least c-mode and c++-mode.  You might have to repeat the above
expression for c-mode.

Regards,
Nathanael



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: using auctex key bindings in C/C++ mode
  2017-02-26 18:36 ` Nathanael Schweers
@ 2017-02-27  2:44   ` Sivaram Neelakantan
  0 siblings, 0 replies; 6+ messages in thread
From: Sivaram Neelakantan @ 2017-02-27  2:44 UTC (permalink / raw
  To: help-gnu-emacs

On Sun, Feb 26 2017,Nathanael Schweers wrote:


[snipped 7 lines]

> I’m not sure, as I don’t write that much C or C++ code.  You can find
> out easily what those particalar bindings are for your configuration.
> Just press C-h k C-c C-c to check what the current binding is (there may
> be none, which would be good).  The same goes for C-h k C-;

Oh, I'm aware of the bindings.  What I meant was, I'm so used to
auctex bindings for compiling/commenting that I thought it would be a
good idea to use similar bindings for C/C++

>
>> And is there a canonical way to unbind and rebind the defaults in
>> C/C++ mode?
>
> I’m not sure if it’s canonical; just say something like this:
>
> (add-hook
>  'c++-mode-hook
>  (lambda () (define-key c++-mode-map (kbd "C-c C-c") 'compile)))

Thanks, will try these out

[snipped 10 lines]


sivaram
-- 




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: using auctex key bindings in C/C++ mode
  2017-02-26 17:47 ` Óscar Fuentes
@ 2017-02-27  2:45   ` Sivaram Neelakantan
  0 siblings, 0 replies; 6+ messages in thread
From: Sivaram Neelakantan @ 2017-02-27  2:45 UTC (permalink / raw
  To: help-gnu-emacs

On Sun, Feb 26 2017,Óscar Fuentes wrote:


[snipped 7 lines]

> I don't think so.

that helps.

>
>> And is there a canonical way to unbind and rebind the defaults in
>> C/C++ mode?
>
> See help for functions `local-set-key', `local-unset-key' and variable
> `c-mode-common-hook'.
>
> For instance (untested):
>
> (defun my-c-mode-common-hook ()
>   (local-set-key (kbd "C-c C-c") 'compile)
>   (local-set-key (kbd "C-;") 'comment-region))
>
> (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
>
>
> For learning more, read about "Hooks" and "Key Bindinds" on the Emacs
> manual.

Thanks, will try these out.


sivaram
-- 




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: using auctex key bindings in C/C++ mode
  2017-02-26 17:31 using auctex key bindings in C/C++ mode Sivaram Neelakantan
  2017-02-26 17:47 ` Óscar Fuentes
  2017-02-26 18:36 ` Nathanael Schweers
@ 2017-02-27  4:40 ` Stefan Monnier
  2 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2017-02-27  4:40 UTC (permalink / raw
  To: help-gnu-emacs

> I'd like to use C-c C-c for compilation and C; for commenting out code
> in C/C++.

Notice that M-; is the standard binding for commenting out code (and
various other comment operations).  That should already work in all
major modes and should hence free C-c C-c and C-; in those modes where
they redundantly use it for commenting out code (those bindings
typically date back to Emacs≤20 where M-; was much more limited).


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-02-27  4:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-26 17:31 using auctex key bindings in C/C++ mode Sivaram Neelakantan
2017-02-26 17:47 ` Óscar Fuentes
2017-02-27  2:45   ` Sivaram Neelakantan
2017-02-26 18:36 ` Nathanael Schweers
2017-02-27  2:44   ` Sivaram Neelakantan
2017-02-27  4:40 ` Stefan Monnier

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.