Update packages/ Add org-ref
This commit is contained in:
26
elpa/racket-mode-20180609.1253/util.rkt
Normal file
26
elpa/racket-mode-20180609.1253/util.rkt
Normal file
@@ -0,0 +1,26 @@
|
||||
#lang racket/base
|
||||
|
||||
(require (for-syntax racket/base
|
||||
syntax/parse))
|
||||
|
||||
(provide display-commented
|
||||
with-dynamic-requires
|
||||
box-swap!)
|
||||
|
||||
(define (display-commented str)
|
||||
(eprintf "; ~a\n"
|
||||
(regexp-replace* "\n" str "\n; ")))
|
||||
|
||||
(define-syntax (with-dynamic-requires stx)
|
||||
(syntax-parse stx
|
||||
[(_ ([lib:id id:id] ...+) body:expr ...+)
|
||||
#'(let ([id (dynamic-require 'lib 'id)] ...)
|
||||
body ...)]))
|
||||
|
||||
(define (box-swap! box f . args)
|
||||
(let loop ()
|
||||
(let* ([old (unbox box)]
|
||||
[new (apply f old args)])
|
||||
(if (box-cas! box old new)
|
||||
new
|
||||
(loop)))))
|
||||
Reference in New Issue
Block a user