<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.mozilla.org/index.php?action=history&amp;feed=atom&amp;title=User%3AVladVukicevic%2FEmacsClangComplete</id>
	<title>User:VladVukicevic/EmacsClangComplete - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.mozilla.org/index.php?action=history&amp;feed=atom&amp;title=User%3AVladVukicevic%2FEmacsClangComplete"/>
	<link rel="alternate" type="text/html" href="https://wiki.mozilla.org/index.php?title=User:VladVukicevic/EmacsClangComplete&amp;action=history"/>
	<updated>2026-06-14T01:56:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.10</generator>
	<entry>
		<id>https://wiki.mozilla.org/index.php?title=User:VladVukicevic/EmacsClangComplete&amp;diff=432042&amp;oldid=prev</id>
		<title>VladVukicevic: Created page with &quot;Clang is neat.  clang-complete is neater, and more importantly, seems to work fine with Gecko with a bit of setup.  Here&#039;s what I did under linux with emacs.  http://i.imgur.com/...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.mozilla.org/index.php?title=User:VladVukicevic/EmacsClangComplete&amp;diff=432042&amp;oldid=prev"/>
		<updated>2012-05-17T15:41:24Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Clang is neat.  clang-complete is neater, and more importantly, seems to work fine with Gecko with a bit of setup.  Here&amp;#039;s what I did under linux with emacs.  http://i.imgur.com/...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Clang is neat.  clang-complete is neater, and more importantly, seems to work fine with Gecko with a bit of setup.  Here&amp;#039;s what I did under linux with emacs.&lt;br /&gt;
&lt;br /&gt;
http://i.imgur.com/z7S9W.png&lt;br /&gt;
&lt;br /&gt;
* Install clang  (apt-get install clang)&lt;br /&gt;
* Install [http://cx4a.org/software/auto-complete/ auto-complete mode]&lt;br /&gt;
* Grab [https://raw.github.com/brianjcj/auto-complete-clang/master/auto-complete-clang.el auto-complete-clang.el]&lt;br /&gt;
* Install [http://code.google.com/p/yasnippet/ yasnippet]&lt;br /&gt;
* Make &amp;lt;tt&amp;gt;~/bin/clang-moz-flags&amp;lt;/tt&amp;gt; and make it executable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ -z &amp;quot;$1&amp;quot; ] ; then&lt;br /&gt;
  TARGET=firefox&lt;br /&gt;
else&lt;br /&gt;
  TARGET=$1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
SRCDIR=&amp;quot;`pwd`&amp;quot;&lt;br /&gt;
OBJDIR=`echo $SRCDIR | sed s,mozilla-central,$TARGET,`&lt;br /&gt;
&lt;br /&gt;
make -C $OBJDIR showbuild 2&amp;gt;&amp;amp;1 | awk &amp;#039;&lt;br /&gt;
   BEGIN { ORS=&amp;quot; &amp;quot;; }&lt;br /&gt;
   /^COMPILE_CXXFLAGS / {&lt;br /&gt;
      gsub(/-I\.\./,&amp;quot;-I&amp;#039;$OBJDIR&amp;#039;/..&amp;quot;);&lt;br /&gt;
      gsub(/ \.\./,&amp;quot; &amp;#039;$OBJDIR&amp;#039;/..&amp;quot;);&lt;br /&gt;
      for (f=1;f&amp;lt;=NF;f++) {&lt;br /&gt;
        if ($f ~ /^-[ID]/) print $f;&lt;br /&gt;
	if ($f ~ /^-include/) { print $f; print $(f+1); }&lt;br /&gt;
	#if ($f ~ /^-isystem/) { print $f; print $(f+1); }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&amp;#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In your &amp;lt;tt&amp;gt;.emacs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
;; yasnippet&lt;br /&gt;
(require &amp;#039;yasnippet)&lt;br /&gt;
(yas/global-mode 1)&lt;br /&gt;
&lt;br /&gt;
;; clang autocomplete&lt;br /&gt;
(require &amp;#039;auto-complete-config)&lt;br /&gt;
(require &amp;#039;auto-complete-clang)&lt;br /&gt;
&lt;br /&gt;
(setq moz-ac-objdir &amp;quot;fx-android-debug&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
(defun moz-ac-set (objdir-name)&lt;br /&gt;
  (interactive &amp;quot;sObjdir name to switch completion to: &amp;quot;)&lt;br /&gt;
  (if (not (eq moz-ac-objdir objdir-name))&lt;br /&gt;
      (setq moz-ac-objdir objdir-name)&lt;br /&gt;
      (ac-clang-set-cflags-from-shell-command (concat &amp;quot;~/bin/clang-moz-flags &amp;quot; objdir-name)))&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
(setq ac-auto-start nil)&lt;br /&gt;
(setq ac-quick-help-delay 0.5)&lt;br /&gt;
;(ac-set-trigger-key &amp;quot;TAB&amp;quot;)&lt;br /&gt;
(define-key ac-mode-map  [(control tab)] &amp;#039;auto-complete)&lt;br /&gt;
(defun my-ac-config ()&lt;br /&gt;
  (setq-default ac-sources &amp;#039;(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))&lt;br /&gt;
  (add-hook &amp;#039;emacs-lisp-mode-hook &amp;#039;ac-emacs-lisp-mode-setup)&lt;br /&gt;
  (add-hook &amp;#039;c-mode-common-hook &amp;#039;ac-cc-mode-setup)&lt;br /&gt;
  (add-hook &amp;#039;css-mode-hook &amp;#039;ac-css-mode-setup)&lt;br /&gt;
  (add-hook &amp;#039;auto-complete-mode-hook &amp;#039;ac-common-setup)&lt;br /&gt;
  (global-auto-complete-mode t))&lt;br /&gt;
(defun my-ac-cc-mode-setup ()&lt;br /&gt;
  (setq ac-sources (append &amp;#039;(ac-source-clang ac-source-yasnippet) ac-sources)))&lt;br /&gt;
(add-hook &amp;#039;c-mode-common-hook &amp;#039;my-ac-cc-mode-setup)&lt;br /&gt;
;; ac-source-gtags&lt;br /&gt;
(my-ac-config)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Then, open a source file and do &amp;lt;tt&amp;gt;M-x moz-ac-set&amp;lt;/tt&amp;gt; and give it an objdir name.  The above stuff assumes that your objdirs are alongside your mozilla-central dir (not inside it, because you shouldn&amp;#039;t do that, that&amp;#039;s gross, stop being gross); if you&amp;#039;re doing something else, you&amp;#039;ll need to tweak the above.  Same with mozilla-central not being your source tree name.&lt;br /&gt;
* Hit control-tab to autocomplete!&lt;br /&gt;
* If something goes wrong, look at the *clang-output* buffer.&lt;/div&gt;</summary>
		<author><name>VladVukicevic</name></author>
	</entry>
</feed>