Using prolog with emacs

2019-02-06 14:10发布

GNU Emacs 23.2.1
Fedora xfce 14

I starting to get into Prolog, and I want to use my emacs as the IDE for programming in Prolog.

Currently I use emacs for c/c++. But not sure how to get started with Prolog. I know that emacs has a built in library for programming in emacs. However, I have researched and found it is feature less, i.e. no syntax highlighting, indention, etc.

So I have download the emacs prackage Prolog.el. I have loaded this library using M-X Load-library.

However, I am not sure what to do after that. How do I compile my prolog files? In the menu of the emacs IDE it has nothing for Prolog.

Do I also need to download some interpretor or compiler for Prolog? Is there an emacs command for compiling? I normally use make in emacs when compiling c code.

I did a yum search prolog and got these results, so with all these choices which one do I need?:

gprolog.x86_64 : GNU Prolog is a free Prolog compiler
pl.x86_64 : SWI-Prolog - Edinburgh compatible Prolog compiler
pl-static.x86_64 : Static library for SWI Prolog
ppl-gprolog.x86_64 : The GNU Prolog interface of the Parma Polyhedra Library
ppl-gprolog-static.x86_64 : The static archive for the GNU Prolog interface of the Parma Polyhedra Library
ppl-swiprolog.x86_64 : The SWI-Prolog interface of the Parma Polyhedra Library
ppl-swiprolog-static.x86_64 : The static archive for the SWI-Prolog interface of the Parma Polyhedra Library
ppl-yap.x86_64 : The YAP Prolog interface of the Parma Polyhedra Library
yap.i686 : High-performance Prolog Compiler
yap.x86_64 : High-performance Prolog Compiler

Many thanks for any suggestions,

================== EDIT =====================

I have installed the following pl.x86_64

I have download the prolog.el and put it the following directory:

~/.emacs.d/site-lisp/prolog/prolog.el

And I have configured my emacs with the following:

;;; Prolog mode
(setq load-path (cons "~/.emacs.d/site-lisp/prolog/prolog.el" load-path))
(autoload 'run-prolog "prolog" "Start a Prolog sub-process." t)
(autoload 'prolog-mode "prolog" "Major mode for editing prolog programs." t)
(setq prolog-system 'swi) ; prolog-system below for possible values
(setq auto-mode-alist (append '(("\\.pl$" . prolog-mode))
                              auto-mode-alist))

So when I save a file as *.pl I get the prolog menu options.

So I write some prolog code and from the prolog menu, I select Run interactive prolog session

I get a second blank buffer open which says (Inferior Prolog:run Shell-Compile)

However, I am not sure what I need to do at this stage. How do I compile and run the prolog files?

Many thanks for any further support.

8条回答
forever°为你锁心
2楼-- · 2019-02-06 14:39

A more complete prolog mode can be found here: Prolog mode for (X)Emacs If you search the .el file for the string prolog-mode-keybindings or do a C-h b while in prolog mode you can see what is available.

If you install pl.x86_64: You can also use the SWI Prolog builtin editor called PceEmacs, see here: The SWI-Prolog builtin editor: PceEmacs SWI Prolog is very complete and includes a text-based debugger in addition to a graphical debugger The graphical tracer and its own GUI system The XPCE GUI system for Prolog plus a lot of libraries. It is a great prolog for exploration. If you want to instead use SWI Prolog with emacs, here is the setup Using SWI-Prolog with GNU-Emacs

查看更多
萌系小妹纸
3楼-- · 2019-02-06 14:40

If you're using the Emacs package manager, you can type M-x package-install RET prolog, and then reload Emacs.

Simple and works.

I use Fedora 15, but Emacs is its own operating system.

查看更多
登录 后发表回答