help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stepping To Next C Function


From: Alan Mackenzie
Subject: Re: Stepping To Next C Function
Date: Fri, 18 Jan 2008 20:37:35 +0000
User-agent: Mutt/1.5.9i

Hi, Andy!

On Fri, Jan 18, 2008 at 10:00:02AM -0800, A Shepard wrote:
> Hello:

> Is there a key mapping/function that provides the ability to step
> through a C source file to the beginning of each function?

No, not as such.  But you surely know that C-M-a goes _backwards_ to a
beginning of function.  You can give a numeric argument of -1 to C-M-a
(`c-beginning-of-defun') to make it go forward to the next function
beginning, like this:

    M-- C-M-a    (that's "Meta minus" ....)

You might find this tedious if you want to do this a lot.  In that case,
put something like this into your .emacs:

    (defun my-next-c-function ()
      "Go to start of next C function."
      (interactive)
      (c-beginning-of-defun -1))
    (defun my-c-initialization-hook
      (define-key c-mode-base-map [ ?\C-\M-\S-a ] 'my-next-c-function))
    (add-hook 'c-initialization-hook 'my-c-initialization-hook)

This will define C-M-S-a ("Control-Meta-Shift a") to do what you want -
Replace with any other key binding you prefer by adapting the second
last line.  If, like me, you use Emacs on a tty, that key binding needs
a fair amount of additional magic to work.  On X, (or MS Windows), it's
just fine.

> Thanks,

Best of luck!

> Andy...

-- 
Alan Mackenzie (Nuremberg, Germany).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]