From: Alan Mackenzie <acm@muc.de>
To: help-gnu-emacs@gnu.org
Subject: Re: remap C-c C-d in C file
Date: Wed, 24 Apr 2013 22:13:14 +0000 (UTC) [thread overview]
Message-ID: <kl9ldq$284i$1@colin.muc.de> (raw)
In-Reply-To: d040c43e-92d1-4237-9a34-fba47b80d340@googlegroups.com
Rami A <rami.ammari@gmail.com> wrote:
> Greetings,
> I have these functions defined in my dotemacs file:
> ;; Duplicate entire line
> (defun paste-line ()
> "Go to beginning of next line, then yank.(eam)"
> "Note: this yanks whatever was last killed, whether it was a line,"
> " multiple lines, or part of a line."
> (interactive)
> (forward-line 1)
> (yank))
> (defun duplicate-entire-line ()
> "Copy the whole line that point is on.(eam)"
> (interactive)
> (forward-line 1)
> (let ((end (point)))
> (forward-line -1)
> (copy-region-as-kill (point) end)
> (paste-line)))
> (global-set-key "\C-c\C-d" 'duplicate-entire-line)
> So pressing C-c C-d works in assembly files and it duplicates the current line.
> However, in C files it just proceeds to delete a character.
Actually, it does c-hungry-delete-forward, which deletes all contiguous white
space characters after point, but that's by the way.
Why are you using C-c C-d here? As an Emacs convention, C-c C-<letter>
combinations are reserved for the use of major modes, so C Mode is behaving
quite correctly here. I would recommend you instead to use something like
C-c d - C-c <letter> combinations are reserved for the use of users. This
convention is documented in the Emacs Lisp manual on page "Key Binding
Conventions".
> How to remap these keys combinations to "duplicate-entire-line"?
If you really insist on this, you have to unbind C-c C-d in the C Mode
key map, since major mode key maps take priority over the global key map.
Something like this (untested) should do it:
(define-key c-mode-base-map "\C-c\C-d" nil)
> Thanks.
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2013-04-24 22:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-24 19:34 remap C-c C-d in C file Rami A
2013-04-24 22:13 ` Alan Mackenzie [this message]
2013-04-24 22:52 ` Rami A
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='kl9ldq$284i$1@colin.muc.de' \
--to=acm@muc.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.
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).