auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX] Problem with latex2e style hook --- LaTeX/Texinfo collision


From: Tassilo Horn
Subject: Re: [AUCTeX] Problem with latex2e style hook --- LaTeX/Texinfo collision‏
Date: Mon, 08 Sep 2014 09:44:16 +0200
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4.50 (gnu/linux)

Vincent Belaïche <address@hidden> writes:

Hi Vincent,

> First of all, I must apologize to you Tassilo, I had overlooked your
> comment about defalias not supporting docstring for XEmacs, so in my
> last contrib (small optimization) that was not corrected.
>
> Question: shouldn't I provide a small patch only for that defalias
> TeX-assoc-string for XEmacs compatibility before we go to this more
> substantial one.

No, I've just removed the docstring arg.

> Concerning this one I did it with taking into account the comments:
>
> - handling bibtex case (from Mosè) but I have not tested whether this
>   solves it. Also I used bib-cite.el file which might be not so
>   relevant.

I cannot remember the issue here, so let's wait what Mosè has to say
about it.

> - having the new argument for all LaTeX styles (I used a constant
>   LaTeX-dialect instead of hard-conding `:latex', as that seemed more
>   futureproof to me.
>
> - supporting (or ...) and (not ...) dialect expressions --- for
>   completeness I also added (and ...)
>
> - not sure whether this was a good idea, but I commonalized the dialects
>   list with equal value to a single instance for the sake of memory
>   saving (but this makes the code slightly more complex, and finally I
>   don't think that the saving worth it).

I totally agree.  Please make it go away! :-)

> Comments & brickbats welcome...

Here we go...

> diff --git a/bib-cite.el b/bib-cite.el
> index 8ac7ac9..32cc135 100644
> --- a/bib-cite.el
> +++ b/bib-cite.el
> @@ -941,6 +941,7 @@ runs bib-find, and [mouse-3] runs bib-display."
>    (eval-after-load
>     "bibtex"
>     '(progn
> +      (add-hook 'bibtex-mode-hook 'TeX-bitex-set-dialect-hook)

I don't like naming functions *-hook, and there's a "b" missing.
`TeX-bibtex-set-LaTeX-dialect' would be fine.

> diff --git a/latex.el b/latex.el
> index b260625..1b8beef 100644
> --- a/latex.el
> +++ b/latex.el
> @@ -4535,6 +4535,11 @@ use \\[customize]."
>      (unless (lookup-key map (LaTeX-math-abbrev-prefix))
>        (define-key map (LaTeX-math-abbrev-prefix) 'self-insert-command))))
>  
> +(defconst LaTeX-dialect :latex
> +  "Default dialect for use with function `TeX-add-style-hook' for
> +  argument DIALECT when the hook is to be run only on LaTeX file,
> +  or any mode derived thereof. See " )

See what?

> diff --git a/tex.el b/tex.el
> index cf56f90..95768fe 100644
> --- a/tex.el
> +++ b/tex.el
> @@ -595,13 +595,16 @@ but does nothing in Emacs."
>  Also does other stuff."
>      (TeX-maybe-remove-help menu)))
>  
> +;; We need this complex constuction with `eval' because XEMACS defalias does 
> not
> +;; have any docstring argument
>  ;;;###autoload
> -(defalias 'TeX-assoc-string
> -  (symbol-function  (if (featurep 'xemacs) 'assoc 'assoc-string))
> -  (concat "Compatibility alias that points to
> -  function `assoc' with XEMACS and to function `assoc-string'
> -  with GNU EMACS. See function `"
> -       (if (featurep 'xemacs) "assoc" "assoc-string") "'." ))
> +(eval `(defalias 'TeX-assoc-string
> +   ,@(if (featurep 'xemacs)
> +        (symbol-function 'assoc)
> +      (list (symbol-function 'assoc-string)
> +        "Compatibility alias that points to function `assoc'
> +  with XEmacs and to function `assoc-string' with GNU Emacs. See
> +  function `assoc-string'."))))

I don't think the docstring adds any value except that it tells you to
what it's aliased in the Emacs flavor you are currently NOT using.  So
just stick to the arity two version that's currently in the git master.

>  (defvar TeX-style-hook-list nil
>    "List of TeX style hooks currently loaded.
>  
> -Each entry is a list where the first element is the name of the style,
> -and the remaining elements are hooks to be run when that style is
> -active.")
> +Each entry is a list:
> +
> + (STYLE HOOK1 HOOK2 ...)
> +
> +where the first element STYLE is the name of the style, and the
> +remaining elements HOOKN, if any, are hooks to be run when that
> +style is active.
> +
> +A hook HOOKN may be a hook function HOOK-FUN to be run in
> +all TeX dialects (LaTeX, Texinfo, etc.), or a vector like:
> +
> +     [TeX-style-hook HOOK-FUN DIALECT-CELL]
> +
> +where HOOK-FUN is the hook function to be run, and DIALECT is an
> +expression defining in which dialect the hook function may be
> +run.
> +
> +DIALECT-CELL is a cons cell as follows:
> +
> +(SORTED-DIALECT-LIST . REF-COUNT)
> +
> +Where SORTED-DIALECT-LIST is the sorted list of supported
> +dialects, and REF-COUNT is how many hooks are refering to this
> +cons cell.")

That's too complicated for little benefit.  I'd prefer if there was only

  [TeX-style-hook HOOK-FUN DIALECT]

with DIALECT being something like (or :texinfo :latex).

> +(defun TeX-add-style-hook (style hook &optional dialect-expr)
> +  "Give STYLE yet another HOOK to run.
> +
> +DIALECT-EXPR serves the purpose of marking the hook to be run only in
> +that dicontext. 
> +
> +DIALECT-EXPR may be a single symbol defining the dialect, see
> +variable `TeX-style-hook-dialect' for supported dialects.
> +
> +DIALECT-EXPR can also be an expression like one of the following:
> +
> +* (or  DIALECT1 DIALECT2 ...)
> +* (not DIALECT1 DIALECT2 ...)
> +* (and DIALECT1 DIALECT2 ...)
> +"

`not' must only have one argument.  Your `not' is probably a `nor'.  We
could just rename it to `nor' but I think making it a normal `not' would
be better.

Bye,
Tassilo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]