bug-auctex
[Top][All Lists]
Advanced

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

[Bug-AUCTeX] 2013-12-18; Broken comment padding


From: Derrik Petrin
Subject: [Bug-AUCTeX] 2013-12-18; Broken comment padding
Date: Fri, 20 Dec 2013 13:58:48 -0800

Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.

Be sure to consult the FAQ section in the manual before submitting
a bug report.  In addition check if the bug is reproducable with an
up-to-date version of AUCTeX.  So please upgrade to the version
available from http://www.gnu.org/software/auctex/ if your
installation is older than the one available from the web site.

If the bug is triggered by a specific (La)TeX file, you should try
to produce a minimal sample file showing the problem and include it
in your report.

Your bug report will be posted to the AUCTeX bug reporting list.
------------------------------------------------------------------------

AUCTeX is a fantastic piece of software that I have used very frequently
over the past year for writing up assignments.  You guys have done a
great job, especially with the support for knitr!

However, I recently noticed a small bug.  It's actually pretty
remarkable that I stumbled across it since it is such a specific
case.

What I was trying to do: I was experimenting with ispell in a small
LaTeX file.  ispell was working well and happily and I was entering
file-local words with no problem (using 'A' while in ispell mode).
However, suddenly and for no reason I could fathom, I was unable to add
new words to the file-local dictionary, unless there was already at
least one word in it.  Every time I tried to enter a first new word an
error popped up:

    ispell-add-per-file-word-list: Wrong type argument: sequencep, 1

Two newlines were appended to the end of the file, but that was it.


I did some digging and debugging and this is what I have gathered...

1) ispell uses the variable 'comment-padding' when adding the line '%
LocalWords:  [word]' to the end of a file, which it does if a file-local
dictionary has not yet been initialized.

2) When visiting a .tex file in a new buffer, AUCTeX initializes
'comment-padding' to '1'.

3) If ispell tries to use 'comment-padding' when its value is '1', then
the above error appears.

4) If, after visiting the file, a comment is made with the command
'M-;', or a line is indented, then 'comment-padding' gets set to "
". This is because 'indent-according-to-mode' ends up being called,
which calls 'LaTeX-indent-line', which in turn calls
'TeX-comment-padding-string', which turns 'comment-padding' from an
integer to a string of spaces that many characters long, namely: " ".

5) Once 'comment-padding' has been converted to a string, ispell
functions perfectly normally.


So, it looks like 'comment-padding' remains an integer (as it was
initialized by LaTeX mode) until 'TeX-comment-padding-string' is
called.  This only happends when 'indent-according-to-mode' is called,
so if any function tries to use the variable 'comment-padding' before
that happens, it'll be borked.  This almost *never* happens, except
apparently in the rare case of adding the first file-local word to the
ispell dictionary of a file, and possibly some edge cases.

My recommendation?  Run 'TeX-comment-padding-string' during
initialization!


Here are minimal examples.  The version of Emacs is 24.3.1.  The version
of AUCTeX is 11.87.2, installed using package.el.  No .emacs file was
used.

With this file, if you run ispell on the whole buffer BEFORE DOING
ANYTHING ELSE (either 'M-x ispell' or 's-:') and then hit 'A' to add
'Foo' to the file-local dictionary, then the error arises and two
newlines are appended to the file:

[code]
\documentclass{article}

\begin{document}
Foo Barr
\end{document}
[\code]

With this file, if you do the same as above (only adding 'Barr' to the
file-local dictionary rather than 'Foo') no error arises:

[code]
\documentclass{article}

\begin{document}
Foo Barr
\end{document}

%  LocalWords:  Foo
[\code]


Hope this helps!

Derrik


Emacs  : GNU Emacs 24.3.1 (x86_64-apple-darwin12.4.0, NS apple-appkit-1187.39)
 of 2013-07-10 on dfpair.systemsbiology.net
Package: 2013-12-18

current state:
==============
(setq
 AUCTeX-date "2013-12-18"
 window-system 'ns
 LaTeX-version "2e"
 TeX-style-path '("/usr/local/var/auctex"
                  "/Users/Derrik/.emacs.d/el-get/auctex/auctex/style"
                  "/Users/Derrik/.emacs.d/auctex/auto"
                  "/Users/Derrik/.emacs.d/auctex/style" "auto" "style")
 TeX-auto-save t
 TeX-parse-self t
 TeX-master nil
 TeX-command-list '(("TeX" "%(PDF)%(tex) %`%S%(PDFout)%(mode)%' %t"
                     TeX-run-TeX nil
                     (plain-tex-mode ams-tex-mode texinfo-mode) :help
                     "Run plain TeX")
                    ("LaTeX" "%`%l%(mode)%' %t" TeX-run-TeX nil
                     (latex-mode doctex-mode) :help "Run LaTeX")
                    ("Makeinfo" "makeinfo %t" TeX-run-compile nil
                     (texinfo-mode) :help "Run Makeinfo with Info output")
                    ("Makeinfo HTML" "makeinfo --html %t" TeX-run-compile nil
                     (texinfo-mode) :help "Run Makeinfo with HTML output")
                    ("AmSTeX" "%(PDF)amstex %`%S%(PDFout)%(mode)%' %t"
                     TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
                    ("ConTeXt" "texexec --once --texutil %(execopts)%t"
                     TeX-run-TeX nil (context-mode) :help "Run ConTeXt once")
                    ("ConTeXt Full" "texexec %(execopts)%t" TeX-run-TeX nil
                     (context-mode) :help "Run ConTeXt until completion")
                    ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help
                     "Run BibTeX")
                    ("Biber" "biber %s" TeX-run-Biber nil t :help "Run Biber")
                    ("View" "%V" TeX-run-discard-or-function t t :help
                     "Run Viewer")
                    ("Print" "%p" TeX-run-command t t :help "Print the file")
                    ("Queue" "%q" TeX-run-background nil t :help
                     "View the printer queue" :visible TeX-queue-command)
                    ("File" "%(o?)dvips %d -o %f " TeX-run-command t t :help
                     "Generate PostScript file")
                    ("Index" "makeindex %s" TeX-run-command nil t :help
                     "Create index file")
                    ("Xindy" "texindy %s" TeX-run-command nil t :help
                     "Run xindy to create index file")
                    ("Check" "lacheck %s" TeX-run-compile nil (latex-mode)
                     :help "Check LaTeX file for correctness")
                    ("ChkTeX" "chktex -v6 %s" TeX-run-compile nil (latex-mode)
                     :help "Check LaTeX file for common mistakes")
                    ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil
                     t :help "Spell-check the document")
                    ("Clean" "TeX-clean" TeX-run-function nil t :help
                     "Delete generated intermediate files")
                    ("Clean All" "(TeX-clean t)" TeX-run-function nil t :help
                     "Delete generated intermediate and output files")
                    ("Other" "" TeX-run-command t t :help
                     "Run an arbitrary command")
                    )
 )



reply via email to

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