2012年10月1日 星期一

Emacs for objective-c development

Emacs for obj-C development.md

To develop GNUStep program under Debian, we need 2 handy tools:

1. Auto complete for obj-c.
2. Source browsing.

For the first one, emacs has auto complete package support for after Emacs24. If you are using Debian wheezy, you have to build from source. Before compile, the pre-requisite packages are:

 $ sudo aptitude install build-essential libxpm-dev libgif-dev libtiff-dev libjpeg-dev libgtk2.0-dev libdbus-1-dev texinfo

Build with these pre-requisite packages can let your emacs customise the X fonts easily. And the build commands are :

$ ./configure --with-x-toolkit --with-xft
$ make
$ sudo make install

ps.: It seems that the default configuration does the same work.

The default install directory is /usr/local/bin.

Since Emacs24, in emacs package provides a convient way to install e-lisp plug-ins, add the following lines in your .emacs :

(require 'package)
(add-to-list 'package-archives 
    '("marmalade" .
    "http://marmalade-repo.org/packages/"))
(package-initialize)
(add-to-list 'load-path "~/.emacs.d")    ; This may not be appeared if you have already added.

Now open emacs, install the auto-complete package by :

M-x package-install [RET] auto-complete [RET]

After that, append the following lines in your .emacs

(require 'auto-complete-config)
(ac-config-default)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/elpa/auto-complete-1.4/dict")
(add-to-list 'ac-modes 'objc-mode) ;;here load the objc-mode

Note : Here the version is 1.4, modify the version if necessary.

OK, now we should have the emacs support auto-complete for obj-c.

For the second one: Source browsing, can be done with Gnu Global (gtags).

Since the Debian/Ubuntu currently provide Global-5.7.1, which does not support '--encode-path' option, the option will be used in the plug-in. We have to build Global-6.2.4 from source then "configure" "make install", and complete the setup by copying gtags.el to ~/.emacs.d and append :

(add-to-list 'load-path "~/.emacs.d")    ; This may not be appeared if you have already added.
(autoload 'gtags-mode "gtags" "" t)

After that, the gtags command will be setup correctly. #

沒有留言:

張貼留言