在 emacs 中使用 prolog [英] Using prolog with emacs
问题描述
GNU Emacs 23.2.1Fedora xfce 14
我开始接触 Prolog,我想使用我的 emacs 作为在 Prolog 中编程的 IDE.
目前我将 emacs 用于 c/c++.但不确定如何开始使用 Prolog.我知道 emacs 有一个用于在 emacs 中编程的内置库.但是,我研究发现它的功能较少,即没有语法高亮、缩进等.
所以我已经下载了emacs prackage Prolog.el.我已经使用 M-X Load-library
加载了这个库.
但是,我不确定在那之后该怎么做.如何编译我的 prolog 文件?在 emacs IDE 的菜单中,Prolog 没有任何内容.
我是否还需要为 Prolog 下载一些解释器或编译器?是否有用于编译的 emacs 命令?我一般在 emacs 中编译 c 代码时使用 make.
我做了一个 yum 搜索序言并得到了这些结果,那么在所有这些选择中我需要哪一个?:
gprolog.x86_64 : GNU Prolog 是一个免费的 Prolog 编译器pl.x86_64 : SWI-Prolog - 爱丁堡兼容的 Prolog 编译器pl-static.x86_64:SWI Prolog 的静态库ppl-gprolog.x86_64:帕尔马多面体库的 GNU Prolog 接口ppl-gprolog-static.x86_64 :帕尔马多面体库的 GNU Prolog 接口的静态存档ppl-swiprolog.x86_64:Parma 多面体库的 SWI-Prolog 接口ppl-swiprolog-static.x86_64:Parma 多面体库的 SWI-Prolog 接口的静态存档ppl-yap.x86_64:Parma 多面体库的 YAP Prolog 接口yap.i686:高性能 Prolog 编译器yap.x86_64 : 高性能 Prolog 编译器
非常感谢您的任何建议,
================== 编辑 ======================
我已经安装了以下 pl.x86_64
我已经下载了 prolog.el 并将其放在以下目录:
~/.emacs.d/site-lisp/prolog/prolog.el
我已经使用以下内容配置了我的 emacs:
<代码>;;;序言模式(setq 加载路径(缺点~/.emacs.d/site-lisp/prolog/prolog.el"加载路径))(autoload 'run-prolog "prolog" "Start a Prolog sub-process." t)(autoload 'prolog-mode "prolog" "编辑 prolog 程序的主要模式." t)(setq prolog-system 'swi) ;下面的序言系统可能的值(setq auto-mode-alist (append '(("\.pl$" . prolog-mode))自动模式列表))
所以当我将文件另存为 *.pl 时,我会得到 prolog 菜单选项.
所以我写了一些 prolog 代码,然后从 prolog 菜单中选择 Run interactive prolog session
我打开了第二个空白缓冲区,上面写着 (Inferior Prolog:run Shell-Compile)
但是,我不确定现阶段需要做什么.如何编译和运行 prolog 文件?
非常感谢您的进一步支持.
您没有使用预期的高级 prolog.el
,因为您的加载路径是错误的.它应该是:
(setq load-path (cons "~/.emacs.d/site-lisp/prolog/" load-path))
请注意,我从路径的末尾删除了 prolog.el
.实际上,它应该更好地阅读:
然后再次启动 Emacs,它应该会为您提供一个包含更多选项的菜单.(试试C-h v prolog-mode-version
,它只适用于高级模式,并显示其版本号.)
然后您可以尝试 C-c C-b
查询缓冲区等.还可以考虑使用 ediprolog,您可以使用它直接在 Emacs 缓冲区中评估查询.还要注意,在最近的 Emacs 版本中,高级 Prolog 模式的一个变体是新的默认模式,但不幸的是它带有严重的回归和缺陷,所以我推荐由 Stefan Bruda 维护的原始版本:
https://bruda.ca/emacs/prolog_mode_for_emacs
有关 Prolog 和 Emacs 的更多信息,请参阅在 GNU Emacs 中使用 SWI-Prolog.
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.
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))
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/")
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.)
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
For more information about Prolog and Emacs, see Using SWI-Prolog with GNU Emacs.
这篇关于在 emacs 中使用 prolog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!