>From 76af298a47147e7b6db38b0228b19748ccf08633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1o=20=C5=BDivanovi=C4=87?= Date: Fri, 30 Dec 2016 11:12:42 +0100 Subject: [PATCH] Fix RefTeX to show table of contents for dtx files * lisp/textmodes/reftex.el (reftex-compile-variables): Change the section regexp so that it accepts lines starting with the comment character. * lisp/textmodes/reftex-parse.el (reftex-parse-from-file): Filter gathered toc entries, accepting a commented entry if and only if the source file is a ".dtx" file. --- lisp/textmodes/reftex-parse.el | 6 +++++- lisp/textmodes/reftex.el | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el index 9180bea..1c628c6 100644 --- a/lisp/textmodes/reftex-parse.el +++ b/lisp/textmodes/reftex-parse.el @@ -270,7 +270,11 @@ of master file." (when (eq (char-before) ?\\) (backward-char)) ;; Insert in List (setq toc-entry (funcall reftex-section-info-function file)) - (when toc-entry + (when (and toc-entry + (equal + (equal (char-after bound) ?%) + (string-suffix-p ".dtx" file) + )) ;; It can happen that section info returns nil (setq level (nth 5 toc-entry)) (setq highest-level (min highest-level level)) diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index adc5076..c309f3e 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el @@ -1015,8 +1015,8 @@ This enforces rescanning the buffer on next use." ;; Calculate the regular expressions (let* ( ; (wbol "\\(\\`\\|[\n\r]\\)[ \t]*") - (wbol "\\(^\\)[ \t]*") ; Need to keep the empty group because - ; match numbers are hard coded + (wbol "\\(^\\)%?[ \t]*") ; Need to keep the empty group because + ; match numbers are hard coded (label-re (concat "\\(?:" (mapconcat 'identity reftex-label-regexps "\\|") "\\)")) -- 2.10.2