auctex-devel
[Top][All Lists]
Advanced

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

Re: [AUCTeX-devel] Add `unit' type for the parser in siunitx.el


From: Tassilo Horn
Subject: Re: [AUCTeX-devel] Add `unit' type for the parser in siunitx.el
Date: Tue, 26 Feb 2013 09:08:36 +0100
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux)

Mosè Giordano <address@hidden> writes:

Hi Mosè,

sorry for being late with this.

>> If you have a sample tex file plus a recipe how to reproduce the
>> error, I could check myself.  E.g. a tex file using siunitx with some
>> custom unit definitions, and then I change it not to use siunitx and
>> revert the buffer, so that I hit the undefined function error.
> LaTeX source code:
> ------------------------------------------------------------------------
> \documentclass{article}
>
> \usepackage{siunitx}
>
> \DeclareSIUnit\parsec{pc}
> \DeclareSIUnit\lightyear{ly}
> ------------------------------------------------------------------------
> Save the buffer, parsed file will be written with this content
> ------------------------------------------------------------------------
> (TeX-add-style-hook
>  "test"
>  (lambda ()
>     (TeX-run-style-hooks
>      "latex2e"
>      ""
>      "article"
>      "art10"
>      "siunitx")
>     (LaTeX-add-siunitx-units
>      "\\parsec"
>      "\\lightyear")))
> ------------------------------------------------------------------------
> Comment or remove `\usepackage{siunitx}', then save the buffer.
> Parsed file will be written, with `LaTeX-add-siunitx-units' function
> but without `siunitx' hook.  Close Emacs, then reopen Emacs and the
> LaTeX source.  Result: error message in the echo area
>   Symbol's function definition is void: LaTeX-add-siunitx-units

Yep, that was easy to reproduce.  I've hopefully fixed that in my last
commit.  The style hook application in `TeX-run-style-hooks' is now
guarded by a `condition-case' that simply ignores void-function errors.

--8<---------------cut here---------------start------------->8---
Index: tex.el
===================================================================
RCS file: /sources/auctex/auctex/tex.el,v
retrieving revision 5.710
retrieving revision 5.711
diff -u -r5.710 -r5.711
--- tex.el      25 Feb 2013 12:05:10 -0000      5.710
+++ tex.el      26 Feb 2013 08:01:28 -0000      5.711
@@ -2433,8 +2433,15 @@
                                            (TeX-master-directory))
                        style (substring style
                                         (match-beginning 2) (match-end 2))))
-               (mapcar 'funcall
-                       (cdr-safe (assoc style TeX-style-hook-list))))))
+               (condition-case err
+                   (mapcar 'funcall
+                           (cdr-safe (assoc style TeX-style-hook-list)))
+                 ;; This happens in case some style added a new parser, and
+                 ;; now the style isn't used anymore (user deleted
+                 ;; \usepackage{style}).  Then we're left over with, e.g.,
+                 ;; (LaTeX-add-siunitx-units "\\parsec"), but the function is
+                 ;; defined in a style siunitx.el that's not loaded anymore.
+                 (void-function nil)))))
          styles))
 
 (defcustom TeX-parse-self nil
--8<---------------cut here---------------end--------------->8---

The result is that (1) you obviously don't get an error when opening the
sample file again, and (2) the auto file has the contents

--8<---------------cut here---------------start------------->8---
(TeX-add-style-hook
 "unit"
 (lambda ()
    (TeX-run-style-hooks
     "latex2e"
     ""
     "article"
     "art10")))
--8<---------------cut here---------------end--------------->8---

afterwards, i.e., the problematic code is gone.  Basically, everything
is gone.  What's there is the result of reparsing.

Bye,
Tassilo




reply via email to

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