我使用 python3 pweave库 ( http://mpatell.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 version26.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.
我错了什么?我怎样才能让所需的多模运行?