Emacs / AUCTeX前缀参数 [英] Emacs/AUCTeX prefix arguments
问题描述
在LaTeX模式中 Cc Cc
必须绑定到:
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命令列表中的条目。
If a prefix argument OVERRIDE-CONFIRM is given, confirmation will depend on it being positive instead of the entry in `TeX-command-list'.
这对我来说有点神秘,并且阅读 Ch 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.
- 如果LaTeX文件缓冲区未被修改,它将运行默认查看器;
- 如果缓冲区脏了,它运行默认的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\n")
(TeX-view)
(message "Errors! Check with C-`")))
您现在可以键入 Mx构建视图
并启动被告知的构建视图进程或将其与新的键盘绑定如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
变量在本地更改,将旧的 C-c C-c
/ 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屋!