Skip to content

Slowdown (or even error) with files containing a lot of comments #536

@aeporreca

Description

@aeporreca

Expected Behavior

I think markdown-mode should be able to work with files containing arbitrarily many comments (in my case, the comments are automatically generated by giving the flyspell-mode command flyspell-correct-word-before-point followed by the “Accept (buffer)” menu entry).

Actual Behavior

When opening a Markdown file containing a lot of comments, such as the attached test.txt (I renamed it as .txt since I don’t know how to upload an .md file) and editing the text while the comments are visible on screen, there is a long lag before the result of the text-editing commands becomes apparent. This does not seem to happen if the comments are not visible (e.g., if you have to scroll down to see them).

When the number of comments becomes very large, such as in the attached test2.txt file, the problem becomes even worse, with an (error "Lisp nesting exceeds ‘max-lisp-eval-depth’").

Steps to Reproduce

Open test.txt and edit it, or just open test2.txt, after having renamed them to .md.

Backtrace

  • For the slowdown occurring when editing test.txt: according to the Emacs profiler, most of the time seems to be spent inside the markdown-syntax-propertize-comments function.

  • See the attached backtrace.txt for the error obtained when opening test2.txt.

Software Versions

  • Markdown Mode: version 2.5-dev
  • Emacs: 27.1
  • OS: macOS Catalina 10.15.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions