-
Notifications
You must be signed in to change notification settings - Fork 166
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 takes 1.7 seconds to load #264
Comments
I just profiled the The delay, I think, is because I used this invocation:
Here is the
|
Yep, I can verify that λ emacs -Q -L ~/prog/markdown-mode --eval='
(progn
(setq markdown-url-compose-char ?∞)
(setq markdown-blockquote-display-char "▌")
(setq markdown-hr-display-char ?─)
(setq markdown-definition-display-char ?<2058>)
(setq start-time (float-time))
(require (quote markdown-mode))
(message "Markdown require: %f s" (- (float-time) start-time)))'
The mailing list post was not especially inspiring. It's the standard rhetoric of only start emacs once. The easy answer is to use ASCII. I'd say switching depends on how useful people find the nice characters. Another avenue is to look at the base fonts for the major operating systems to see what percentage include a fallback font that covers the code points. I'd imagine by this point, most distros support all the characters. You could even hard code a list of supported fonts and use that instead of A nice middle ground is to document the slowness and provide a work-around. Maybe reach out to the major Emacs config distros (spacmeacs, prelude, etc.) and ask if they want to customize how they use markdown-mode. Spacemacs has something like a Here's a workaround with (use-package markdown-mode
:defer t
:mode ("\\.md\\'" . gfm-mode)
:init
;; Prevent ~1.7 second delay by avoiding `char-displayable-p'. See
;; https://github.com/jrblevin/markdown-mode/issues/264
(setq markdown-url-compose-char ?∞)
(setq markdown-blockquote-display-char "▌")
(setq markdown-hr-display-char ?─)
(setq markdown-definition-display-char ?⁘)) |
Hmm, I'm wondering whether loading |
Thanks for all of these suggestions. I see now that checking at load time isn't necessarily reliable, so I'm leaning towards making these variables sequences and checking at display time, as @phst suggested. I haven't checked, but allegedly (according to a mailing list thread) subsequent calls to |
With this commit, `markdown-hr-display-char` is permitted to be a list. The default value is now a sequence of possible characters and the first one that is displayable will be used. This is part of a series of changes to improve the load time by deferring calls to `char-displayable-p`. See GH-264.
With this commit, `markdown-url-compose-char` is permitted to be a list. The default value is now a sequence of possible characters and the first one that is displayable will be used. This is part of a series of changes to improve the load time by deferring calls to `char-displayable-p`. See GH-264.
With this commit, `markdown-blockquote-display-char` is permitted to be a list. The default value is now a sequence of possible strings and the first one that is displayable will be used. This is part of a series of changes to improve the load time by deferring calls to `char-displayable-p`. See GH-264.
With this commit, `markdown-definition-display-char` is permitted to be a list. The default value is now a sequence of possible characters and the first one that is displayable will be used. This is part of a series of changes to improve the load time by deferring calls to `char-displayable-p`. See GH-264.
Following the suggestion of @phst, I have updated the defcustoms in question to be lists and only check for displayable characters at fontification time. For backwards compatibility, atomic values for these variables are allowed as well. This reduces the load time down to around 0.1 s for me. Let me know if there are any issues and thanks for reporting @jschaf. |
Loading or requiring
markdown-mode
hangs Emacs for about 1.7 seconds.Here's a command to verify (maybe update the load path
-L
).I haven't looked into the source of the slow-down but it seems excessive.
System info:
The text was updated successfully, but these errors were encountered: