我使用python3 pweave库(http://mpastell.com/pweave/usage.html)来实现读写编程。
pweave使用标记作为文本模式,作为代码模式python3,可以使用noweb (https://en.wikipedia.org/wiki/Noweb)读写编程语法。
为了在emacs中正确突出显示语法,i的目标是使用多模库(https://polymode.github.io/和https://github.com/polymode)。
我使用emacs版本26.1。我能从蜂巢里安装多模。
不幸的是,主机模式没有预先存在的多模式:标记,内部模式: python3,语法: noweb,基于文档和现有代码,我尝试通过将以下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时,会得到以下错误:
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.我做错什么了?我如何才能获得所需的多模运行?
发布于 2018-11-05 04:43:56
这是如何指定标记-python3-noweb多模的解决方案。
;; define pwn polymode
(require 'poly-noweb)
(require 'poly-markdown)
(defcustom pm-inner/noweb-python
(clone pm-inner/noweb
:name "noweb-python"
:mode 'python-mode)
"Noweb for Python"
:group 'poly-innermodes
:type 'object)
(define-polymode poly-pweave-mode poly-markdown-mode
:innermodes '(pm-inner/noweb-python :inherit))
(add-to-list 'auto-mode-alist '("\\.pymd" . poly-pweave-mode))我要感谢Vitalie,这个多模式包的作者,他帮助我解决了这个问题!关于详细的讨论,请看一下github多模第180期。
或者,我在emacs堆栈交换中找到了这篇文章:https://emacs.stackexchange.com/questions/20136/pythontex-and-auctex,因此,在这篇文章之后,这是实现标记-python3-noweb mmm模式的解决方案。
;; define pwn multi major modes mode
(require 'mmm-auto)
(mmm-add-classes
'((noweb-python
:submode python-mode
:face mmm-default-submode-face
:front "^<<.*>>=\n"
:back "^@$")))
(setq mmm-global-mode 'maybe)
(mmm-add-mode-ext-class 'markdown-mode nil 'noweb-python)
(add-to-list 'auto-mode-alist '("\\.pymd" . markdown-mode))我的感谢是让-皮埃尔的,他在帖子中的详细解释使我的案子办得一帆风顺!
https://stackoverflow.com/questions/52489905
复制相似问题