unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: A Shepard <ashepard2001@yahoo.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Stepping To Next C Function
Date: Fri, 18 Jan 2008 20:37:35 +0000	[thread overview]
Message-ID: <20080118203734.GA2634@muc.de> (raw)
In-Reply-To: <434334.85968.qm@web50202.mail.re2.yahoo.com>

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	other threads:[~2008-01-18 20:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-18 18:00 Stepping To Next C Function A Shepard
2008-01-18 20:37 ` Alan Mackenzie [this message]

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=20080118203734.GA2634@muc.de \
    --to=acm@muc.de \
    --cc=ashepard2001@yahoo.com \
    --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).