Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

markdown-mode hangs Emacs #44

Closed
alecigne opened this issue Dec 18, 2015 · 13 comments
Closed

markdown-mode hangs Emacs #44

alecigne opened this issue Dec 18, 2015 · 13 comments
Labels
Milestone

Comments

@alecigne
Copy link

Hi,

I work on a fairly large markdown file (126k) and commit 86e0c76 (from Dec 16) hangs Emacs regularly (it lags when I type fast, lags when I use scroll-up-command or scroll-down-command, etc.). Everything works fine with the previous commit. I also tried with a minimal init file, only requiring markdown-mode, and the problem is the same.

I'd like to be able to provide more details here but I don't know how to proceed.

Thank you

@jrblevin
Copy link
Owner

Thanks for your report. I am aware that are some issues with lag and hanging, particularly with very large files, and I am actively looking into it. (See also #30 and #42.) This should be helpful in isolating at least one of the issues.

@jrblevin jrblevin added the bug label Dec 18, 2015
@hut8
Copy link

hut8 commented Dec 18, 2015

I'm getting this also. My file is very small. Looking around briefly it appears this happens on all files. I just upgraded this morning. If I can be of more help, please let me know.

@jrblevin
Copy link
Owner

Can you check to see whether the recent commits improved things?

@alecigne
Copy link
Author

I have no quantitative data but I think it's better now. It doesn't hang anymore when using scroll-up-command and scroll-down-command or when folding and unfolding. However, the lag when typing fast is still here. When I type full speed, the displayed text doesn't update at all.

Edit: actually, the "typing fast" lag depends on where I am located in the file. Do you see any reason for this?

@jrblevin
Copy link
Owner

Thanks for checking! I used the profiler to scroll through a large (> 5000 line) file and it is now much faster for me. I didn't check typing. Parsing Markdown accurately and in real time is difficult, but I will keep working to make it more efficient. I will try profiling when entering text into a large file as well to see where the bottlenecks are.

@jrblevin
Copy link
Owner

Further profiling revealed that the insertion lag was mostly due to the after-change hook that performs wiki link fontification. I will have a patch ready soon that substantially speeds things up!

@hut8
Copy link

hut8 commented Dec 19, 2015

Works great for me now. Thanks very much!

@jrblevin
Copy link
Owner

@hut8 Great—I'm glad it's working better now.

@alecigne I just saw your edit. It does make sense that it could be better or worse depending on the surrounding context. Some regions may be more difficult to parse than others. When you insert characters, things have to be parsed again in case the syntax changed.

I just pushed commit acf7c5e which I think should essentially eliminate the lag when typing. Please let me know if not. For me, this makes any lag almost imperceptible in my 5000+ line file, but if it doesn't work for you then I may ask for a more specific test case.

Another thing you can do to increase performance is to set markdown-make-gfm-checkboxes-buttons to nil. When this is non-nil, markdown-mode must check all input for checkboxes.

@jrblevin jrblevin modified the milestone: v2.1 Dec 19, 2015
@alecigne
Copy link
Author

Hi,

Thank you for looking into this. Commit acf7c5e doesn't fix the lagging problem. My file is actually my PhD thesis and thus contains a LOT of references in the format:

[@chow2012]

or

[@goldberg2008; @pajerowski2007]

That may be the source of the problem. This is a format understood by pandoc-citeproc. There are also quite a lot of sections. If you give me some time, I will try and build an example file in which the problem is present, since I don't want to send you my thesis (and you really don't want to receive it) ;)

As for now, I will continue to use markdown-mode under version 01dc652.

@jrblevin
Copy link
Owner

One option is to obfuscate your thesis while preserving the syntax. Then I could see first hand what is happening. If you are on Linux or OS X, may I suggest using tr to randomly scramble the letters while leaving the symbols, markup, and punctuation intact? Here's one suggestion:

cat thesis.md | tr '[a-zA-Z]' 'x' | tr '[0-9]' '1' > scramble.md

It translates all letters to 'x' and all numbers to '1'. If that's sufficiently obfuscated, then you could email the file to me at jrblevin@sdf.org.

Edit: Of course, if your thesis is in French this won't handle some letters. You also could do it in Emacs:

M-x replace-regexp RET [[:alpha:]] RET x
M-x replace-regexp RET [[:digit:]] RET 1

Obviously, back up your thesis first :)

@jrblevin
Copy link
Owner

I have also created a new branch to help us diagnose the problem without disturbing the main branch: https://github.com/jrblevin/markdown-mode/tree/diagnose-44

There are two commits of interest right now. Both are based on the current HEAD.

  1. Commit c428fe9 reverts back to the old extend-region function from the "good" commit 01dc652.
  2. Commit a8af698 is (another) alternative extend-region function that I'd like to test.

Could you check number 2 first and if that doesn't work, also try number 1? Thanks for your patience while we narrow this down.

@alecigne
Copy link
Author

Hi,

The new version of the function (commit a8af698) fix the lagging problem. For what it's worth, c428fe9 does as well.

My thesis is indeed in French, and is about biology – so in a way it is already pretty well obfuscated! But all jokes aside if you still need the file despite the new working function, let me know and I will send it to you.

Again, thank you for your quick response.

@jrblevin
Copy link
Owner

Excellent! Likewise, thanks for testing out these changes so quickly and helping improve markdown-mode! Good luck with your thesis—it's an honor that you're writing it in markdown-mode. Let me know if you have any other issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants