伪WYSIWYG Emacs [英] Pseudo-WYSIWYG Emacs

查看:140
本文介绍了伪WYSIWYG Emacs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需文件中的几行 file.adoc

////
-*-iimage-mode-*-
////

.A PNG smiley
image::smiley.png[]

我可以使用 asciidoctor 和MS生成HTML使用 pandoc 的字 .doc
这个工具链不能处理SVG,所以它不是完美的,但是它的效果很好,而
是免费的。

I can generate HTML using asciidoctor and MS-word .doc using pandoc. This toolchain doesn't handle SVG, and so it's not perfect, but it works well, and it's free.

.html

< img src =https://i.stack.imgur.com/EUj1t.pngalt =呈现的HTML文件中的笑脸>

有一个障碍:

我想 iimage-mode 在加载 file.adoc 时启用。我的尝试(上面的源中的前三行)不起作用。你能想到一种方式吗?

I'd like iimage-mode to be enabled when I load file.adoc. My attempt (the first three lines in the source above) doesn't work. Can you think of a way that will?

.emacs

(set-foreground-color "white")
(set-background-color "black")

(require 'adoc-mode)
(setq auto-mode-alist (cons '("\\.adoc\\'" . adoc-mode) auto-mode-alist))

评论

我在这里写这些评论,以便能够排版。

I am writing these comments here to be able to typeset.


  1. Asciidoctor
    (我正在使用 Ruby )有(现在?)行评论除了评论。

  1. Asciidoctor (I'm using to the superior implementation of the asciidoc syntax written in Ruby) does have (now?) line comments in addition to block comments.

使用

// - - 模式:iimage - -

// -- mode: iimage --

在第一线工程(谢谢,尼克)。但是它取代了adoc主要模式(感谢phils)。

on the first line works (thanks, Nick). But it replaces the adoc major mode (thanks, phils).


  1. 在文件底部添加: li>
  1. Adding at the bottom of the file:

// //本地变量:

eval:(iimage-mode 1)

////

切换到次模式iimage,而主要模式仍然是adoc。

switches to minor mode iimage while the major mode remains adoc.


  1. phils的建议使用 my-adoc-mode-hook 运行良好。

  1. phils's suggestion to use my-adoc-mode-hook works well.

我是将第二部分加入一个单独的问题。这个讨论已经足够长了一个问题。

I'm forking the second part to a separate question. This discussion is already long enough for one question.

更新

使用asciidoctor + pandoc可能会生成一个使用最新版本的MS-Word正确处理的 .doc 文件。评论欢迎。 MS-Word 2011在OS X上打开结果 .doc 文件,但在SVG图像的位置显示错误消息。

Using asciidoctor + pandoc may produce a .doc file that is handled correctly with a recent version of MS-Word. Comments welcome. MS-Word 2011 on OS X opens the resulting .doc file fine, but shows an error message in the place of SVG images.

如果这样工作,它将(最后)成为向所有坚持使用它们的人发送一个 .doc 文件的方法,同时在环境中编辑与Emacs一样灵活。

If this works, it will (finally) be a way to send a .doc file to all those people who insist on them, while editing in an environment as flexible as Emacs.

推荐答案

Nick的答案大多是正确的,但 iimage-mode 模式,在本地变量中使用 mode:... em>模式。使用它启用次要模式已被弃用(即使它在某些情况下仍然有效 1 )。

Nick's answer is mostly correct, but iimage-mode is a minor mode, and using mode:... in local variables is (nowadays) intended for major modes only. Using it to enable minor modes is deprecated (even if it still works in some situations1).

而是使用 eval:... 调用小模式函数,如下所示 2

Instead use eval:... to call the minor mode function like so2:

//// -*- eval: (iimage-mode 1); -*-

//// Local Variables:
//// eval: (iimage-mode 1)
//// End:

另请注意, - * - iimage - * - 相当于 - * - mode:iimage - * - ,而对于这两种形式,Emacs将 -mode 后缀附加到获取实际模式名称。

Note also that -*- iimage -*- is equivalent to -*- mode: iimage -*-, and that for both forms Emacs appends a -mode suffix to get the actual mode name.

因此 - * - iimage-mode - * - 要求使用 iimage-mode-mode - 实际上,Emacs应该产生一个消息忽略未知模式iimage-mode-mode

Hence -*-iimage-mode-*- is asking to use iimage-mode-mode -- and in fact Emacs should have produced a message "Ignoring unknown mode `iimage-mode-mode'".

最后,如果你想为所有 adoc启用 iimage-mode -mode 文件,那么您可以在init文件中使用模式钩子,而不是使用文件局部变量:

Finally, if you want iimage-mode enabled for all adoc-mode files, then you can use a mode hook in your init file instead of using file-local variables:

(add-hook 'adoc-mode-hook 'my-adoc-mode-hook)

(defun my-adoc-mode-hook ()
  "Custom `adoc-mode' behaviours."
  (iimage-mode 1))

1 在这种情况下,如果您使用 - * - iimage - * - 或 - * - mode:iimage- * - 作为唯一的本地变量模式规范,Emacs将其视为主要模式,您的预期 adoc模式主模式将不会使用

1 In this case, if you had used -*-iimage-*- or -*-mode: iimage-*- as the only local variable mode spec, Emacs would treat it as a major mode, and your intended adoc-mode major mode would not be used.

2 我正在跟随尼克的答案,假设 //// 是正确的行注释前缀,但问题使它看起来更像一个块注释语法,所以我不知道是否正确。

2 I'm following Nick's answer in assuming that //// is the correct line-comment prefix, but the question makes it look more like a block comment syntax, so I don't know if it's correct.

这篇关于伪WYSIWYG Emacs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆