使用 AUCTeX 维护某些折叠环境的参数显示

使用 AUCTeX 维护某些折叠环境的参数显示

在使用某些环境时(function以及来自的朋友l3doc提示这一点),希望始终可以看到环境的参数:

Some text that, in reality, shouldn't be here in an l3doc
\begin{function}{\tl_new:N}
  Some documentation...
\end{function}
more inappropriate text

当使用 折叠它时C-c C-o C-e,所有内容都会消失(这对于 等环境很有用minipage):

Some text that, in reality, shouldn't be here in an l3doc
  [function]
more inappropriate text

有什么办法可以将其变成以下内容肯定环境?

Some text that, in reality, shouldn't be here in an l3doc
  [function]{\tl_new:N}
more inappropriate text

(如果只有一个解决方案全部环境很容易存在,我可以通过打开/关闭模式来进行管理。)


如果解决方案类似,那么真的如果你能有某种标记,那就太酷了,比如说%!!,它在折叠环境中总是可见的。

答案1

开始解决方案,基于这个答案

(defun mg-TeX-fold-environment-with-argument ()
  "Hide the current environment with \"[environment]{argument}\"."
  (interactive)
  (if (equal (LaTeX-current-environment) "function")
      (let ((env-end (save-excursion
               (LaTeX-find-matching-end)
               (point)))
        env-start priority ov)
    (setq env-start (save-excursion
              (LaTeX-find-matching-begin)
              (looking-at "\\\\begin{function}\\({[^}]*}\\)")
              (point)))
    (if (and env-start env-end)
        (progn
          (setq priority (TeX-overlay-prioritize env-start env-end))
          (setq ov (make-overlay env-start env-end
                     (current-buffer) t nil))
          (overlay-put ov 'category 'TeX-fold)
          (overlay-put ov 'priority priority)
          (overlay-put ov 'evaporate t)
          (overlay-put ov 'TeX-fold-display-string-spec
               (concat "[function]" (match-string-no-properties 1)))
          (TeX-fold-hide-item ov))
      (message "No environment found")))))

相关内容