branch: elpa/racket-mode commit b6db517f79c067e5519871909bb842bb2d266047 Author: Greg Hendershott <g...@greghendershott.com> Commit: Greg Hendershott <g...@greghendershott.com>
Add racket-package-refresh command; remove auto refresh The previous commit would refresh the local catalog on every startup of the Racket Mode back end. On reflection this seems wrong. Some users might not want a connection to made. Instead supply a command for users to do this explicitly, when they choose. Downside is the results will be poor until they do this at least once, but we document this. Anyway this is analogous to `package-refresh-contents` for Emacs packages, and the idea here was already to largely follow the same UX. --- doc/generate.el | 1 + doc/racket-mode.texi | 21 ++++++++++++++++++++- racket-package.el | 45 +++++++++++++++++++++++++++++++-------------- racket/package.rkt | 8 +------- 4 files changed, 53 insertions(+), 22 deletions(-) diff --git a/doc/generate.el b/doc/generate.el index 8b4287a207..3ce74fcde5 100644 --- a/doc/generate.el +++ b/doc/generate.el @@ -108,6 +108,7 @@ racket-expand-definition racket-expand-last-sexp "Packages" + racket-package-refresh list-racket-packages racket-package-mode describe-racket-package diff --git a/doc/racket-mode.texi b/doc/racket-mode.texi index 8ca768b3d4..314783dabb 100644 --- a/doc/racket-mode.texi +++ b/doc/racket-mode.texi @@ -183,6 +183,7 @@ Macro expand Packages +* racket-package-refresh:: * list-racket-packages:: * racket-package-mode:: * describe-racket-package:: @@ -2874,11 +2875,22 @@ were 'disabled. @section Packages @menu +* racket-package-refresh:: * list-racket-packages:: * racket-package-mode:: * describe-racket-package:: @end menu +@node racket-package-refresh +@subsection racket-package-refresh + +@kbd{M-x} @code{racket-package-refresh} + +Refresh the local copy of package catalogs. + +Will make HTTP requests to remote catalog servers. May take a few +seconds to complete. + @node list-racket-packages @subsection list-racket-packages @@ -2894,7 +2906,10 @@ Open a @ref{racket-package-mode} buffer for the active back end. Major mode for Racket package management. The list of packages is equivalent to ``raco pkg show -all'' on -the active back end. +the active back end -- that is, all packages installed manually +or as dependencies -- plus packages available from your +configured catalogs, assuming you have run the command +@ref{racket-package-refresh}. On each row you can press RET to @code{describe-racket-package}, which opens a buffer where you can view details, and use buttons to @@ -2951,6 +2966,10 @@ file. There is also a button to each module's locally installed documentation, if any. @end itemize +If the package is available from a catalog, additional details +will be shown, assuming you have run the command +@ref{racket-package-refresh}. + @node Other @section Other diff --git a/racket-package.el b/racket-package.el index e80805f9fd..cc6af4cf46 100644 --- a/racket-package.el +++ b/racket-package.el @@ -47,7 +47,10 @@ "Major mode for Racket package management. The list of packages is equivalent to \"raco pkg show -all\" on -the active back end. +the active back end -- that is, all packages installed manually +or as dependencies -- plus packages available from your +configured catalogs, assuming you have run the command +`racket-package-refresh'. On each row you can press RET to `describe-racket-package', which opens a buffer where you can view details, and use buttons to @@ -115,7 +118,11 @@ Detail values are links when possible: - For installed packages, each /Modules/ item links to the local file. There is also a button to each module's locally installed - documentation, if any." + documentation, if any. + +If the package is available from a catalog, additional details +will be shown, assuming you have run the command +`racket-package-refresh'." (interactive (racket--package-completing-read)) (let ((name (if name-or-button (if (stringp name-or-button) @@ -375,6 +382,14 @@ Allows users to customize via `completion-category-overrides'.") 'racket-package-url url)) (newline)))))) +(defun racket-package-refresh () + "Refresh the local copy of package catalogs. + +Will make HTTP requests to remote catalog servers. May take a few +seconds to complete." + (interactive) + (racket--do-pkg-op 'refresh nil)) + (defun racket--package-insert-raco-pkg-op-button (verb name) (insert-text-button (symbol-name verb) :type 'racket-package-op @@ -388,12 +403,13 @@ Allows users to customize via `completion-category-overrides'.") (defun racket-raco-pkg-op (&optional button) (interactive) (unless button (error "no raco pkg button here")) - (let ((verb (button-get button 'raco-pkg-verb)) - (name (button-get button 'raco-pkg-name)) - (inhibit-read-only t)) - (pop-to-buffer (racket--package-notify-buffer-name) - '(display-buffer-below-selected)) - (racket--cmd/async nil `(pkg-op ,verb ,name)))) + (racket--do-pkg-op (button-get button 'raco-pkg-verb) + (button-get button 'raco-pkg-name))) + +(defun racket--do-pkg-op (verb name) + (pop-to-buffer (racket--package-notify-buffer-name) + '(display-buffer-below-selected)) + (racket--cmd/async nil `(pkg-op ,verb ,name))) (defun racket--package-notify-buffer-name () (format "*Racket Package Operations <%s>*" (racket-back-end-name))) @@ -411,15 +427,16 @@ Allows users to customize via `completion-category-overrides'.") (quit-window) ;; Fully refresh *Racket Packages* list because "--auto" commands ;; can install/remove/update multiple, dependent packages. - (with-current-buffer (racket--package-buffer-name) - (tabulated-list-revert) - (let ((win (get-buffer-window (current-buffer)))) - (when win - (set-window-point win (point))))) + (when-let (buf (get-buffer (racket--package-buffer-name))) + (with-current-buffer buf + (tabulated-list-revert) + (let ((win (get-buffer-window buf))) + (when win + (set-window-point win (point)))))) ;; Also refresh the status for this package in the *Help* ;; buffer. (with-current-buffer (help-buffer) - (revert-buffer))) + (help-mode-revert-buffer nil nil))) (`(error ,message) (insert (propertize message 'face 'compilation-error))) diff --git a/racket/package.rkt b/racket/package.rkt index 9eea837f0b..c5ce838fd8 100644 --- a/racket/package.rkt +++ b/racket/package.rkt @@ -22,7 +22,6 @@ get-pkg-tags get-pkg-modules) (only-in pkg - pkg-config-command pkg-install-command pkg-update-command pkg-remove-command) @@ -39,12 +38,7 @@ catalog-package-doc-link package-notify-channel) -(define catalog-local-cache - (delay/thread (pkg-catalog-update-local #:quiet? #t) - 'ready)) - (define (package-list) - (force catalog-local-cache) (define installed (installed-packages)) (define catalog (for/hash ([p (in-list (get-pkgs))]) (values (pkg-name p) p))) @@ -69,7 +63,6 @@ "")))) (define (package-details name) - (force catalog-local-cache) (define props (make-hasheq)) (define (merge! . kvs) (hash-union! props (apply hash kvs) #:combine (λ (_a b) b))) @@ -297,6 +290,7 @@ ['install (λ () (pkg-install-command #:auto #t name))] ['update (λ () (pkg-update-command name))] ['remove (λ () (pkg-remove-command #:auto #t name))] + ['refresh (λ () (pkg-catalog-update-local))] [else (error 'package-op "unknown verb")])) (define (put v) (channel-put package-notify-channel