Hi Vincent,

2016-01-08 12:27 GMT+01:00 Vincent Belaïche <vincent....@hotmail.fr>:
> Hello Mosè,
>
> Ok, so the way we go is to have multi-dialect hooks, and you are asking
> "Do you think is it easy to implement specification of multiple dialects
> in AUCTeX style files?".
>
> So the good news is that in the contribution which I did multi-dialect
> style files were supported from the beginning --- because at the time
> when I did it, I had already in mind the fact that some packages are
> multidialects. Please, look at the TeX-add-style-hook docstring. Assume
> that you would have the two new dialects :context and :plaintex, then
> for pgf hook you would declare the following in place of the
> DIALECT-EXPR argument :
>
> (or :latex :context :plaintex)

Oh, right, I already read it!  And it seems I forgot it as well ;-)

>   Vincent.
>
> PS-1: If you add new dialects, I think that the only thing to do is
>
> 1) To change the docstring of TeX-style-hook-dialect variable to update
>    the full list of supported dialects
>
> 2) To change the corresponding major-more definition, so that the
>   initialisation of the TeX-style-hook-dialect variable be done
>   accordingly.
>
>
> PS-2: I don't know whether the DocTeX mode is used only for LaTeX, or is
>      there something similar for ConTeXt. In the later case, you should
>      update also the DocTeX mode definition so that the
>      TeX-style-hook-dialect variable be initialized either to :latex or
>      to :context, accordingly, or maybe we need some :doctex-latex and
>      :doctex-context dialects (I don't think so, the style hook should
>      be written in a way that they you only primitive of the AUCTeX
>      kernel, and these primitives should react accordingly whether you
>      are in DocTeX mode or not, I DocTeX is not really a dialect, but
>      rather some file polyglotting method (ie making two dialects
>      co-exist in the same file).

Please, take a look at the attached patch.  In particular, I'm not
sure about the value of `TeX-style-hook-dialect-weight-alist' and the
order of the dialects, but probably it isn't really important.

Bye,
Mosè
diff --git a/context.el b/context.el
index 42d1594..882ed83 100644
--- a/context.el
+++ b/context.el
@@ -1,6 +1,6 @@
 ;;; context.el --- Support for ConTeXt documents.
 
-;; Copyright (C) 2003-2006, 2008, 2010, 2012, 2014, 2015
+;; Copyright (C) 2003-2006, 2008, 2010, 2012, 2014-2016
 ;;   Free Software Foundation, Inc.
 
 ;; Maintainer: Berend de Boer <ber...@pobox.com>
@@ -1661,6 +1661,12 @@ Use `ConTeXt-Mark-version' to choose the command."
     ConTeXt-item-list
     ConTeXt-extra-paragraph-commands))
 
+(defconst ConTeXt-dialect :context
+  "Default dialect for use with function `TeX-add-style-hook' for
+argument DIALECT-EXPR when the hook is to be run only on ConTeXt
+file, or any mode derived thereof. See variable
+`TeX-style-hook-dialect'." )
+
 (defcustom ConTeXt-clean-intermediate-suffixes
   ;; See *suffixes in texutil.pl.
   '("\\.tui" "\\.tup" "\\.ted" "\\.tes" "\\.top" "\\.log" "\\.tmp" "\\.run"
@@ -1695,6 +1701,7 @@ i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
   (setq major-mode 'context-mode)
 
   (setq local-abbrev-table context-mode-abbrev-table)
+  (set (make-local-variable 'TeX-style-hook-dialect) ConTeXt-dialect)
 
   ;; Make language specific variables buffer local
   (dolist (symbol ConTeXt-language-variable-list)
diff --git a/plain-tex.el b/plain-tex.el
index 3df6196..dfdc423 100644
--- a/plain-tex.el
+++ b/plain-tex.el
@@ -1,6 +1,6 @@
 ;;; plain-tex.el --- Support for plain TeX documents.
 
-;; Copyright (C) 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2010, 2013, 2016  Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-de...@gnu.org
 ;; Keywords: tex
@@ -103,6 +103,12 @@ Install tool bar if `plain-TeX-enable-toolbar' is non-nil."
 
 ;;; The mode
 
+(defconst plain-TeX-dialect :plain-tex
+  "Default dialect for use with function `TeX-add-style-hook' for
+argument DIALECT-EXPR when the hook is to be run only on
+plain-TeX file, or any mode derived thereof. See variable
+`TeX-style-hook-dialect'." )
+
 (defcustom plain-TeX-mode-hook nil
   "A hook run in plain TeX mode buffers."
   :type 'hook
@@ -143,6 +149,7 @@ of plain-TeX-mode-hook."
   (VirTeX-common-initialization)
   (set-syntax-table TeX-mode-syntax-table)
   (setq local-abbrev-table plain-tex-mode-abbrev-table)
+  (set (make-local-variable 'TeX-style-hook-dialect) plain-TeX-dialect)
   (setq paragraph-start
 	(concat
 	 "\\(^[ \t]*$"
diff --git a/tex.el b/tex.el
index b70f363..c2c247c 100644
--- a/tex.el
+++ b/tex.el
@@ -2603,8 +2603,10 @@ For supported dialects, see variables `TeX-style-hook-dialect'.")
 Supported values are described below:
 
 * `:bibtex'  for files in BibTeX mode.
+* `:context' for files in ConTeXt mode.
 * `:latex'   for files in LaTeX mode, or any mode derived
 	     thereof.
+* `:plain-tex' for files in plain-TeX mode.
 * `:texinfo' for Texinfo files.
 
 Purpose is notably to prevent non-Texinfo hooks to be run in
@@ -2667,6 +2669,6 @@ side effect e.g. on variable `TeX-font-list'.")
 	   (load-file el)))))
 
 (defconst TeX-style-hook-dialect-weight-alist
-  '((:latex . 1) (:texinfo . 2) (:bibtex . 4))
+  '((:latex . 1) (:texinfo . 2) (:bibtex . 4) (:plain-tex . 8) (:context . 16))
   "Association list to map dialects to binary weight, in order to
   implement dialect sets as bitmaps."  )
_______________________________________________
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex

Reply via email to