emacs with perl auto completion

I have to admit that I am programming again. Yes, again, after five or six years. Again, I am still programming perl, still under emacs. Fortunately, the language doesn’t change a lot, so do emacs.

Ok, of course emacs, but we need do some modification to make it as a good IDE. There are two auto completion modes I can find on the net, let’s talk about the details.

  1. autocomplete
    This is a Japanese designed model which has popup menu to complete the keywords. Even the project was stop 3 years ago, but the mode is still useful.
    After reading hundreds documents through the Google and put around thirty some lines into the .emacs file, I still can’t make it work. Eventually I had to get back to read the official manual and just got a hint. It was only a hint instead of a solution, but it helped. The solution is easy, just extract the zip file into site-lisp folder, normally it’s under .emacs.d folder. Then put the following lisp into the .emacs:
     (add-to-list 'load-path "~/.emacs.d/site-lisp/auto-complete-1.3.1")
     (require 'auto-complete-config)
     (add-to-list 'ac-dictionary-directories "~/.emacs.d/site-lisp/auto-complete-1.3.1/dict/")

    Until now, it won’t work. You still need a perl dictionary which is a plain text reserved keywords list. The key point is how to name the file. The package already has several dictionaries under its own dict folder and named as css-mode, ruby-mode, and etc. NONE of them will work! You have to make a copy of the dictionary files into relative extension names. For example, python-mode file has to be a file named as "py". Perl dictionary isn’t the default and has to follow the file naming rule, I prepared a pl file for you, just save as it to dict folder.

  2. perl-completion

    This one isn’t as fancy as the above, but it’s much more useful for a programmer. It also lists the keywords but is at the bottom message area. It can do some sort of syntax analyst that’s why I prefer it. This one need three modes:




    and need the following to the .emacs:

    (add-hook 'cperl-mode-hook
                (require 'perl-completion)
                (perl-completion-mode t)))

    It won’t automatically load up, so you have to ‘M-x cperl-mode’ to active it.

  3. When use those together, autocomplete doesn’t require the dictionary file. Instead, the keywords list, aka the autocomplete source, will be provided by perl-completion. And following to the .emacs, the code in 1 and 2 has to be in consequence and 3 also.

    (add-hook  'cperl-mode-hook
               (lambda ()
                 (when (require 'auto-complete nil t) ; no error whatever auto-complete.el is not installed.
                   (auto-complete-mode t)
                   (make-variable-buffer-local 'ac-sources)
                   (setq ac-sources