all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Sašo Živanović" <saso.zivanovic@guest.arnes.si>
To: emacs-devel@gnu.org
Subject: [PATCH] Fix RefTeX to show table of contents for dtx files
Date: Fri, 30 Dec 2016 11:49:41 +0100	[thread overview]
Message-ID: <1de25256-ff37-a170-31aa-af2c4467953a@guest.arnes.si> (raw)

[-- Attachment #1: Type: text/plain, Size: 925 bytes --]

I've fixed a tiny bug in RefTeX: TOC was not shown for dtx files.

Dtx files mix code and documentation. Any comment with the comment 
character at the beginning of the line is considered a part of the docs.

The regexp gathering sections allowed only whitespace before the section 
command. I've changed this so that now, the comment character is also 
allowed at the very beginning. In the parser code, I've added a filter 
that accepts only commented lines for dtx files and only uncommented 
ones for other files.

I've relied on the file name (ending in ".dtx", obviously), to detect 
dtx files. Using the major mode (doctex-mode or not) of the file that is 
currently visited does not work, as a tex file can input a dtx file, or 
vice versa. Maybe there's a way to also check file variables of included 
files, but I don't know about it, and it would probably be an overkill, 
anyway.

Best,
Sašo

[-- Attachment #2: 0001-Fix-RefTeX-to-show-table-of-contents-for-dtx-files.patch --]
[-- Type: text/x-patch, Size: 2286 bytes --]

From 76af298a47147e7b6db38b0228b19748ccf08633 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sa=C5=A1o=20=C5=BDivanovi=C4=87?=
 <saso.zivanovic@guest.arnes.si>
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


             reply	other threads:[~2016-12-30 10:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-30 10:49 Sašo Živanović [this message]
2017-01-02 12:22 ` [PATCH] Fix RefTeX to show table of contents for dtx files Tassilo Horn
2017-01-02 15:41   ` Sašo Živanović

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1de25256-ff37-a170-31aa-af2c4467953a@guest.arnes.si \
    --to=saso.zivanovic@guest.arnes.si \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.