我使用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的情况下没有预先存在的polymode,因此我尝试根据文档和现有代码编写自己的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.
我做错了什么?我该如何使所需的polymode运行?