.emacs、automake 和 cmake
很久以前,当我编写 .emacs 设置 [1] 时,我使用了 shell 脚本来编译并加入整个内容。这个东西现在已经很旧而且“硬壳”了,所以我现在正在重写它以替换诸如以下的东西:
(defmacro make-new-comment( mode face strcom color1 color2)
(list 'progn
`(make-face ',face)
`(if (not (assoc ,strcom ,(intern (concat (symbol-name mode) "-comments-alist"))))
(setf ,(intern (concat (symbol-name mode) "-comments-alist"))
(append ,(intern (concat (symbol-name mode) "-comments-alist")) '((,strcom . ,face)))
)
)
`(modify-face ',face ,color1 ,color2 nil t nil nil nil nil)
)
)
并且我发生了一些事情。编译时,我访问几个环境变量,提供有关系统的信息,例如[2],某些使用 comint[3] 的模式调用的大多数程序的全名。我可以使用一些类似于 autoconf 的工具来调整 .emacs 文件,然后编译它们,而不是读取环境变量。
问题是 autoconf 实在是太丑了。我考虑过 cmake,但文档非常差,尤其是在构建自己的构建系统方面。我不熟悉替代系统。
建议?
[1]:为了明确起见,我所说的 .emacs 设置是指我拥有的 30 个左右的文件和两个代码子目录。更不用说几个软件包(在包含时)不属于标准 emacs 发行版的一部分。
[2] 我用“”替换了eg,因为显然很多人不知道eg意味着例如。要么就是他们不知道什么是例子。
[3] 例如 diff 模式、ruby 模式。
A long time ago,when I wrote my .emacs setup[1], I used a shell script to compile and join the whole thing. The thing is now very old and "crusty", so I am now rewriting it to replace things such as:
(defmacro make-new-comment( mode face strcom color1 color2)
(list 'progn
`(make-face ',face)
`(if (not (assoc ,strcom ,(intern (concat (symbol-name mode) "-comments-alist"))))
(setf ,(intern (concat (symbol-name mode) "-comments-alist"))
(append ,(intern (concat (symbol-name mode) "-comments-alist")) '((,strcom . ,face)))
)
)
`(modify-face ',face ,color1 ,color2 nil t nil nil nil nil)
)
)
and something occured to me. When compiling I access several environmental variables giving information about the system, for example[2], the full name of most programs called by some mode that uses comint[3]. Rather then reading environmental variables, i could use some autoconf like tool to tweak the .emacs files and then compile them.
The problem is that autoconf is just plain ugly. I considered cmake, but the documentation is very poor especially on constructing your own build system. I'm not familar with alternate systems.
Suggestions?
[1]: To make clear, by .emacs setup I mean the 30 or so files and two subdirs of code that I have. Not to mention several packages that ( well at the time of inclusion ) are not part of the standard emacs distribution.
[2] I've replaced eg with "" since apparently many people do not know that eg means for example. Either that or they don't know what an example is.
[3] Such as diff-mode, and ruby-mode.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
哪个差异
?更多细节在这里会很有用。这些环境变量是你自己设置的吗?或者你的发行版提供的东西?
有点讽刺的是,听起来令人怀疑 emacs 极其强大的内置脚本正是您所寻找的。
which diff
?More details would be useful here. Are these environment variables that you set yourself? or things provided by your distro?
Somewhat ironically, it sounds suspiciously like emacs' incredibly powerful built-in scripting is what you're looking for.
我同意 jkerian 的观点:你为什么要用零件组装 .emacs?这就是我所做的:按语言或功能将其分解,并使用
require
和provide
。我的 .emacs 看起来像:~/elisp/personal
中的每个单独文件设置对某种语言或其他内容的支持,然后提供
sjdk-whatever.这是 jdk-lua.el:
请注意,我将所有 elisp 包保存在 ~/elisp/packages 中。这意味着我可以将 .emacs 和 ~/elisp 目录复制到任何地方并使其立即工作。
I agree with jkerian: why are you assembling your .emacs from parts? Here is what I do: break it down by language or feature and use
require
andprovide
. My .emacs looks like:Each individual file in
~/elisp/personal
then sets up support for a language or whatever, thenprovide
sjdk-whatever
. Here is jdk-lua.el:Notice that I keep all elisp packages in ~/elisp/packages. This means I can copy my .emacs and ~/elisp directory just about anywhere and have it work straight away.
据我了解,您需要一个脚本来自动检测您的工具(如 diff、grep...)在哪里,而不是通过环境变量手动告诉您的 .emacs 它们在哪里。
如果您使用的是类 UNIX 平台,那么所有工具(例如 diff、grep)都应该已经在您的 PATH 中,并且 emacs 应该可以毫无问题地找到它们。因此,在 .emacs 中,您不应使用任何环境变量,而应直接将工具名称放入配置中。
如果您的目标是制作一个可以在 Windows 上执行的可移植 .emacs,那么您应该放置所有 gnuwin32 工具 也在你的 PATH 中,这样 emacs 就可以毫无问题地找到它们。但对于 Windows,您必须做许多其他微小的安排才能使 emacs 命令像在 UNIX 系统上一样正常工作。
使用像 autoconf 这样的工具是一件非常耗时的事情,而通过自定义一个 .emacs 文件就可以很好地处理这些事情。如果您要为特定系统执行特定操作,您可以编写如下 elisp 代码:
另外,如果您想自动执行所有 .el 文件的字节编译,您可以在 shell 上使用如下命令:
From what I understand, you want a script to autodetect where are your tools (like diff, grep...) instead of manually telling your .emacs where they are through environment variables.
If you are on a unix-like platform, all your tools like diff, grep, should already be on your PATH and emacs should have no problem finding them. So, in your .emacs you should not use any environment variable and put directly tools name in your configuration.
If your goal is to make a portable .emacs that could be executed on Windows for example, then you should put all the gnuwin32 tools in your PATH too, so that emacs find them without problem. But for Windows, you'll have to do many other tiny arrangements for emacs commands to work properly as on a unix system.
Using a tool like autoconf is something very time-consuming for something that could be well handled by customizing one single .emacs file. If you have specific things to do for a particular system, you could write elisp code like this :
Also, if you want to automate the byte compilation of all your .el files, you could use a command like this on your shell :