Skip to content

Cyclic function indirection with context-mode and ConTeXt-mode in AUCTeX autoloads. #1253

@hongyi-zhao

Description

@hongyi-zhao

Dear AUCTeX and straight.el developers,

I am writing to report and seek clarification on a persistent issue
with the cyclic function indirection error related to context-mode
and ConTeXt-mode in AUCTeX.

Issue Description

When using AUCTeX with straight.el package manager, I consistently
encounter the following error during startup:

Debugger entered--Lisp error: (cyclic-function-indirection context-mode)
  defalias(context-mode ConTeXt-mode)
  eval((defalias 'context-mode #'ConTeXt-mode))
  straight--activate-package-autoloads(...)

Environment

Root Cause

The issue appears to be in the auctex-autoloads.el file,
specifically this line:

(defalias 'context-mode #'ConTeXt-mode)

This creates a circular reference when the autoloads are processed, as
ConTeXt-mode itself is defined as an autoload that hasn't been
loaded yet.

Relationship to Previous Bug Reports

I noticed this appears to be related to bug#68998 and bug#69081. While
bug#68998 was closed with a workaround for the upgrade process (using
emacs -Q), the underlying cyclic function indirection issue seems to
persist in daily usage scenarios.

Current Workaround

I am currently using this workaround in my straight.el configuration:

(use-package auctex
  :straight (:type git :host nil :repo
"https://git.savannah.gnu.org/git/auctex.git"
             :pre-build (("make"))
             :post-build (("sed" "-i" "/^(defalias 'context-mode
#'ConTeXt-mode)$/d" "auctex-autoloads.el"))
             :files (:defaults "doc/*"))
  ;; ... rest of configuration
  )

This removes the problematic defalias line after each build, which
resolves the issue.

Questions

  1. Is this a known ongoing issue, or should the cyclic reference
    problem have been resolved?

  2. Would it be appropriate to modify the autoload generation to handle
    this defalias more safely, perhaps with a conditional check like:

    (when (fboundp 'ConTeXt-mode)
      (defalias 'context-mode #'ConTeXt-mode))
  3. Is there a recommended approach for package managers like
    straight.el to handle this issue without manual post-build
    modifications?

Additional Context

This issue affects not just the initial loading but also functionality
like M-x completion in some configurations, as reported by other
users in the Emacs community.

Thank you for your excellent work on AUCTeX and straight.el. I would be happy to
provide additional debugging information or test potential fixes.

See here for the related discussion.

Best regards,
Zhao

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions