Skip to content

Issue when org mode errors #4898

@egh

Description

@egh

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

When org-mode throws an error and is loaded before lsp-mode, it causes some issues (that I don't fully understand) with compilation that messes up the cl generic dispatch system. I've narrowed down this issue (after way too much work) to d183627. I have seen this issue on linux and mac os on Emacs 30.2. Breaking this means that lots of things start breaking in emacs.

Steps to reproduce

Here is a minimal file to reproduce (slightly updated from original report):

🤔 cat test.el
(setq package-archives
      '(("melpa" . "https://melpa.org/packages/")
        ("melpa-stable" . "https://stable.melpa.org/packages/")
        ("gnu-devel" . "https://elpa.gnu.org/packages/")))
(package-initialize)
(use-package org-mode :hook ((org-mode . foo)))
(ignore-errors
  (with-temp-buffer (org-mode)))
(use-package lsp-mode :ensure t)
(message "%s" (seq-empty-p '()))

🤔 emacs --batch --load test.el
Error (use-package): lsp-mode/:catch: Autoloading file /snap/emacs/current/usr/share/emacs/30.2/lisp/org/org.elc failed to define function foo

Error: cl-no-applicable-method (seq-empty-p nil)
  signal(cl-no-applicable-method (seq-empty-p nil))
  cl-no-applicable-method(#s(cl--generic :name seq-empty-p :dispatches nil :method-table nil :options nil) nil)
  apply(cl-no-applicable-method #s(cl--generic :name seq-empty-p :dispatches nil :method-table nil :options nil) nil)
  seq-empty-p(nil)
  (message "%s" (seq-empty-p 'nil))
  load-with-code-conversion("/home/egh/test.el" "/home/egh/test.el" nil t)
  command-line-1(("--load" "test.el"))
  command-line()
  normal-top-level()
No applicable method: seq-empty-p, nil

Expected behavior

This issue was introduced in d183627. Versions before that work fine.

🤔 rm -rf ~/.emacs.d/elpa

~ 
🤔 emacs --batch --load test.el
Importing package-keyring.gpg...
Importing package-keyring.gpg...done
Contacting host: melpa.org:443
Contacting host: melpa.org:443
...
t

Which Language Server did you use?

none, lsp mode itself only

OS

Linux

Error callstack

Anything else?

Wrapping the call to (org-mode) in lsp--org-element-use-new-api with (ignore-errors ...) corrects the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions