Emacs/AUCTeX 前缀参数 [英] Emacs/AUCTeX prefix arguments

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

问题描述

在LaTeX模式下C-c C-c绑定到:

In LaTeX mode C-c C-c is bound to:

(TeX-command-master &optional OVERRIDE-CONFIRM)

通常这个交互函数会运行一个命令,也许是一个 LaTeX 编译,要求确认.

Normally this interactive function runs a command, perhaps a LaTeX compilation, asking for confirmation.

tex-buf.el 中显示:

如果给出前缀参数 OVERRIDE-CONFIRM,确认将取决于它是肯定的,而不是 `TeX-command-list' 中的条目.

If a prefix argument OVERRIDE-CONFIRM is given, confirmation will depend on it being positive instead of the entry in `TeX-command-list'.

这对我来说有点神秘,阅读 C-h v TeX-command-list 并没有帮助.

This is a bit cryptic for me and reading C-h v TeX-command-list didn't help.

如何将前缀参数传递给TeX-command-master",以避免所有确认请求?

How can I pass the prefix argument to "TeX-command-master" so that I avoid all the confirmation requests?

推荐答案

Build &查看

同样,这个解决方案不是修改 TeX-command-master 的行为,而是重写它.该命令的重写版本名为 build-view,遵循相当简单的逻辑.

Build & view

Again, this solution, instead of modifying the behaviour of the TeX-command-master, rewrites it. The rewritten version of the command, named build-view, follows a rather straightforward logic.

  1. 如果 LaTeX 文件缓冲区未修改,则运行默认查看器;
  2. 如果缓冲区脏了,它会运行默认的 LaTeX 编译器,并在构建后在默认查看器中打开输出.

代码如下:

(defun build-view ()
  (interactive)
  (if (buffer-modified-p)
      (progn  
    (let ((TeX-save-query nil)) 
    (TeX-save-document (TeX-master-file)))
    (setq build-proc (TeX-command "LaTeX" 'TeX-master-file -1))
    (set-process-sentinel  build-proc  'build-sentinel))
    (TeX-view)))

(defun build-sentinel (process event)    
  (if (string= event "finished
") 
      (TeX-view)
    (message "Errors! Check with C-`")))

您现在可以键入 M-x build-view 并启动指定的构建视图过程或将其与新的键绑定相关联,例如F2":

You can now type M-x build-view and start the told build-view process or associate it with a new keybinding such as "F2":

(add-hook 'LaTeX-mode-hook '(lambda () (local-set-key (kbd "<f2>") 'build-view)))

注意:正如 Tyler 所建议的,TeX-save-query 变量在本地更改,因此旧的 Cc Cc/TeX-command-master 不受影响,并将继续要求确认.

Note: As suggested by Tyler, TeX-save-query variable is changed locally, therefore the old C-c C-c/ TeX-command-master is unaffected and will keep asking confirmations.

请编辑此代码以使其更好或更易于阅读!

Do edit this code to make it better or easier to read!

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

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