From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: remap C-c C-d in C file Date: Wed, 24 Apr 2013 22:13:14 +0000 (UTC) Organization: muc.de e.V. Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 X-Trace: ger.gmane.org 1366842744 2206 80.91.229.3 (24 Apr 2013 22:32:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 24 Apr 2013 22:32:24 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 25 00:32:29 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UV8Em-0005q0-8I for geh-help-gnu-emacs@m.gmane.org; Thu, 25 Apr 2013 00:32:28 +0200 Original-Received: from localhost ([::1]:48177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UV8El-0002ad-Qr for geh-help-gnu-emacs@m.gmane.org; Wed, 24 Apr 2013 18:32:27 -0400 X-Received: by 10.180.37.83 with SMTP id w19mr20374342wij.7.1366841594604; Wed, 24 Apr 2013 15:13:14 -0700 (PDT) Original-Path: usenet.stanford.edu!bx2no3586162wib.1!news-out.google.com!hg5ni23093wib.1!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!195.62.100.242.MISMATCH!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news.space.net!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 48 Original-NNTP-Posting-Host: news.muc.de Original-X-Trace: colin.muc.de 1366841594 73874 193.149.48.2 (24 Apr 2013 22:13:14 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: Wed, 24 Apr 2013 22:13:14 +0000 (UTC) User-Agent: tin/1.9.6-20101126 ("Burnside") (UNIX) (FreeBSD/8.4-PRERELEASE (amd64)) Original-Xref: usenet.stanford.edu gnu.emacs.help:198068 X-Mailman-Approved-At: Wed, 24 Apr 2013 18:32:18 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:90336 Archived-At: Rami A 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- 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 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).