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

2014-09-17 Thread Tassilo Horn
Vincent Belaïche  writes:

Hi Vincent,

> Not sure whether the attached bash script may be useful to other
> people, I have written it to detect suspicious blanks on all files
> that come into a patch, so that if some day I submit some other patch,
> the same problem will not occur.

Great!

> PS: I have noticed that there are files, e.g. latex.el with many
> problems like leading eight blanks.  Surely this is the reason for
> your suggesting whitespace-cleanup-region on change region instead of
> whitespace-cleanup (on all buffer, ie w/o transient mark mode on
> changed region).

Yes, exactly.

Bye,
Tassilo

___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-17 Thread Vincent Belaïche
Hello Tassilo,


[...]

>
> Bye,
> Tassilo
>
> BTW: Your patches contained some minor problems in that they introduced
> trailing whitespaces and spaces before tabs in indented code. New
> versions of Git emit warnings for that that and it was easy to fix them
> after applying your patches. But still, it's a good idea to do M-x
> whitespace-cleanup-region on the regions that you've modified before
> creating a patch.


Not sure whether the attached bash script may be useful to other people,
I have written it to detect suspicious blanks on all files that come
into a patch, so that if some day I submit some other patch, the same
problem will not occur.

---
Usage:

vcdiff > my_patch.diff
---

stdout of git diff will go into my_patch.diff, but prior to that
any suspicious blanks is warned for on the stderr.

   Vincent.

PS: I have noticed that there are files, e.g. latex.el with many
problems like leading eight blanks. Surely this is the reason for your
suggesting whitespace-cleanup-region on change region instead of
whitespace-cleanup (on all buffer, ie w/o transient mark mode on changed
region).

#!/bin/sh

# detect VC engine in use
if [ -d .git ]; then
vcengine=git
elif [ -d .svn ]; then
vcengine=svn
else
echo "Can't detect vcengine"
exit -1
fi

# sanity check
if $vcengine --version > /dev/null; then
true; # dummy
else
echo "Can't find $vcengine program!"
exit -2
fi

files=$($vcengine status | awk '$2 == "modified:" { print $3}')

suspicious_files=''
awkscript=$(mktemp /temp/tmp.awkscript.XX)

# Note that in the script I set RS to be tolerant to Windows file format. This 
is because I may be handling
# Windows text files (ended in CRLF) in a *nixy (e.g. MSYS) environment
cat > $awkscript < STDERR}
empty = 1}
/[^ ]/ { body = 1; empty = 0}
/^ {8,}/ { r=0; print FILENAME ":line " line ": 8 or more spaces at the 
beginning of a line" > STDERR }
/^ +/ { r=0; print FILENAME ":line " line ": Space(s) followed by a TAB at 
the beginning of a line" > STDERR }
/[^ ][  ]+\$/ { r=0; print FILENAME ":line " line ": Trailing blanks" > 
STDERR }
END {
if(empty == 1){r=0; print FILENAME ":line " line ": Trailing blank 
line" > STDERR}
exit(r)}
EOF


# echo "AWKSCRIPT>"
# cat $awkscript
# echo " /dev/stderr
rm -f $awkscript

$vcengine diff




# Local Variables:
# mode: sh
# End:
___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-14 Thread Tassilo Horn
Vincent Belaïche  writes:

Hi Vincent,

>> Thanks, applied. Could you please also document `TeX-add-style-hook's
>> new third argument in the info docs.
>
> Please find the patch attached.

Thanks, applied.

> Thank you very much for your support and kind checking & installing my
> contribution.

We have to thank you!

Bye,
Tassilo

BTW: Your patches contained some minor problems in that they introduced
trailing whitespaces and spaces before tabs in indented code.  New
versions of Git emit warnings for that that and it was easy to fix them
after applying your patches.  But still, it's a good idea to do M-x
whitespace-cleanup-region on the regions that you've modified before
creating a patch.

___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-13 Thread Vincent Belaïche
Hello Tassilo,


> From: t...@gnu.org
> To: vincent@hotmail.fr
> CC: auctex@gnu.org
> Subject: Re: [AUCTeX] Problem with latex2e style hook --- LaTeX/Texinfo 
> collision‏
> Date: Fri, 12 Sep 2014 21:26:40 +0200
>
> Vincent Belaïche  writes:
>
> > Here you are.
>
> Thanks, applied. Could you please also document `TeX-add-style-hook's
> new third argument in the info docs.
>
> Bye,
> Tassilo

Please find the patch attached.

Thank you very much for your support and kind checking & installing my
contribution.

  Vincent.

diff --git a/ChangeLog b/ChangeLog
index a5c842e..ca4d1e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2014-09-13  Vincent Belaïche  
+
+	* latex.el (LaTeX-dialect): Correct doctstring for consistency
+	with definition of function TeX-add-style-hook.
+
+	* doc/auctex.texi (Simple Style): modify example with
+	'TeX-add-style-hook', so that 3rd argument is added. Modify @defun
+	of 'TeX-add-style-hook' also to document addition of 3rd argument.
+
 2014-09-11  Vincent Belaïche  
 
 	* doc/changes.texi: Add information about style hook labelling by dialect.
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 84ac235..8e768ae 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -4269,7 +4269,8 @@ Here is a simple example of a style file.
 (TeX-add-style-hook
  "book"
  (lambda () 
-   (LaTeX-largest-level-set "chapter")))
+   (LaTeX-largest-level-set "chapter"))
+ LaTeX-dialect)   
 @end lisp
 
 The example is from the @AUCTeX{} sources and is loaded for any @LaTeX{}
@@ -4288,11 +4289,59 @@ hooks will be called for each buffer using the style file.
 Note that the basename of the style file and the name of the style hook
 should usually be identical.
 
-@defun TeX-add-style-hook @var{style} @var{hook}
+@defun TeX-add-style-hook @var{style} @var{hook} &optional @var{dialect-expr}
 Add @var{hook} to the list of functions to run when we use the @TeX{}
-file @var{style}.
+file @var{style} and the current dialect is one in the set derived from
+@var{dialect-expr}. When @var{dialect-expr} is omitted, then @var{hook}
+is allowed to be run whatever the current dialect is.
+
+@var{dialect-expr} may be one of:
+
+@itemize
+@item
+A symbol indicating a singleton containing one basic @TeX{} dialect,
+this symbol shall be selected among:
+@table @code
+@item :latex
+For all files in @LaTeX{} mode, or any mode derived thereof
+@item :bibtex
+For all files in Bib@TeX{} mode, or any mode derived thereof
+@item :texinfo
+For all files in @acronym{Texinfo} mode.
+@end table
+@item
+A logical expression like:
+@table @code
+@item (or @var{dialect-expression1} @dots{} @var{dialect-expression_@var{n}})
+For union of the sets of dialects corresponding to  @var{dialect-expression1}
+through @var{dialect-expression_@var{n}}
+@item (and @var{dialect-expression1} @dots{} @var{dialect-expression_@var{n}})
+For intersection of the sets of dialects corresponding to
+@var{dialect-expression1} through @var{dialect-expression_@var{n}}
+@item (nor @var{dialect-expression1} @dots{} @var{dialect-expression_@var{n}})
+For complement of the union sets of dialects corresponding to
+@var{dialect-expression1} through @var{dialect-expression_@var{n}}
+relatively to the set of all supported dialects
+@item (not @var{dialect-expr})
+For complement set of dialect corresponding to @var{dialect-expr}
+relatively to the set of all supported dialects
+@end table
+@end itemize
+
 @end defun
 
+In case of adding a style hook for @LaTeX{}, when calling function
+@code{TeX-add-style-hook} it is thought more futureproof for argument
+@var{dialect-expr} to pass constant @code{LaTeX-dialect} currently
+defined to @code{:latex}, rather than passing @code{:latex} directly.
+
+@defvr Constant LaTeX-dialect
+Default dialect for use with function @code{TeX-add-style-hook} for
+argument @var{dialect-expr} when the hook is to be run only on LaTeX
+file, or any mode derived thereof.
+@end defvr
+
+
 @node Adding Macros
 @subsection Adding Support for Macros
 @cindex Adding macros
diff --git a/latex.el b/latex.el
index 2cd2b65..32a431f 100644
--- a/latex.el
+++ b/latex.el
@@ -4537,8 +4537,9 @@ use \\[customize]."
 
 (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 variable `TeX-style-hook-dialect'." )
+argument DIALECT-EXPR when the hook is to be run only on LaTeX
+file, or any mode derived thereof. See variable
+`TeX-style-hook-dialect'." )
 
 (defconst LaTeX-math-default
   '((?a "alpha" "Greek Lowercase" 945) ;; #X03B1
___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-12 Thread Tassilo Horn
Vincent Belaïche  writes:

> Here you are.

Thanks, applied.  Could you please also document `TeX-add-style-hook's
new third argument in the info docs.

Bye,
Tassilo

___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-12 Thread Vincent Belaïche

Here you are.
   Vincent.

> From: t...@gnu.org
> To: vincent@hotmail.fr
> CC: auctex@gnu.org
> Subject: Re: [AUCTeX] Problem with latex2e style hook --- LaTeX/Texinfo 
> collision‏
> Date: Fri, 12 Sep 2014 20:18:00 +0200
> 
> Vincent Belaïche  writes:
> 
> Hi Vincent,
> 
>> Attached is the other patch --- that with bitmap based style hook
>> dialect sets.
> 
> Nice, I like it.
> 
>> However I decided to provide separate implementations for nor and not,
>> as I think that you wish to get rid of `nor', and the `not' specific
>> implementation is slightly simpler.
> 
> No, I like to keep `nor'.  I just felt that a simple `not' which is
> known by anybody mustn't be missing.
> 
>> Just to say: do not pay too much attention to the ChangeLog is the
>> patch attached to my previous mail, as it needs update --- I will do
>> that with the rests of pending changes (ie NEWS & manual).
> 
> Your patch is good to go.  So just add the NEWS entry and the manual
> update, and I'll apply it.
> 
> Thanks a lot for your effort!
> Tassilo
  

dialectified_style_hooks.diff
Description: Binary data
___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-12 Thread Tassilo Horn
Vincent Belaïche  writes:

Hi Vincent,

> Attached is the other patch --- that with bitmap based style hook
> dialect sets.

Nice, I like it.

> However I decided to provide separate implementations for nor and not,
> as I think that you wish to get rid of `nor', and the `not' specific
> implementation is slightly simpler.

No, I like to keep `nor'.  I just felt that a simple `not' which is
known by anybody mustn't be missing.

> Just to say: do not pay too much attention to the ChangeLog is the
> patch attached to my previous mail, as it needs update --- I will do
> that with the rests of pending changes (ie NEWS & manual).

Your patch is good to go.  So just add the NEWS entry and the manual
update, and I'll apply it.

Thanks a lot for your effort!
Tassilo

___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-10 Thread Vincent Belaïche

Just to say: do not pay too much attention to the ChangeLog is the patch
attached to my previous mail, as it needs update --- I will do that with
the rests of pending changes (ie NEWS & manual).

   Vincent.

>Hello,
>
>Attached is the other patch --- that with bitmap based style hook
>dialect sets.
>
>It saves 43 lines of code in tex.el, and also has a smaller memory
>footprint per hooks because an integer is smalled than a list containing
>one symbol (best case for the sorted list based implementation).
>
>I could save even a little more if we decide to remove the nor operator
>--- I feel that in the end we will do that.
>
>I have done the same basic tests, and it works the same...
>
>more feedback below...
>  

[...]


___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-10 Thread Vincent Belaïche
Hello,

Attached is the other patch --- that with bitmap based style hook
dialect sets.

It saves 43 lines of code in tex.el, and also has a smaller memory
footprint per hooks because an integer is smalled than a list containing
one symbol (best case for the sorted list based implementation).

I could save even a little more if we decide to remove the nor operator
--- I feel that in the end we will do that.

I have done the same basic tests, and it works the same...

more feedback below...
  
> From: t...@gnu.org
> To: vincent@hotmail.fr
> CC: auctex@gnu.org
> Subject: Re: [AUCTeX] Problem with latex2e style hook --- LaTeX/Texinfo 
> collision‏
> Date: Wed, 10 Sep 2014 16:56:02 +0200
> 
> Vincent Belaïche  writes:
> 
> >> FWIW, I wouldn't mind releasing with that patch and an appropriate
> >> info doc update & NEWS entry (Vincent, could you please add that?)
> >
> > Yes, of course, I will do that in the next patch version.
> 
> Do that once we have settled on a specific patch version.
> 
> > Please make me know whether you are happy with the sorted-list based
> > implementation of style-hook set arithmetic, or if you think that
> > bitmaps are better.
> 
> Since you said that bitmaps would be easier to maintain, shorter, and
> simpler, I'm in favor of that. See my other mail.
> 
> > Also what about the nor/not discussion, I suggest that we keep only
> > `nor' and rename it `not'. Do you agree ?
> 
> No, see my other mail. I don't get why (not (or :a :b)) isn't
> equivalent to (nor :a :b) in every case.

Well, after more thoughts, that is a bug of the sorted list based
implementation of `not' operator which I submitted in the previous
patch: this implementation of the not operator was restricted to one
argument being a dialect, and not allowing argument being _any_ dialect
expression. So it was possible to do

   (not :a)

but not

  (not (or :a :b))
  
since :a is a both a dialect and a dialect expression, while (or :a :b)
is a dialect expression, but not a dialect.

I can correct this bug if we decide to go for the sorted-list based
implementation, which now I really doubt we will do.

> And in my book, the logical `not' is always unary.
>

It could be seen as an implementation trick to have `not' delegating to
`nor'. After all, for all x, (nor x) will yield the `same set' as (not
x) --- where `same set', does not necessarilly means same integer as
there are non significant bits.

However I decided to provide separate implementations for nor and not,
as I think that you wish to get rid of `nor', and the `not' specific
implementation is slightly simpler.

About non significant bits, I mean that

  (or :latex :bibtex)

and

  (not :texinfo)

is the same set, but not the same integer value. That does not really
matter.

Maybe to avoid these non-significant bits variations, I should have used
(logxor TeX-shdex-all x) rather than (lognot x) for not operator,
with TeX-shdex-all = 2^(3 dialects) -1 = 7, e.g. defined as:

(defconst TeX-shdex-all
  (lognot
(let ((dialect-count (length TeX-style-hook-dialect-weight-alist)))
 (lsh (lsh -1 (- dialect-count)) dialect-count

I don't think that this is really needed, but your opinion is welcome.

> Bye,

Good night --- if you are on CEST time,

   Vincent.

diff --git a/ChangeLog b/ChangeLog
index 9b70f3a..2318fb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,329 @@
+2014-09-08  Vincent Belaïche  
+
+	* style/xspace.el ("xspace"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/xparse.el ("xparse"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/virtex.el ("virtex"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/verbatim.el ("verbatim"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/varioref.el ("varioref"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/url.el ("url"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/units.el ("units"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/unicode-math.el ("unicode-math"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/ulem.el ("ulem"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/tabulary.el ("tabulary"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/tabularx.el ("tabularx"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/swedish.el ("swedish"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/subfigure.el ("subfigure"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/slovak.el ("slovak"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/slides.el ("slides"): Add LaTeX-dialect to TeX-add-style-hook call.

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

2014-09-10 Thread Tassilo Horn
Vincent Belaïche  writes:

>> FWIW, I wouldn't mind releasing with that patch and an appropriate
>> info doc update & NEWS entry (Vincent, could you please add that?)
>
> Yes, of course, I will do that in the next patch version.

Do that once we have settled on a specific patch version.

> Please make me know whether you are happy with the sorted-list based
> implementation of style-hook set arithmetic, or if you think that
> bitmaps are better.

Since you said that bitmaps would be easier to maintain, shorter, and
simpler, I'm in favor of that.  See my other mail.

> Also what about the nor/not discussion, I suggest that we keep only
> `nor' and rename it `not'. Do you agree ?

No, see my other mail.  I don't get why (not (or :a :b)) isn't
equivalent to (nor :a :b) in every case.  And in my book, the logical
`not' is always unary.

Bye,
Tassilo

___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-10 Thread Tassilo Horn
Vincent Belaïche  writes:

Hi Vincent,

> BTW, in my previous email I proposed a defun for (not...), but please
> note that with this defun `not' must have one single *dialect*
> argument (`dialect' as opposed to `dialect expression').
>
> So (nor x y) is equivalent to (not (or x y)) only in the case when (or
> x y) is a one element list.

That sounds like strange logic to me.  Say we have the dialects :a, :b,
:c and :d.  Then if I do

  (TeX-add-style-hook "foo" (lambda () ...) (not (or :a :b)))

I want it to run for both dialects :c and :d.  Same for (nor :a :b).
The two dialect expressions should be equivalent in every case.

> Please note that in my initial contribution you told that `not' would
> be better named `nor', and this is why I did rename it.  However I
> think that it could have kept the original name `not' even if not
> unary.  After all, the SORTED-DIALECT-LIST element of the hook vector
> is a particular implementation of a `set' object. These
> SORTED-DIALECT-LIST are just non empty sets.

I don't see why that should be different.  With sets, `or' is basically
the union.  So (not (or :a :b)) would mean "not in the union of the
single-element sets :a and :b", i.e., "not in the set (:a :b)" which
would still be (:c :d).

> Maybe it would have been preferable to implement this `set' thing as a
> bitmap: it is quite unlikely that AUCTeX will ever have to handle more
> dialects than there are bits in an integer (currently 23).

I very much hope so.

> Bitwise logical operators are maybe better suited to make the
> job. That would be simpler, shorter, easier to maintain code, and if
> you wish I can update the patch towards this.

Well, if it's shorter, simpler and easier to maintain, please do so!

Bye,
Tassilo

___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-10 Thread Vincent Belaïche
Ok, now it seems that I have caught up, and gone through all the new
messages...

I have attached a new version of the patch to this message taking into
account the previous email, but it does not contain yet any addition to
NEWS/manual.

> From: t...@gnu.org
> To: m...@gnu.org
> CC: vincent@hotmail.fr; auctex@gnu.org
> Subject: Re: [AUCTeX] Problem with latex2e style hook --- LaTeX/Texinfo 
> collision‏
> Date: Tue, 9 Sep 2014 11:37:03 +0200
> 
> Mosè Giordano  writes:
> 
> > I have only a concern about this patch: we should release a new
> > version of AUCTeX these days, if the plan still holds, I'm not sure we
> > should apply a not so tested, though valuable, patch before the
> > release.
> 
> FWIW, I wouldn't mind releasing with that patch and an appropriate info
> doc update & NEWS entry (Vincent, could you please add that?)

Yes, of course, I will do that in the next patch version.

Please make me know whether you are happy with the sorted-list based
implementation of style-hook set arithmetic, or if you think that
bitmaps are better.

Maybe it is difficult to answer without seeing what it would be, I can
provide another patch with bitmaps just for the sake of getting a better
idea and taking the right decision.

Also what about the nor/not discussion, I suggest that we keep only
`nor' and rename it `not'. Do you agree ?


> because IMHO chances are low that there's a bug with existing style
> hooks.
>

I think so, but I have made only basic tests with Texinfo and plain
LaTeX.

> Bye,
> Tassilo

Bye,
   Vincent.

diff --git a/ChangeLog b/ChangeLog
index 9b70f3a..2318fb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,329 @@
+2014-09-08  Vincent Belaïche  
+
+	* style/xspace.el ("xspace"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/xparse.el ("xparse"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/virtex.el ("virtex"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/verbatim.el ("verbatim"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/varioref.el ("varioref"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/url.el ("url"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/units.el ("units"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/unicode-math.el ("unicode-math"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/ulem.el ("ulem"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/tabulary.el ("tabulary"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/tabularx.el ("tabularx"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/swedish.el ("swedish"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/subfigure.el ("subfigure"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/slovak.el ("slovak"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/slides.el ("slides"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/siunitx.el ("siunitx"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/shortvrb.el ("shortvrb"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/setspace.el ("setspace"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrreprt.el ("scrreprt"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrpage2.el ("scrpage2"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrlttr2.el ("scrlttr2"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrbook.el ("scrbook"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrbase.el ("scrbase"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrartcl.el ("scrartcl"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/ruby.el ("ruby"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/report.el ("report"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/ragged2e.el ("ragged2e"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pstricks.el ("pstricks"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pst-slpe.el ("pst-slpe"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pst-plot.el ("pst-plot"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pst-node.el ("pst-node"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pst-grad.el ("pst-grad"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/psfig.el ("psfig"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/prosper.el ("prosper"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/polski.el ("polski"): Add LaTeX-dial

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

2014-09-10 Thread Vincent Belaïche
Ok, now I look into Tassilo's feedback on the patch itself...

> To: auctex@gnu.org
> From: t...@gnu.org
> Date: Tue, 9 Sep 2014 08:49:26 +0200
> Subject: Re: [AUCTeX] Problem with latex2e style hook --- LaTeX/Texinfo 
> collision‏
> 
> Vincent Belaïche  writes:
> 
> Hi Vincent,
> 
> > Please ignore the previous patch attachment: I had not made all the
> > corresponding updates in the ChangeLog.
> 
> Ok. Some last nitpicks below.
> 
> > diff --git a/tex.el b/tex.el
> > index f3316d5..9bbcb29 100644

[...]


> > +For supported dialects, see variables `TeX-style-hook-dialect'.")
> 
> Could you please add a comment here that you don't manipulate that
> variable directly but only via `TeX-add-style-hook' and friends which
> will take care of the correct sorting?
>
Good idea, I will do that...

> > +(defun TeX-shdex-nor (&rest args)
> > + "NOR operator for style hook dialect expressions. The returned
> > +value is a list of dialects that are in
> > +`TeX-style-hook-dialect-list' but not in ARGS."
> > + (setq args (apply 'TeX-shdex-or args))
> 
> Shouldn't that apply `TeX-shdex-eval' on the args?
>

No, I need `or' because it does more than just evaluating each elements
in the args list, it also sorts the output of evaluation, and this is
needed by the sequel of the nor algorithm.

BTW, in my previous email I proposed a defun for (not...), but please
note that with this defun `not' must have one single *dialect* argument
(`dialect' as opposed to `dialect expression').

So (nor x y) is equivalent to (not (or x y)) only in the case when (or x
y) is a one element list.

Please note that in my initial contribution you told that `not' would be
better named `nor', and this is why I did rename it. However I think
that it could have kept the original name `not' even if not unary. After
all, the SORTED-DIALECT-LIST element of the hook vector is a particular
implementation of a `set' object. These SORTED-DIALECT-LIST are just non
empty sets.

Maybe it would have been preferable to implement this `set' thing as a
bitmap: it is quite unlikely that AUCTeX will ever have to handle more
dialects than there are bits in an integer (currently 23). Bitwise
logical operators are maybe better suited to make the job. That would be
simpler, shorter, easier to maintain code, and if you wish I can update
the patch towards this.

Anyway, as a minimal change I will update the patch so that
TeX-style-hook-dialect-list is defined like

   (TeX-shdex-or :bibtex :latex :texinfo )

to remove the dependancy on a particular sorted-list based
implementation. In the same vein, within `TeX-run-style-hooks', I will
replace:

 (memq TeX-style-hook-dialect (aref hook 2))

 (TeX-shdex-in-p TeX-style-hook-dialect (aref hook 2))

with

(defalias 'TeX-shdex-in-p 'memq)

> > +(defun TeX-shdex-eval (&rest args)
> > + "Evaluate a style hook dialect expression ARGS."
> > + (sort (apply 'append (mapcar
> > + (lambda (dialect-expr)
> > + (cond
> > + ((symbolp dialect-expr)
> > + (list dialect-expr))
> > + ((and (consp dialect-expr)
> > + (memq (car dialect-expr) '(or and nor)))
> > + (apply (intern
> > + (concat "TeX-shdex-" (symbol-name (car dialect-expr
> > + (cdr dialect-expr)))
> > + (t
> > + (error "Invalid dialect expression : %S." dialect-expr
> > + args))
> > + 'string<))
> 
> Please move that before the operator functions because they call it to
> remove some undefined function warnings.
>

Ok, I will do that also.


> Bye,
> Tassilo
>

Bye,
   Vincent.
> 
> ___
> auctex mailing list
> auctex@gnu.org

___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-10 Thread Vincent Belaïche
Trying to catch-up the discussion...

> To: auctex@gnu.org
> From: t...@gnu.org
> Date: Tue, 9 Sep 2014 08:34:49 +0200
> Subject: Re: [AUCTeX] Problem with latex2e style hook --- LaTeX/Texinfo 
> collision‏
> 

[...]

> >
> > I renamed it `nor' because I think that a user may want to pass
> > explicitly `(nor )' as the last argument of TeX-add-style-hook to
> > mean:
> >
> > Supported for *all* dialects
> >
> > as opposed to:
> >
> > I have coded this before Vincent did the patch, so the last
> > argument is missing.
> 
> Yes, nil (omitted) should indeed mean "run with all dialects" but I
> don't see why this requires `nor'. The only place I found it is in the
> docstring of `TeX-add-style-hook' where you say that omitted is
> equivalent to (nor). You could also just say that it's equivalent to
> `(not (or))', no?
> 
> To me it looks just a bit strange to have `and' and `or' but not a plain
> `not'. Do me a favor and just add a normal `not' that just delegates to
> `nor'.
>

Ok, I will add the not operator, but rather than delegating to `or' it
seems simpler if it has a boy of its own like:

(defun TeX-shdex-not (arg)
  "NOT operator for style hook dialect expressions. The returned
value is a list of all dialects that are in
`TeX-style-hook-dialect-list' but ARG."
  (delq arg (copy-sequence TeX-style-hook-dialect-list)))

So not will be unary.

> Bye,
> Tassilo
>

Bye,
  vincent.
> 
> ___
> auctex mailing list
> auctex@gnu.org
> https://lists.gnu.org/mailman/listinfo/auctex

___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-09 Thread Tassilo Horn
Mosè Giordano  writes:

> I have only a concern about this patch: we should release a new
> version of AUCTeX these days, if the plan still holds, I'm not sure we
> should apply a not so tested, though valuable, patch before the
> release.

FWIW, I wouldn't mind releasing with that patch and an appropriate info
doc update & NEWS entry (Vincent, could you please add that?) because
IMHO chances are low that there's a bug with existing style hooks.

Bye,
Tassilo

___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-09 Thread Mosè Giordano
Hi Vincent and Tassilo,

2014-09-08 22:21 GMT+02:00 Vincent Belaïche :
>> > 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.
>
> I think that his problem was that he had to change his workflow so that
> he would not have the case foo.tex and foo.bib in the same directory,
> with foot.tex using foo.bib as a bibliography.
>
> My patch _should_ solve that, but I must admit that I have not yet
> tested it because I do not know what symptom Mosè actually was meeting
> when editing the bib file.
>
> I seems that there is no such thing as some reduced AUCTeX support in
> BibTeX file (like `C-c C-f ...' for setting formatting).
>
> Mosè could you provide a minimal example of the bug --- was the issue
> ever logged in AUCTeX issue tracker ?

This is the first item in the list of known bugs of AUCTeX:
https://gnu.org/software/auctex/manual/auctex.html#Bugs  This is
simply due to AUCTeX dropping the extension of the parsed file in
style hook names.

I have only a concern about this patch: we should release a new
version of AUCTeX these days, if the plan still holds, I'm not sure we
should apply a not so tested, though valuable, patch before the
release.

Bye,
Mosè

___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-08 Thread Tassilo Horn
Vincent Belaïche  writes:

Hi Vincent,

> Please ignore the previous patch attachment: I had not made all the
> corresponding updates in the ChangeLog.

Ok.  Some last nitpicks below.

> diff --git a/tex.el b/tex.el
> index f3316d5..9bbcb29 100644
> --- a/tex.el
> +++ b/tex.el
> @@ -2376,15 +2376,54 @@ Used when checking if any files have changed."
>  (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 SORTED-DIALECT-LIST]
> +
> +where HOOK-FUN is the hook function to be run, and
> +SORTED-DIALECT-LIST is a list containing all dialects in which
> +the hook function may be run. This list is sorted with function
> +`string<' and it must contain at least one dialect.
> +
> +For supported dialects, see variables `TeX-style-hook-dialect'.")

Could you please add a comment here that you don't manipulate that
variable directly but only via `TeX-add-style-hook' and friends which
will take care of the correct sorting?

> +(defun TeX-shdex-nor (&rest args)
> +  "NOR operator for style hook dialect expressions. The returned
> +value is a list of dialects that are in
> +`TeX-style-hook-dialect-list' but not in ARGS."
> +  (setq args (apply 'TeX-shdex-or args))

Shouldn't that apply `TeX-shdex-eval' on the args?

> +(defun TeX-shdex-eval (&rest args)
> +  "Evaluate a style hook dialect expression ARGS."
> +  (sort (apply 'append (mapcar
> + (lambda (dialect-expr)
> +   (cond
> +((symbolp dialect-expr)
> + (list dialect-expr))
> +((and (consp dialect-expr)
> +  (memq (car dialect-expr) '(or and nor)))
> + (apply (intern
> + (concat "TeX-shdex-" (symbol-name  (car 
> dialect-expr
> + (cdr dialect-expr)))
> +(t
> + (error "Invalid dialect expression : %S." 
> dialect-expr
> + args))
> + 'string<))

Please move that before the operator functions because they call it to
remove some undefined function warnings.

Bye,
Tassilo


___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-08 Thread Tassilo Horn
Vincent Belaïche  writes:

> BTW I could not find the issue tracker at
> https://savannah.gnu.org/projects/auctex, are you at all using an
> issue tracker (or AUCTeX does not have any issues :-P :-DDD ).

We're currently using a plain mailinglist (bug-auc...@gnu.org).  That's
were bug reports sent with M-x TeX-submit-bug-report end up.  The list
is also accessible via Gmane: gmane.emacs.auctex.bugs.

>> > - 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! :-)
>
> Gone!

Great!

>> > + (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.
>>
> Done, except that I named it
>
> TeX-bibtex-set-BibTeX-dialect
>
> because the matter is to set dialect to *BibTeX* (not LaTeX) when you
> are in BibTeX mode.

Yes, fine.  I first thought it would set the LaTeX-dialect variable
which I later saw it doesn't.

> Well: this may mean that some of hooks will need to be allowing both
> BibTeX and LaTeX dialects (actually I don't think so, as there do not
> seem to be anything like BibTeX editing support in AUCTeX appart from
> bib-cite which I don't know about.
>
> Please expect that you might see something looking like a regression
> when editing BibTeX files if you rely on some style hook being active
> in those files.

At least I don't, but we'll see.

>> `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.
>
> I renamed it `nor' because I think that a user may want to pass
> explicitly `(nor )' as the last argument of TeX-add-style-hook to
> mean:
>
>Supported for *all* dialects
>
> as opposed to:
>
>I have coded this before Vincent did the patch, so the last
>argument is missing.

Yes, nil (omitted) should indeed mean "run with all dialects" but I
don't see why this requires `nor'.  The only place I found it is in the
docstring of `TeX-add-style-hook' where you say that omitted is
equivalent to (nor).  You could also just say that it's equivalent to
`(not (or))', no?

To me it looks just a bit strange to have `and' and `or' but not a plain
`not'.  Do me a favor and just add a normal `not' that just delegates to
`nor'.

Bye,
Tassilo


___
auctex mailing list
auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex


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

2014-09-08 Thread Vincent Belaïche
Please ignore the previous patch attachment: I had not made all the
corresponding updates in the ChangeLog.

>Hello Tassilo et alii,
>

[...]

>
>Bye,
>  Vincent.

Re-Bye,
   Vincent.

diff --git a/ChangeLog b/ChangeLog
index 9b70f3a..2318fb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,329 @@
+2014-09-08  Vincent Belaïche  
+
+	* style/xspace.el ("xspace"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/xparse.el ("xparse"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/virtex.el ("virtex"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/verbatim.el ("verbatim"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/varioref.el ("varioref"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/url.el ("url"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/units.el ("units"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/unicode-math.el ("unicode-math"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/ulem.el ("ulem"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/tabulary.el ("tabulary"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/tabularx.el ("tabularx"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/swedish.el ("swedish"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/subfigure.el ("subfigure"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/slovak.el ("slovak"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/slides.el ("slides"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/siunitx.el ("siunitx"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/shortvrb.el ("shortvrb"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/setspace.el ("setspace"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrreprt.el ("scrreprt"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrpage2.el ("scrpage2"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrlttr2.el ("scrlttr2"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrbook.el ("scrbook"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrbase.el ("scrbase"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrartcl.el ("scrartcl"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/ruby.el ("ruby"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/report.el ("report"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/ragged2e.el ("ragged2e"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pstricks.el ("pstricks"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pst-slpe.el ("pst-slpe"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pst-plot.el ("pst-plot"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pst-node.el ("pst-node"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pst-grad.el ("pst-grad"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/psfig.el ("psfig"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/prosper.el ("prosper"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/polski.el ("polski"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/polish.el ("polish"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/plhb.el ("plhb"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/plfonts.el ("plfonts"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/plext.el ("plext"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/placeins.el ("placeins"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pdfsync.el ("pdfsync"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/paralist.el ("paralist"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/nomencl.el ("nomencl"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/nicefrac.el ("nicefrac"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/ngerman.el ("ngerman"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/naustrian.el ("naustrian"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/natbib.el ("natbib"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/nameref.el ("nameref"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/multirow.el ("multirow"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/multind.el ("multind"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/multido.el ("multido"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/multicol.el ("multicol"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/mflogo.el ("mflogo"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/metalogo.el ("metalogo"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/memoir.el ("memoir"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/mdwlist.el ("mdwlist"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/mathtools.el ("mathtools"): Add LaTeX-dialect to TeX-add-styl

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

2014-09-08 Thread Vincent Belaïche
Hello Tassilo et alii,

My updated patch attached. Comment inserted below.

> From: t...@gnu.org
> To: vincent@hotmail.fr
> CC: m...@gnu.org; auctex@gnu.org
> Subject: Re: [AUCTeX] Problem with latex2e style hook --- LaTeX/Texinfo 
> collision‏
> Date: Mon, 8 Sep 2014 09:44:16 +0200
> 
> Vincent Belaïche  writes:
> 
> Hi Vincent,
> 

[...]

> > 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.
>

Great! Ok not to have any docstring.

> > 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.

I think that his problem was that he had to change his workflow so that
he would not have the case foo.tex and foo.bib in the same directory,
with foot.tex using foo.bib as a bibliography.

My patch _should_ solve that, but I must admit that I have not yet
tested it because I do not know what symptom Mosè actually was meeting
when editing the bib file.

I seems that there is no such thing as some reduced AUCTeX support in
BibTeX file (like `C-c C-f ...' for setting formatting).

Mosè could you provide a minimal example of the bug --- was the issue
ever logged in AUCTeX issue tracker ?

BTW I could not find the issue tracker at
https://savannah.gnu.org/projects/auctex, are you at all using an issue
tracker (or AUCTeX does not have any issues :-P :-DDD ).

> 
> > - 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! :-)
>

Gone!

> > 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.
>
Done, except that I named it

TeX-bibtex-set-BibTeX-dialect

because the matter is to set dialect to *BibTeX* (not LaTeX) when you
are in BibTeX mode.

Well: this may mean that some of hooks will need to be allowing both
BibTeX and LaTeX dialects (actually I don't think so, as there do not
seem to be anything like BibTeX editing support in AUCTeX appart from
bib-cite which I don't know about.

Please expect that you might see something looking like a regression
when editing BibTeX files if you rely on some style hook being active in
those files.

> > 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?
>

Completed, the intention was

See variable `TeX-style-hook-dialect'.

> > 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 

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

2014-09-08 Thread Tassilo Horn
Vincent Belaïche  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-di

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

2014-09-06 Thread Vincent Belaïche
Hello,

I am back at it.

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.

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.
  
- 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).

Comments & brickbats welcome...


  Vincent.

diff --git a/ChangeLog b/ChangeLog
index 01ff6dc..b154d6f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,330 @@
+2014-09-06  Vincent Belaïche  
+
+	* style/xspace.el ("xspace"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/xparse.el ("xparse"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/virtex.el ("virtex"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/verbatim.el ("verbatim"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/varioref.el ("varioref"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/url.el ("url"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/units.el ("units"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/unicode-math.el ("unicode-math"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/ulem.el ("ulem"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/tabulary.el ("tabulary"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/tabularx.el ("tabularx"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/swedish.el ("swedish"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/subfigure.el ("subfigure"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/slovak.el ("slovak"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/slides.el ("slides"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/siunitx.el ("siunitx"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/shortvrb.el ("shortvrb"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/setspace.el ("setspace"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrreprt.el ("scrreprt"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrpage2.el ("scrpage2"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrlttr2.el ("scrlttr2"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrbook.el ("scrbook"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrbase.el ("scrbase"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/scrartcl.el ("scrartcl"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/ruby.el ("ruby"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/report.el ("report"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/ragged2e.el ("ragged2e"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pstricks.el ("pstricks"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pst-slpe.el ("pst-slpe"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pst-plot.el ("pst-plot"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pst-node.el ("pst-node"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pst-grad.el ("pst-grad"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/psfig.el ("psfig"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/prosper.el ("prosper"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/polski.el ("polski"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/polish.el ("polish"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/plhb.el ("plhb"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/plfonts.el ("plfonts"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/plext.el ("plext"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/placeins.el ("placeins"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/pdfsync.el ("pdfsync"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/paralist.el ("paralist"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/nomencl.el ("nomencl"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/nicefrac.el ("nicefrac"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* style/ngerman.el ("ngerman"): Add LaTeX-dialect to TeX-add-style-hook call.
+
+	* sty