简体   繁体   English

如何以及在何处为 Ubuntu 上的 sbcl / slime / emacs 设置默认加载位置 18

[英]How and where to set the default load location for sbcl / slime / emacs on Ubuntu 18

I have emacs / sbcl / slime working.我有 emacs / sbcl / slime 工作。

I'm going through a tutorial and hit the following example:我正在阅读教程并点击以下示例:

CL-USER> (load "hello.lisp")
; Loading /home/peter/my-lisp-programs/hello.lisp

The author doesn't specify how or where he set things up to default the load location to his example.作者没有指定他如何或在哪里设置默认加载位置到他的示例。

I've tried creating the EMACSLOADPATH environment variable and have tried a setq for load-path all with no positive results.我已经尝试创建 EMACSLOADPATH 环境变量,并尝试了一个 setq 的加载路径,但都没有积极的结果。

If I load a.lisp file using the entire path as in /home/bill/lisp/hello.lisp, it load and I can run it.如果我使用 /home/bill/lisp/hello.lisp 中的整个路径加载 a.lisp 文件,它会加载并且我可以运行它。 Id like to know how and where to set the default to "~/lisp" so I can avoid an absolute path reference.我想知道如何以及在哪里将默认设置为“~/lisp”,这样我就可以避免绝对路径引用。

Before the answer, EMACSLOADPATH (or load-path) isn't related to common-lisp or sbcl (which is a common-lisp implementation).在回答之前,EMACSLOADPATH(或加载路径)与 common-lisp 或 sbcl(这是一个 common-lisp 实现)无关。 It is an emacs related variable.它是一个 emacs 相关变量。 The root of the confusion is understandable, as emacs is a tool build on its own variant of lisp, elisp, and you write elisp code to extend or configure emacs.混淆的根源是可以理解的,因为 emacs 是基于其自己的 lisp、elisp 变体构建的工具,您编写 elisp 代码来扩展或配置 emacs。 Emacs tool has its own elisp engine that runs those elips commands. Emacs 工具有自己的 elisp 引擎来运行这些 elips 命令。 And then you start using emacs as an editor to write common-lisp code, using plugins like slime to make it easier to interact with sbcl interpreter (or any other slime compatible common-lisp interpreter, for that matter).然后你开始使用 emacs 作为编辑器来编写 common-lisp 代码,使用像 slime 这样的插件来更容易与 sbcl 解释器(或任何其他兼容 slime 的 common-lisp 解释器)交互。

For the default load location of common-lisp, load function of sbcl uses *default-pathname-defaults* to form the pathname from the argument, and it is generally set to the current directory (by slime at least - check swank:set-default-directory).对于 common-lisp 的默认加载位置,加载 sbcl 的 function 使用 *default-pathname-defaults* 从参数中形成路径名,一般设置为当前目录(至少通过 slime-check swank:set-默认目录)。

However, if you want an approach similar to python's import, where the function uses a list of directories to search for, I believe there are two options to start with.但是,如果您想要一种类似于 python 的导入的方法,其中 function 使用目录列表进行搜索,我相信有两个选项可以开始。

  1. Use quicklisp or asdf, as they are equivalent to python-import, but that probably means you define a 'system' (python: 'module') and use asdf:load-system.使用 quicklisp 或 asdf,因为它们等同于 python-import,但这可能意味着您定义了一个“系统”(python:“模块”)并使用 asdf:load-system。 Here is an answer for this solution: example of using external libs in common-lisp这是此解决方案的答案: 在 common-lisp 中使用外部库的示例
  2. Write a load function yourself, and search for a predefined list of directories for the file name, and form an absolute path then call cl:load with the absolute path you decide.自己编写一个加载 function 并搜索文件名的预定义目录列表,并形成一个绝对路径,然后使用您决定的绝对路径调用 cl:load。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM