经过反复试验,我找到了答案。
如果我们在仅 LaTeX 的缓冲区中,这是正确的(and (equal (symbol-name major-mode) "latex-mode") (not ess-noweb-mode)))
:
如果我们在 ESS 缓冲区的块之外,这是真的ess-noweb-mode
:
您可能对以下便利功能感兴趣。
;Check ESS related modes
(defun is-pure-latex ()
"The buffer is in LaTeX mode, but not in ESS mode."
(and (equal (symbol-name major-mode) "latex-mode") (not ess-noweb-mode)))
(defun is-ess ()
"The buffer is in ESS mode."
ess-noweb-mode)
(defun is-ess-doc ()
"The buffer is in ESS mode and insertion point is outside a chunk."
(and ess-noweb-mode (equal (symbol-name major-mode) "latex-mode")))
(defun is-ess-chunk ()
"The buffer is in ESS mode an insertion point is inside a chunk."
(equal (symbol-name major-mode) "ess-mode"))
(defun is-ess-inf ()
"The buffer is in inferior ESS mode"
(equal (symbol-name major-mode) "inferior-ess-mode"))