Disable population of `file-name-history', it causes calls to
abbreviate-file-name => file-name-case-insensitive-p => tramp-autoload-file-name-handler
taking 40% of startup time.
`ido-switch-buffer' doesn't depends on `file-name-history', nothing to lose.
Profiling data for startup:
- eval-buffer 4340 99%
- recentf-mode 1684 38%
- recentf-load-list 1684 38%
- mapcar 1684 38%
- abbreviate-file-name 1684 38%
- file-name-case-insensitive-p 1250 28%
+ tramp-autoload-file-name-handler 1172 26%
+ tramp-file-name-handler 78 1%
;;; pypi.el --- Handle work with Python pypi site.
;;; Commentary:
;;
(require 'url-handlers)
(require 'thingatpt)
(eval-when-compile
(defvar url-http-response-status))
;;; Code:
(defvar pypi/buffer-name "*Pip*")
(defvar pypi/pkg-history nil)
(defvar pypi/url "https://pypi.python.org/pypi/%s/json")
(defun pypi/pkg-callback (status)
(let ( (buffer (current-buffer)) content-type status )
(setq content-type (mail-fetch-field "Content-Type"))
(setq status url-http-response-status)
(switch-to-buffer pypi/buffer-name)
(erase-buffer)
(url-insert buffer)
(fundamental-mode)
(when (and (eq status 200) (string-match "application/json" content-type))
(js-mode))))
;;;###autoload
(defun pypi-pkg (pkg)
(interactive (list
(read-string "Python package: "
(if (region-active-p) (buffer-substring (mark) (point)) (thing-at-point 'symbol))
'pypi/pkg-history)))
(url-retrieve (format pypi/url pkg) #'pypi/pkg-callback))
(provide 'pypi)
;;; pypi.el ends here