使用prolog与emacs [英] Using prolog with emacs

查看:126
本文介绍了使用prolog与emacs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GNU Emacs 23.2.1
Fedora xfce 14



我开始进入Prolog,我想使用我的emacs作为在Prolog中编程的IDE。

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

目前我使用emacs进行c / c ++。但不知道如何开始使用Prolog。我知道emacs有一个内置的emacs编程库。但是,我已经研究发现它是功能较少,即没有语法高亮,缩进等。

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.

所以我已经下载了emacs prackage Prolog.el。我已经使用 MX Load-library 加载了这个库。

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

但是,我不知道该做什么。如何编译我的prolog文件?在emacs IDE的菜单中,Prolog没有任何内容。

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.

我还需要下载一些Prolog的解释器或编译器吗?有没有一个emacs命令来编译?我通常在编译c代码时使用emacs。

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.

我做了一个yum搜索序言,并得到这些结果,所以我需要一个这样的选择: / p>

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 =====================

我已经安装了以下 pl.x86_64

我已经下载了prolog.el并将其放在以下目录中:

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

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

我已经配置了我的emacs与以下:

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))

所以当我将文件保存为* .pl时,我得到了prolog菜单选项。

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

所以我写了一些prolog代码,从prolog菜单中,我选择运行交互式prolog会话

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

我得到一个第二个空白缓冲区打开,表示(Inferior Prolog:运行Shell编译)

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

然而,我不知道在这个阶段我需要做什么。如何编译和运行prolog文件?

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.

推荐答案

由于您的加载路径错误,您没有使用预期的高级 prolog.el 它应该是:

You are not using the intended advanced prolog.el, since your load path is wrong. It should read:

(setq load-path (cons "~/.emacs.d/site-lisp/prolog/" load-path))

注意我删除了 prolog.el 从路径的末尾。实际上,它应该更好地阅读:

notice that I removed prolog.el from the end of the path. Actually, it should even better read:


(add-to-list 'load-path  "~/.emacs.d/site-lisp/prolog/")

然后再次启动Emacs,它应该给你一个更多的菜单选项。 (尝试 Ch v prolog-mode-version ,仅适用于高级模式,并显示其版本号。)

Then start Emacs again, and it should give you a menu with many more options. (Try C-h v prolog-mode-version, which only works with the advanced mode, and shows its version number.)

然后,您可以尝试 Cc Cb 来查询缓冲区等。还要考虑使用 ediprolog ,您可以直接在Emacs中评估查询缓冲。还要注意,在最近的Emacs版本中,高级Prolog模式的一个变体是新的默认模式,但不幸的是出现严重的回归和缺陷,因此我建议由Stefan&Brubru维护的原始版本:

You can then try C-c C-b to consult the buffer etc. Also consider using ediprolog, with which you can evaluate queries directly in the Emacs buffer. Notice also that in recent Emacs versions, a variant of the advanced Prolog mode is the new default, but it unfortunately ships with severe regressions and flaws so that I recommend the original version maintained by Stefan Bruda:

https://bruda.ca/emacs/prolog_mode_for_emacs

https://bruda.ca/emacs/prolog_mode_for_emacs

有关Prolog和Emacs的更多信息,请参阅
使用SWI-Prolog与GNU Emacs

For more information about Prolog and Emacs, see Using SWI-Prolog with GNU Emacs.

这篇关于使用prolog与emacs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆