emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/racket-mode b54ada52d7 1/8: Change xref var to get-xref fu


From: ELPA Syncer
Subject: [nongnu] elpa/racket-mode b54ada52d7 1/8: Change xref var to get-xref function; delete xref-ready-evt
Date: Fri, 22 Nov 2024 19:00:43 -0500 (EST)

branch: elpa/racket-mode
commit b54ada52d780eb4adfead41d47de7797152548de
Author: Greg Hendershott <git@greghendershott.com>
Commit: Greg Hendershott <git@greghendershott.com>

    Change xref var to get-xref function; delete xref-ready-evt
    
    The ready event, although not used, wasn't implemented correctly.
    
    Although moot now, better to set this up to work correctly if needed
    someday.
---
 racket/commands/help.rkt |  1 +
 racket/scribble.rkt      |  9 +++++----
 racket/xref.rkt          | 14 +++++++++-----
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/racket/commands/help.rkt b/racket/commands/help.rkt
index 96757861ed..020223f857 100644
--- a/racket/commands/help.rkt
+++ b/racket/commands/help.rkt
@@ -28,6 +28,7 @@
   (->identifier how str stx->uri-string))
 
 (define (stx->uri-string stx)
+  (define xref (get-xref))
   (match (and xref (xref-binding->definition-tag xref stx 0))
     [(? tag? tag)
      (define-values (path anchor) (xref-tag->path+anchor xref tag))
diff --git a/racket/scribble.rkt b/racket/scribble.rkt
index 63e2fa9072..03e764fde8 100644
--- a/racket/scribble.rkt
+++ b/racket/scribble.rkt
@@ -44,7 +44,8 @@
 
 (define/contract (binding->path+anchor stx)
   (-> identifier? (or/c #f (cons/c path-string? (or/c #f string?))))
-  (let* ([tag (xref-binding->definition-tag xref stx 0)]
+  (let* ([xref (get-xref)]
+         [tag (xref-binding->definition-tag xref stx 0)]
          [p+a (and tag (tag->path+anchor xref tag))])
     p+a))
 
@@ -72,7 +73,7 @@
 
 (define/contract (identifier->bluebox stx)
   (-> identifier? (or/c #f string?))
-  (match (xref-binding->definition-tag xref stx 0)
+  (match (xref-binding->definition-tag (get-xref) stx 0)
     [(? tag? tag) (get-bluebox-string tag)]
     [_ #f]))
 
@@ -169,7 +170,7 @@
              (let ([ht (exported-index-desc*-extras desc)])
                (or (hash-ref ht 'hidden? #f)
                    (hash-ref ht 'constructor? #f))))))
-  (for* ([entry (in-list (xref-index xref))]
+  (for* ([entry (in-list (xref-index (get-xref)))]
          [desc (in-value (entry-desc entry))]
          #:when desc
          #:unless (hide-desc? desc)
@@ -181,7 +182,7 @@
   root)
 
 (define (doc-trie-value desc term tag)
-  (define-values (path anchor) (xref-tag->path+anchor xref tag))
+  (define-values (path anchor) (xref-tag->path+anchor (get-xref) tag))
   (define (method-what)
     (cond
       [(method-tag? tag)
diff --git a/racket/xref.rkt b/racket/xref.rkt
index b55b90ecd0..9179bf12ef 100644
--- a/racket/xref.rkt
+++ b/racket/xref.rkt
@@ -5,9 +5,13 @@
 
 (require setup/xref)
 
-(provide xref
-         xref-ready-evt)
+(provide get-xref)
 
-(define xref-ready-evt never-evt)
-(define xref (begin0 (load-collections-xref)
-               (set! xref-ready-evt always-evt)))
+;; A single xref instance for all our modules to share.
+;;
+;; Will block safely until ready, if used from e.g. delay/thread or
+;; delay/idle (which, although we're not doing now, we've done before,
+;; and might do again someday).
+(define sema (make-semaphore 1))
+(define xref (call-with-semaphore sema load-collections-xref))
+(define (get-xref) (call-with-semaphore sema (λ () xref)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]