[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Michael D. Vose
Mon, 28 Jan 2008 11:16:33 -0500
I added your code -- beginning with (defun mdv-reset-c-cmae ... -- and
now all is right again!
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 <email@example.com>
>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
>[ .... ]
>> 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).
- C-M-a, Michael D. Vose, 2008/01/25
- Re: C-M-a, Alan Mackenzie, 2008/01/26
- Re: C-M-a,
Michael D. Vose <=