Subject: Re: bug#24412: 11.89; Wrong DocTeX-mode

From: David Kastrup <[email-masked]>
Date: Sun, 11 Sep 2016 22:26:16 +0200

Piet van Oostrum <[email-masked]> writes:

> In AucTeX, latex.el (line 5871) contains:
>
> (add-to-list 'auto-mode-alist '("\\.dtx\\'" . doctex-mode))
>
> However, AUCTeX's doctex mode is called docTeX-mode. So the line above causes the standard Emacs doctex-mode to be invoked, rather than AUCTeX's docTeX-mode. This is undesirable.
>
> The line should be:
>
> (add-to-list 'auto-mode-alist '("\\.dtx\\'" . docTeX-mode))

Why?  It doesn't change the other modes either.  The point is that they
are mapped to the AUCTeX modes on-demand, see

TeX-modes is a variable defined in ‘tex-site.el’.
Its value is
(tex-mode plain-tex-mode texinfo-mode latex-mode doctex-mode)

Documentation:
List of modes provided by AUCTeX.

This variable can’t be set normally; use customize for that, or
set it with ‘TeX-modes-set’.

You can customize this variable.

> There is another thing. The documentation of docTeX-mode says:
>
> "Major mode in AUCTeX for editing .dtx files derived from `LaTeX-mode'.
> Runs `LaTeX-mode', sets a few variables and
> runs the hooks in `docTeX-mode-hook'."
>
> However, docTeX-mode-hook is never run.

That's a possible bug.  Let me see.

docTeX-mode is defined with

(define-derived-mode docTeX-mode TeX-latex-mode "docTeX"
...

in latex.el.  The documentation of define-derived-mode states:

    The new mode runs the hook constructed by the function
    ‘derived-mode-hook-name’.

which is defined as

    (defsubst derived-mode-hook-name (mode)
      "Construct a mode-hook name based on a MODE name."
      (intern (concat (symbol-name mode) "-hook")))

Which very much looks like it should do the job.  Do you have actual
evidence that it doesn't?

-- 
David Kastrup