Skip to content

An Emacs dynamic module to interface with libclang.

Notifications You must be signed in to change notification settings

nealsid/elclang

Repository files navigation

elclang

elclang is an Emacs dynamic module to interface with libclang. It only builds on macOS 12 right now, because it references header files for building Emacs modules directly from the Emacs.app bundle. It also requires LLVM installed by Homebrew (there will probably be forthcoming changes to support building against LLVM/libclang from a different directory in order use different or custom versions), as well as Ninja. However, because I am too lazy to upgrade Emacs on my laptop, I can say it has been tested on both Emacs 26 & Emacs 27.

Compile with (tested on macOS 12.2 beta 21D5025f):

$ git clone https://github.com/nealsid/elclang
$ cd elclang && mkdir build && cd build
$ cmake ../
$ ninja elclang

It doesn't do anything, but you can load it with:

$ /Applications/Emacs.app/Contents/MacOS/Emacs -nw -q -execute "(module-load \"elclang.dylib\")"

I suggest starting a new Emacs because there is no way to unload modules currently (also, it really isn't useful right now). Once inside Emacs, you can do something like M-: (elclang-initialize-build-tree "some build tree with compile_commands.json").

Demo

This simple demo sets up a timer in Emacs that fires every 100 milliseconds. It queries libclang for the CXCursor that surrounds the point, and highlights it. I used a timer, rather than querying on every keystroke, to minimize impact on user interaction, and I believe that Emacs does some special scheduling to ensure timer functions don't slow down interactive editing.

Demo

About

An Emacs dynamic module to interface with libclang.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published