From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Michael D. Vose" Newsgroups: gmane.emacs.help Subject: Re: C-M-a Date: Mon, 28 Jan 2008 11:16:33 -0500 Message-ID: References: <20080126132840.GA4014@muc.de> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1201545722 3673 80.91.229.12 (28 Jan 2008 18:42:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 28 Jan 2008 18:42:02 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Alan Mackenzie Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 28 19:42:21 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JJYvs-0005km-Tt for geh-help-gnu-emacs@m.gmane.org; Mon, 28 Jan 2008 19:42:13 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JJYvS-0007I4-1q for geh-help-gnu-emacs@m.gmane.org; Mon, 28 Jan 2008 13:41:46 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JJWfE-0003bJ-8r for help-gnu-emacs@gnu.org; Mon, 28 Jan 2008 11:16:52 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JJWfC-0003ag-KQ for help-gnu-emacs@gnu.org; Mon, 28 Jan 2008 11:16:51 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JJWfC-0003aa-Gp for help-gnu-emacs@gnu.org; Mon, 28 Jan 2008 11:16:50 -0500 Original-Received: from gandalf.cs.utk.edu ([160.36.59.7]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JJWfC-00045w-Eo for help-gnu-emacs@gnu.org; Mon, 28 Jan 2008 11:16:50 -0500 Original-Received: from vose by gandalf.cs.utk.edu with local (Exim 4.68) (envelope-from ) id 1JJWev-0001KK-4l; Mon, 28 Jan 2008 11:16:33 -0500 In-reply-to: <20080126132840.GA4014@muc.de> (message from Alan Mackenzie on Sat, 26 Jan 2008 13:28:40 +0000) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-Mailman-Approved-At: Mon, 28 Jan 2008 13:37:43 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:51036 Archived-At: Many thanks! I added your code -- beginning with (defun mdv-reset-c-cmae ... -- and now all is right again! Michael P.S. When C-M-a puts the cursor at the opening brace, that positions the cursor properly for additional useful commands (like C-M-q, C-M-f, ...). It is the function's body that is subject to modification much more so than the functions name/signature, and therefore moving to the beginning of that body is a more useful thing for C-M-a to do (IMHO). >From: Alan Mackenzie > >Hi, Michael! > >On Fri, Jan 25, 2008 at 04:13:58PM -0500, Michael D. Vose wrote: > >> Before upgrading to GNU Emacs 22.1.1 (sorry I don't know what my old >> version was), C-M-a would behave in c-mode like it did and currently >> does in fundamental mode... specifically: if the cursor was below the >> closing brace of the body of main (see code below), then C-M-a would >> move the position of the cursor to the opening brace of the body of >> main > >[ .... ] > >> However now (in c-mode using GNU Emacs 22.1.1) C-M-a positions the >> cursor at the beginning of "int main(int argc, char *argv[])". I have >> tried to change this new behavior back to the old behavior described >> above -- I WANT THE CURSOR AT THE OPENING BRACE just where C-M-a puts >> it in fundamental mode -- by putting the following into my .emacs file > >Well, the thinking is that C-M-a should go back to "the beginning of a >top level thingy.", and that in C Mode, that's the function (or struct, >or whatever) header, not the opening brace. > >> (add-hook 'c-mode-hook >> '(lambda () >> (defvar beginning-of-defun-function nil) >> (defvar defun-prompt-regexp nil) >> (local-set-key [?\M-\C-a] 'beginning-of-defun))) > >> Unfortunately, that does not work. > >I can't see why it doesn't work, either. > >> What motivated the above attempt at restoring desired behavior was the >> fact when in fundamental mode M-x find-function-on-key reports that >> C-M-a invokes beginning-of-defun. > >find-function-on-key is a cool function! Thanks for telling me about it. > >> What can I do to make C-M-a behave in c-mode like it does in >> fundamental mode? > >For "safety"'s sake, you're probably advised to do the same to C-M-e. >Put this in your .emacs (before CC Mode gets loaded): > >(defun mdv-reset-c-cmae () > "Restore C-M-a/e, etc., to fundamental mode defaults." > (define-key c-mode-base-map "\C-\M-a" nil) > (define-key c-mode-base-map "\C-\M-e" nil)) >(add-hook 'c-initialization-hook 'mdv-reset-c-cmae) >(defun mdv-clear-c-beodf () > "Clear buffer local values of c-beginning/end-of-defun-function." > (setq beginning-of-defun-function nil > end-of-defun-function nil)) >(add-hook 'c-mode-common-hook 'mdv-clear-c-beodf) > >As a matter of interest, why do you want C-M-a to put the cursor at the >opening brace rather than the function header? > >-- >Alan Mackenzie (Nuremberg, Germany).