3

I'm starting a project using Qooxdoo and emacs with js2-mode(great tool btw) but I have a little problem: no auto complete support for the qooxdoo framework classes. Currently I have auto-complete-mode enabled, but it doesn't help when I need to remember the framework classes.

Notes: - I'm using emacs 24. - If needed, I can drop auto-complete-mode and use company-mode instead.

Thanks!

Edit: To make this work, I did a little script to get the class names from the framework/source/class directory:

find . -iname '*.js' -print0 | while read -d $'\0' file
do
  grep '^qx.Class.define(".*",$' $file | sed 's/qx\.Class\.define("\(.*\)",/\1/' >> ~/.emacs.d/ac-dict/js2-mode
done

After that, just followed the answer from sanityinc everything worked as expected. Thanks!

Rafael Ibraim
  • 1,515
  • 2
  • 12
  • 13
  • Nice script, but you should be able to get away with just the file names, as there is a 1:1 relation between the qx/... path to the file and its class name (e.g. the path qx/util/ResourceManager.js contains the class qx.util.ResourceManager). Makes it a little easier. And be sure to -prune qx/test, as you don't want the unit test classes blowing up your dictionary. - Way to go! – ThomasH Jul 21 '11 at 19:52
  • @thomash Good points. If I have free time the next weeks I think I will make an improved version(the current on "stops" completing as when I type "." as in "qx.something") and post the link here and send a mail about it to the qooxdoo team. – Rafael Ibraim Jul 22 '11 at 19:36

1 Answers1

3

You can accomplish this using a user-defined dictionary based on the major mode. First, ensure your 'ac-sources includes 'ac-source-dictionary. Then, create a file containing a list of the framework class names, and save it as ~/.emacs.d/ac-dict/js (or ~/.emacs.d/ac-dict/js2-mode).

Set the following variable in your ~/.emacs (or ~/.emacs.d/init.el, if you are using that scheme instead, which you should ;-):

(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")

Restart your emacs, and then auto-completion candidates in .js files should include your class-names.

sanityinc
  • 15,002
  • 2
  • 49
  • 43