Last active
June 6, 2021 02:57
-
-
Save tttuuu888/267a8a56c207d725ea999e353646eec9 to your computer and use it in GitHub Desktop.
Eye-candy for Emacs package loading time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar sk-package-loading-notice-list '(org yasnippet)) | |
(defun sk-package-loading-notice (old &rest r) | |
(let* ((elt (car r)) | |
(mode | |
(when (stringp elt) | |
(let ((ret (assoc-default elt auto-mode-alist 'string-match))) | |
(and (symbolp ret) (symbol-name ret))))) | |
(pkg | |
(cond ((symbolp elt) elt) | |
((stringp mode) (intern (string-remove-suffix "-mode" mode))) | |
(t nil)))) | |
(if (not (member pkg sk-package-loading-notice-list)) | |
(apply old r) | |
(let ((msg (capitalize (format " %s loading ..." pkg))) | |
(ovr (make-overlay (point) (point)))) | |
(when (fboundp 'company-cancel) (company-cancel)) | |
(setq sk-package-loading-notice-list | |
(delq pkg sk-package-loading-notice-list)) | |
(unless sk-package-loading-notice-list | |
(advice-remove 'require #'sk-package-loading-notice) | |
(advice-remove 'find-file #'sk-package-loading-notice)) | |
(message msg) | |
(overlay-put ovr 'after-string | |
(propertize msg 'face '(:inverse-video t :weight bold))) | |
(redisplay) | |
(let ((ret (apply old r))) | |
(delete-overlay ovr) | |
ret))))) | |
(advice-add 'require :around #'sk-package-loading-notice) | |
(advice-add 'find-file-noselect :around #'sk-package-loading-notice) |
Thank you so much :-)
@aspiers I made this as a package in https://github.com/tttuuu888/package-loading-notifier. I made a pull request for Melpa as well but not yet merged. Thank you~
Fantastic! Thanks a lot again! 😎
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@aspiers Thank you for your suggestion. I will work on it and will leave a comment here when I'm done to some degree. Thanks.