CEldocMode

Last edit

Summary: Update source repo to git:// protocol

Changed:

< git clone https://github.com/nflath/c-eldoc

to

> git clone git://github.com/nflath/c-eldoc.git


What is it?

c-eldoc mode displays the arguments of C functions while one is programming.

git clone git://github.com/nflath/c-eldoc.git

Advantages

This version takes the function declarations from preprocessor output, thus allowing one to use it with system-dependent functions from any library. This was developed as a response to CEDET, which I was unable to use. If you know how to make this feature work in CEDET (I believe it is called ‘summary-mode’), please post the method here. This approach is somewhat simpler than that of CEDET.

Disadvantages

It currently only works with the C language.

Requirements

This file requires the new eldoc functions available in Emacs 22. You’ll also need a GNU-compatible version of grep and cpp. This shouldn’t be a problem for most people running GNU/Linux systems. I have not tested this on XEmacs yet. Please post if it works.

How do I use it?

  1. Eval (install-elisp-from-emacswiki "c-eldoc.el") if you have InstallElisp, or download Lisp:c-eldoc.el from the ElispArea and save to your emacs-lisp directory.
  2. Add the following to your .emacs file.
;; add in your commonly used packages/include directories here, for
;; example, SDL or OpenGL. this shouldn't slow down cpp, even if
;; you've got a lot of them
(setq c-eldoc-includes "`pkg-config gtk+-2.0 --cflags` -I./ -I../ ")
(load "c-eldoc")
(add-hook 'c-mode-hook 'c-turn-on-eldoc-mode)

Replaced English with installation code. You should not force users to translate English into code. – rubikitch

History

The code here makes a few changes to Paul Pogonyshev’s c-eldoc mode, originally posted on emacs-devel [1]. Paul’s version worked using TAGS, but this version has eliminated this restriction, allowing one to use it with any function that is #included at the top of the C file. It is essentially the same speed, but one no longer needs to make a large TAGS file for /usr/include. When Paul first posted, there was some talk of putting it in a future release of GNU Emacs, but I have yet to see this actually happen.

In 2010, Nathaniel Flath added caching to this file to make it usable on large projects, “like the emacs codebase”.

Bugs

I think caching symbol-info into alist or hashtable is better than calculating symbol-info EVERY TIME. It is immutable until the source file and included files are modified. – rubikitch

Nathaniel’s patch has resolved this issue. :) – MattStrange?

if you replace the grep command and the function-name pattern (2 times in the code) like below, you could get complex macros/functions working like printf or others from stdio.h.

   c-eldoc-grep "'[^a-zA-Z_0-9]"
   function-name "[\s]*('" )) 

– clabom

Call to bury-buffer added so that buffers with preprocessed content don’t show up in EasyBufferSwitch and Ido cycles. – IvanKorotkov

The preprocessed-source buffers don’t (always?) go away when the main buffer does. – KenRaeburn?

Alternatives

For another take on c-eldoc, see this article[2].


CategoryModes CategoryProgramming