gpt4 book ai didi

emacs - 运行 TeX-command-master 而不在 emacs 中查询

转载 作者:行者123 更新时间:2023-12-02 04:17:31 24 4
gpt4 key购买 nike

Emacs/AucTeX 中的组合键 C-c C-c 运行函数 TeX-command-master,该函数决定应运行什么命令(latex、bibtex、view 或其他) ),然后在运行命令之前要求用户确认。

我想将其绑定(bind)到一个键(例如F9),除非要求确认。这样我只需按 F9 即可运行最合适的命令。我怎样才能做到这一点?

最佳答案

我有这个片段(取自下面的 Emacswiki 链接),它可以完成所有事情,而不会打扰我现在该做什么。我绑定(bind)到 C-c C-a

;;; http://www.emacswiki.org/emacs/TN
(require 'tex-buf)
(defun TeX-command-default (name)
"Next TeX command to use. Most of the code is stolen from `TeX-command-query'."
(cond ((if (string-equal name TeX-region)
(TeX-check-files (concat name "." (TeX-output-extension))
(list name)
TeX-file-extensions)
(TeX-save-document (TeX-master-file)))
TeX-command-default)
((and (memq major-mode '(doctex-mode latex-mode))
(TeX-check-files (concat name ".bbl")
(mapcar 'car
(LaTeX-bibliography-list))
BibTeX-file-extensions))
;; We should check for bst files here as well.
TeX-command-BibTeX)
((TeX-process-get-variable name
'TeX-command-next
TeX-command-Show))
(TeX-command-Show)))

;;; from wiki
(defcustom TeX-texify-Show t
"Start view-command at end of TeX-texify?"
:type 'boolean
:group 'TeX-command)

(defcustom TeX-texify-max-runs-same-command 5
"Maximal run number of the same command"
:type 'integer
:group 'TeX-command)

(defun TeX-texify-sentinel (&optional proc sentinel)
"Non-interactive! Call the standard-sentinel of the current LaTeX-process.
If there is still something left do do start the next latex-command."
(set-buffer (process-buffer proc))
(funcall TeX-texify-sentinel proc sentinel)
(let ((case-fold-search nil))
(when (string-match "\\(finished\\|exited\\)" sentinel)
(set-buffer TeX-command-buffer)
(unless (plist-get TeX-error-report-switches (intern (TeX-master-file)))
(TeX-texify)))))

(defun TeX-texify ()
"Get everything done."
(interactive)
(let ((nextCmd (TeX-command-default (TeX-master-file)))
proc)
(if (and (null TeX-texify-Show)
(equal nextCmd TeX-command-Show))
(when (called-interactively-p 'any)
(message "TeX-texify: Nothing to be done."))
(TeX-command nextCmd 'TeX-master-file)
(when (or (called-interactively-p 'any)
(null (boundp 'TeX-texify-count-same-command))
(null (boundp 'TeX-texify-last-command))
(null (equal nextCmd TeX-texify-last-command)))
(mapc 'make-local-variable '(TeX-texify-sentinel TeX-texify-count-same-command TeX-texify-last-command))
(setq TeX-texify-count-same-command 1))
(if (>= TeX-texify-count-same-command TeX-texify-max-runs-same-command)
(message "TeX-texify: Did %S already %d times. Don't want to do it anymore." TeX-texify-last-command TeX-texify-count-same-command)
(setq TeX-texify-count-same-command (1+ TeX-texify-count-same-command))
(setq TeX-texify-last-command nextCmd)
(and (null (equal nextCmd TeX-command-Show))
(setq proc (get-buffer-process (current-buffer)))
(setq TeX-texify-sentinel (process-sentinel proc))
(set-process-sentinel proc 'TeX-texify-sentinel))))))

(add-hook 'LaTeX-mode-hook
'(lambda ()
(define-key LaTeX-mode-map (kbd "C-c C-a") 'TeX-texify)))

我还有一些 AUCTeX/RefTeX 设置 here ,如果愿意,请复制。

关于emacs - 运行 TeX-command-master 而不在 emacs 中查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10132927/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com