emacsdbusauctex

Emacs: dbus-related error when trying to switch to latex mode


since I began using dbus with Emacs some days ago (meaning I recompiled with dbus-support), when I open a latex-file or try to switch manually to latex-mode, I get

File mode specification error: (invalid-function dbus-ignore-errors)

and emacs stops there remaining in fundamental mode.

I use dbus for Zeitgeist-Support and that works fine and up to the recompilation, Auctex worked equally fine. I checked if the dbus-functions are available with the result: They show up in the help (including "dbus-ignore-errors") but they don't seem to be available for execute-extended-commad (M-x) meaning they don't show up in completion and cannot be executed. On the other hand they are available for lisp-eval.

I don't know if that's normal behavior for these functions, but anyway there seems to be some sort of a problem with the availability of the functions for auctex?

The situation does not change by disabling the zeitgeist-plugin.

Any suggestions?

Best regards

Matthias


Solution

  • The error invalid-function usually means that a piece of Emacs Lisp code was compiled before a certain macro was defined, and is now trying to call that macro as a function. To solve this, find the module in question and recompile it after making sure that the macro (dbus-ignore-errors in this case) is defined.


    In the case of Auctex, this happens because tex.el contains the following:

    ;; Require dbus at compile time to prevent errors due to `dbus-ignore-errors'
    ;; not being defined.
    (eval-when-compile (and (featurep 'dbusbind)
                (require 'dbus nil :no-error)))
    

    That is, it tries to load the dbus library, but ignores failures. If the Emacs under which Auctex is being compiled doesn't support dbus, dbus-ignore-errors will thus be compiled into a function call when compiling tex.el. That's no problem, because the dbus-ignore-errors call is protected by a featurep test.

    If this byte-compiled file is then loaded into an Emacs instance that does support dbus, we suddenly reach the line in question, and try to call the macro as a function, which fails with invalid-function. That's why the file needs to be recompiled before being loaded into a dbus-enabled Emacs.

    One way to solve this is to wrap the dbus-ignore-errors line into eval, changing this line:

         (dbus-ignore-errors (dbus-get-unique-name :session))
    

    to this:

         (eval '(dbus-ignore-errors (dbus-get-unique-name :session)))
    

    That would postpone the decision on how to evaluate that expression until runtime, when Emacs will know that dbus-ignore-errors is a macro.