【发布时间】:2019-02-28 14:08:43
【问题描述】:
我使用 python3 pweave 库 (http://mpastell.com/pweave/usage.html) 进行文学编程。
pweave 用作文本模式 markdown,用作代码模式 python3, 并且可以使用 noweb (https://en.wikipedia.org/wiki/Noweb) 识字的编程语法。
为了在 emacs 中正确突出显示语法,我打算使用 polymode 库(https://polymode.github.io/ 和 https://github.com/polymode)。
我使用 emacs 版本 26.1。 而且我能够从 melpa 安装 polymode。
不幸的是,没有预先存在的多模 主机模式:markdown,内部模式:python3,语法:noweb 所以我尝试根据文档和现有代码编写我的 poly-pweave-mode,将以下 lisp 代码放入我的 .emacs 文件中。
(require 'polymode-classes)
(defcustom pm-host/pweave-text
(pm-host-chunkmode :name "pweave-text"
:mode 'markdown-mode)
"markdown host chunkmode"
:group 'poly-hostmodes
:type 'object)
(defcustom pm-inner/pweave-code
(pm-inner-chunkmode :name "pweave-code"
:head-matcher "^[ \t]*<<\\(.*\\)>>="
:tail-matcher "^[ \t]*@.*$"
:mode 'python-mode)
"noweb static python3 inner chunkmode."
:group 'poly-innermodes
:type 'object)
(define-polymode poly-pweave-mode
:hostmode 'pm-host/pweave-text
:innermode 'pm-inner/pweave-code)
(add-to-list 'auto-mode-alist '("\\.pymd" . poly-pweave-mode))
但不知何故,emacs 不吃这个。 当我打开 emacs 时,出现以下错误:
Warning (initialization): An error occurred while loading `/Users/abc/.emacs':
Symbol's function definition is void: pm-host-chunkmode
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
我做错了什么? 如何运行所需的多模?
【问题讨论】:
-
我无法提供解决方案,但我希望看到它能够正常工作,因为我越来越多地使用 Python,而不是我传统上使用 Rmarkdown 的 R。如果您还没有,可能值得在Emacs Stackexchange 上发帖。
-
完成了一些挖掘,它有点过时但也许this thread 可能有用。
-
@slackline :对不起,我的慢动作回复。我联系了 Vspinu——polymode 包的作者——我们打开了一个关于这个主题的问题:github.com/polymode/polymode/issues/180。该问题尚未完全解决(20181031),但您应该能够在您的 emacs 上运行“用于 markdown 和 python 的 polymode”版本,按照我们在那里的讨论。
-
感谢您的提醒,即使没有完全解决,看起来也很有用。干杯
-
另外我发现了这篇文章:
标签: emacs literate-programming noweb pweave