乳胶,Emacs:自动打开* TeX帮助*缓冲区错误,纠正错误后关闭? [英] Latex, Emacs: automatically open *TeX Help* buffer on error and close it after correction of the error?

查看:100
本文介绍了乳胶,Emacs:自动打开* TeX帮助*缓冲区错误,纠正错误后关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Ivan Andrus在 TeX-parse-error emacs-latexmk-function-throws-me-into-a-empty-buffer> Emacs latexmk函数将我引入一个空的缓冲区,以便在发生错误时自动打开* TeX Help *缓冲区编译( Cc Cc )。纠正错误并重新编译后,* TeX Help *缓冲区保持打开状态(尽管错误已更正)。有没有办法调整功能(不幸的是,我没有经验的elisp编程),以便* TeX帮助*缓冲区关闭,如果错误已解决和更新(并仍然打开)如果错误没有解决?这样可以节省大量的输入,如 Cc'来显示* TeX Help *缓冲区和 Cx 1 来隐藏它再次。

I use the function TeX-parse-error defined by Ivan Andrus at the bottom of Emacs latexmk function throws me into an empty buffer in order to automatically open the *TeX Help* buffer when there was an error during the compilation (C-c C-c). After correcting an error and compiling again, the *TeX Help* buffer remains open (although the error has been corrected). Is there any way to adjust the function (unfortunately, I'm not experienced in elisp programming) so that the *TeX Help* buffer is closed if the error was resolved and updated (and still open) if the error wasn't resolved? That would save a lot of typing like C-c ' to show the *TeX Help* buffer and C-x 1 to hide it again.

推荐答案

首先,我们定义一个函数,找到 * TeX帮助* 缓冲区,如果存在,关闭窗口,然后杀死缓冲区:

First, let's define a function that finds the *TeX Help* buffer, if it exists, closes its window, and then kills the buffer:

(defun demolish-tex-help ()
  (interactive)
  (if (get-buffer "*TeX Help*") ;; Tests if the buffer exists
      (progn ;; Do the following commands in sequence
        (if (get-buffer-window (get-buffer "*TeX Help*")) ;; Tests if the window exists
            (delete-window (get-buffer-window (get-buffer "*TeX Help*")))
          ) ;; That should close the window
        (kill-buffer "*TeX Help*") ;; This should kill the buffer
        )
    )
  )

现在,当你调用你用来编译的任何函数时,你必须调用这个。以其他页面为例,您可以修改Ivan Andrus的功能:

Now, you have to call this when you call whatever function it is that you use to compile. Taking the example from that other page, you can modify Ivan Andrus's function to be:

(defun run-latexmk ()
  (interactive)
  (let ((TeX-save-query nil)
        (TeX-process-asynchronous nil)
        (master-file (TeX-master-file)))
    (TeX-save-document "")
    (TeX-run-TeX "latexmk"
                 (TeX-command-expand "latexmk %t" 'TeX-master-file)
                 master-file)
    (if (plist-get TeX-error-report-switches (intern master-file))
        (TeX-next-error t)
      (progn
       (demolish-tex-help)
       (minibuffer-message "latexmk done")))))

(add-hook 'LaTeX-mode-hook
          (lambda () (local-set-key (kbd "C-0") #'run-latexmk)))

(注意:这实际上并不适用于我,因为我的乳胶已经搞砸了,所以我没有成功测试过,但是如果Ivan的版本适合你,那么这个也应该是这样的。)

(Note: This doesn't actually work for me, because my latexmk is screwed up, so I haven't successfully tested it. But if Ivan's version worked for you, then this should too.)

所以现在,任何时候使用这个函数调用latexmk(例如通过点击 C-0 ),编译完成后,它检查错误。如果有错误,它会自动打开帮助窗口并获取第一个错误。如果没有,它检查帮助缓冲区是否打开;如果是这样,它关闭该窗口并杀死缓冲区。

So now, any time you call latexmk with this function (by hitting C-0, for example), once the compilation is done, it checks for errors. If there were errors, it automatically opens the Help window and gets the first error. If there were none, it checks to see if the Help buffer is open; if so, it closes that window and kills the buffer.

这篇关于乳胶,Emacs:自动打开* TeX帮助*缓冲区错误,纠正错误后关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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