{"id":4249,"date":"2013-02-28T10:54:04","date_gmt":"2013-02-28T02:54:04","guid":{"rendered":"http:\/\/www.yuleshow.com\/?p=4249"},"modified":"2013-02-28T10:54:04","modified_gmt":"2013-02-28T02:54:04","slug":"emacs-with-perl-auto-completion","status":"publish","type":"post","link":"https:\/\/www.yuleshow.com\/?p=4249","title":{"rendered":"emacs with perl auto completion"},"content":{"rendered":"<p>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&#8217;t change a lot, so do emacs.<\/p>\n<p>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&#8217;s talk about the details.<\/p>\n<ol>\n<li>autocomplete      <br \/>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.       <br \/><a href=\"http:\/\/emacswiki.org\/emacs\/AutoComplete\">http:\/\/emacswiki.org\/emacs\/AutoComplete<\/a>       <br \/>After reading hundreds documents through the Google and put around thirty some lines into the .emacs file, I still can&#8217;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&#8217;s under .emacs.d folder. Then put the following lisp into the .emacs:       <br \/><code>\n<pre> (add-to-list 'load-path &quot;~\/.emacs.d\/site-lisp\/auto-complete-1.3.1&quot;)\n (require 'auto-complete-config)\n (add-to-list 'ac-dictionary-directories &quot;~\/.emacs.d\/site-lisp\/auto-complete-1.3.1\/dict\/&quot;)\n (ac-config-default)<\/pre>\n<p>    <\/code>Until now, it won&#8217;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 &quot;py&quot;. Perl dictionary isn&#8217;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. <\/li>\n<li>perl-completion<br \/>\n    <br \/>This one isn&#8217;t as fancy as the above, but it&#8217;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&#8217;s why I prefer it. This one need three modes:<br \/>\n    <br \/><a href=\"http:\/\/www.emacswiki.org\/emacs\/PerlCompletion\">http:\/\/www.emacswiki.org\/emacs\/PerlCompletion<\/a><br \/>\n    <br \/><a href=\"http:\/\/www.emacswiki.org\/emacs\/anything.el\">http:\/\/www.emacswiki.org\/emacs\/anything.el<\/a><br \/>\n    <br \/><a href=\"http:\/\/www.emacswiki.org\/emacs\/anything-match-plugin.el\">http:\/\/www.emacswiki.org\/emacs\/anything-match-plugin.el<\/a><br \/>\n    <br \/>and need the following to the .emacs: <code><\/p>\n<pre>(add-hook 'cperl-mode-hook\n          (lambda()\n            (require 'perl-completion)\n            (perl-completion-mode t)))<\/pre>\n<p>    <\/code>It won&#8217;t automatically load up, so you have to &#8216;M-x cperl-mode&#8217; to active it. <\/li>\n<li>When use those together, autocomplete doesn&#8217;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.<br \/>\n<code><\/p>\n<pre>\n(add-hook  'cperl-mode-hook\n           (lambda ()\n             (when (require 'auto-complete nil t) ; no error whatever auto-complete.el is not installed.\n               (auto-complete-mode t)\n               (make-variable-buffer-local 'ac-sources)\n               (setq ac-sources\n                     '(ac-source-perl-completion)))))\n<\/pre>\n<p><\/code>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[34,47],"tags":[146,191,201,206],"class_list":["post-4249","post","type-post","status-publish","format-standard","hentry","category-emacs","category-perl","tag-emacs","tag-mode","tag-perl","tag-programming"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.yuleshow.com\/index.php?rest_route=\/wp\/v2\/posts\/4249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yuleshow.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yuleshow.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yuleshow.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yuleshow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4249"}],"version-history":[{"count":0,"href":"https:\/\/www.yuleshow.com\/index.php?rest_route=\/wp\/v2\/posts\/4249\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yuleshow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yuleshow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yuleshow.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}