Erlang programmers are lucky because for them there is no question what language to learn next. Of course it should be Prolog. After all Erlang is “a bastard child of Scheme and Prolog”. And of course hard-core Erlang programmers use emacs :-). Are there any other text editors?
So, here are steps how to get SWI Prolog work with emacs on OS X.
1. Install SWI-prolog with brew:
brew install swi-prolog
I had a problem with brew after upgrade to Yosemite.
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory /usr/local/bin/brew: line 23: /usr/local/Library/brew.rb: Undefined error: 0
If you get the error above just edit file “/usr/local/Library/brew.rb” to point to Current version of ruby interpreter:
2. Install prolog-el mode. I use el-get, so M-x el-get-install prolog-el did a trick.
3. Add the following into your init.el:
(autoload 'run-prolog "prolog" "Start a Prolog sub-process." t) (autoload 'prolog-mode "prolog" "Major mode for editing Prolog programs." t) (autoload 'mercury-mode "prolog" "Major mode for editing Mercury programs." t) (setq prolog-system 'swi) (setq auto-mode-alist (append '(("\\.pl$" . prolog-mode) ("\\.m$" . mercury-mode)) auto-mode-alist))
To test installation, open a new buffer, change to prolog mode with M-x prolog-mode and press C-c RET. This should open prolog interpreter in inferior mode. C-c C-b allows to evaluate (“conduct”) a buffer with prolog code. C-h b – will give you all the key bindings available in prolog mode.