Skip to content

Instantly share code, notes, and snippets.

@tttuuu888
Last active June 6, 2021 02:57
Show Gist options
  • Save tttuuu888/267a8a56c207d725ea999e353646eec9 to your computer and use it in GitHub Desktop.
Save tttuuu888/267a8a56c207d725ea999e353646eec9 to your computer and use it in GitHub Desktop.
Eye-candy for Emacs package loading time
(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)
@aspiers
Copy link

aspiers commented May 23, 2021

That's awesome! Please please could this be turned into a MELPA package?! gists are a nightmare for any kind of collaboration.

@tttuuu888
Copy link
Author

@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.

@aspiers
Copy link

aspiers commented May 24, 2021

Thank you so much :-)

@tttuuu888
Copy link
Author

@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~

@aspiers
Copy link

aspiers commented May 27, 2021

Fantastic! Thanks a lot again! 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment