标记处于活动状态时列出所有行

标记处于活动状态时列出所有行

在 AUCTeX 中,我希望LaTeX-environmentand/or的行为LaTeX-insert-item能够创建多个项目每一个调用时标示为活动状态。

答案1

如果我理解了你想要什么,下面的代码应该可以解决问题:

(defadvice LaTeX-env-item
  (around LaTeX-env-item-region activate)
  "When there is an active region, wrap the environment around it.
Insert \\item macros at the beginning of every non empty line of the region."
  (let ((beg (min (point) (mark)))
    (if (< (point) (mark))
    (exchange-point-and-mark))
    (save-excursion
      (while (re-search-backward "^\\(.+\\)$" beg t)
    (replace-match "\\\\item \\1" t nil)
    (beginning-of-line 1))))
  ad-do-it
  ;; Remove the extra \item.
  (re-search-forward "\\\\item " (save-excursion (end-of-line)) t)
  (replace-match ""))

这适用于所有插入的环境,LaTeX-env-item即默认情况下enumerate、、、和。itemizetrivlistdescriptiontheindex

相关内容