16

I recently switched to emacs for my code editing, and it mostly works well.

However, for Objective-C I find myself missing Xcode's autocomplete feature as I have trouble remembering the long function names such as

- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation screen:(NSScreen *)screen;

Is there a way to get Xcode-style autocompletion on emacs?

Also, are there any good packages to help with Cocoa or Objective-C in general that I should have?

paulmelnikow
  • 16,895
  • 8
  • 63
  • 114
cobbal
  • 69,903
  • 20
  • 143
  • 156
  • I would note that you can use Emacs keybindings in Xcode so you get some of the advantages of Emacs within Xcode. – TechZen Mar 30 '10 at 00:36
  • Untagging cocoa, since it's a lot more relevant to Objective-C, and because "Cocoa autocomplete" is something entirely different. – paulmelnikow Oct 17 '12 at 22:05

5 Answers5

9

I wrote a script to export function definitions in Cocoa SDK as yasnippet snippets: http://github.com/zegal/yasobjc

With the help with ETAGS and auto-complete, the completion experience is very close to XCode. You can have a try.

zegal
  • 91
  • 1
  • 2
  • 2
    Very clever, and super useful, I love it ! Thanks zegal – julien Sep 04 '10 at 14:49
  • 1
    Nice work! However, I wonder if it is possible to tie this into Semantic? If I know the message name, yasnippet+yasobjc are fine for completing, but what if I need to find the correct message first? Semantic could determine the type of the object in question, and present valid messages from the yasnippets. – Arne Aug 20 '11 at 22:31
5

A somewhat buggy and hacky, but very nice solution is clang-completion-mode.el found in the clang svn.

cobbal
  • 69,903
  • 20
  • 143
  • 156
3

I haven't used XCode, but emacs comes with several autocomplete modes.

See:

  • built in dabbrev-expand (M-/ runs the command dabbrev-expand which "autocompletes" partially written text)
  • AutoComplete
  • HippieExpand

Also cedet for something more sophisticated - but I don't think it works with objective-c unfortunately.

luapyad
  • 3,860
  • 26
  • 20
  • 1
    Thanks, I'm not sure any of these will work well enough though (doesn't look like any are context sensitive enough), I think I may just stick to XCode for Objective-C. – cobbal Mar 21 '09 at 23:28
1

I haven't tried it yet, but company-mode has an xcode backend that could be quite helpful:

http://nschum.de/src/emacs/company-mode/

zpinter
  • 2,232
  • 2
  • 23
  • 29
1

Edit the file auto-complete.el (look for it in the folder you installed "auto-complete" package, of course):

Goto line 165, I guarantee you know what to do already. :)

Blachshma
  • 17,097
  • 4
  • 58
  • 72
Jialong
  • 11
  • 1
  • 2
    I prefer the `M-x` customize-variable `RET` ac-mode `RET`. Or even better in you .emacs add `(setq ac-mode (cons 'objc-mode ac-mode))` – mathk Nov 22 '11 at 10:49