Re: [racket-users] Re: local variables are hyperlinked in scribble/manual

2020-05-25 Thread Ryan Culpepper
You can also use make-element-id-transformer, like this:

(define-syntax SET
  (make-element-id-transformer
   (lambda _ #'(racketvarfont "set"

Then Scribble will automatically replace SET within rendered code with the
element expression above.

Another trick is to break the for-label binding by introducing a local
binding that shadows it. For example, if you write

(let ([set #f])
  (racket set))

then the occurrence of `set` within the `racket` form isn't linked to `set`
from racket/set. This trick relies on being able to put a let around the
occurrences you don't want linked but not the ones that you do want linked,
so it might not work in all cases.

Ryan


On Mon, May 25, 2020 at 4:55 PM Ryan Kramer 
wrote:

> My favorite way to avoid this problem is simply to choose another name, or
> use `except-in` to avoid importing `set` for-label. But if you must use the
> name `set` and you want it linking to racket/set most of the time (but not
> this time), here is a technique I've used in the past:
>
> #lang scribble/manual
>
> @(require (for-label racket) scribble/eval
>   (for-syntax racket
>   syntax/parse))
>
> @(define-for-syntax (replace-helper stx orig-sym new-sym)
>(let ([content (syntax-e stx)])
>  (cond
>[(list? content)
> (datum->syntax stx
>(map (λ (child) (replace-helper child orig-sym
> new-sym))
> content)
>stx stx)]
>[(equal? orig-sym content)
> (datum->syntax #f new-sym stx #f)]
>[else
> stx])))
>
> @(define-syntax (replace stx)
>(syntax-parse stx
>  [(_ [orig:id new:id] body:expr)
>   (replace-helper #'body (syntax-e #'orig) (syntax-e #'new))]))
>
> @(replace
>   [SET set]
>   @interaction[
>  (let ((SET 1)) (add1 SET))])
>
>
> On Sunday, May 24, 2020 at 11:26:54 AM UTC-5, jos.koot wrote:
>>
>> Hi,
>>
>> I have:
>>
>>
>>
>> #lang scribble/manual
>>
>> @(require (for-label racket) scribble/eval)
>>
>> @interaction[
>>
>> (let ((set 1)) (add1 set))]
>>
>>
>>
>> I prepare a HTML document with DrRacket (in Windows 10).
>>
>> Works, but local variable set is hyperlinked to procedure set in the
>> documents (racket/set). I would like this variable to be typeset as any
>> other local variable. How can I do that without loosing the hyperlink where
>> I do mean the procedure from racket/set ?
>>
>>
>>
>> Thanks, Jos
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/ffd4f155-ee18-409d-b92f-9450d976220f%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CANy33qk3Q3F6uLx9_Y%2BRNUb4j-z4DEuH3_%2BEgSc4evnNHpoXgg%40mail.gmail.com.


[racket-users] Re: local variables are hyperlinked in scribble/manual

2020-05-25 Thread Ryan Kramer
My favorite way to avoid this problem is simply to choose another name, or 
use `except-in` to avoid importing `set` for-label. But if you must use the 
name `set` and you want it linking to racket/set most of the time (but not 
this time), here is a technique I've used in the past:

#lang scribble/manual

@(require (for-label racket) scribble/eval
  (for-syntax racket
  syntax/parse))

@(define-for-syntax (replace-helper stx orig-sym new-sym)
   (let ([content (syntax-e stx)])
 (cond
   [(list? content)
(datum->syntax stx
   (map (λ (child) (replace-helper child orig-sym 
new-sym))
content)
   stx stx)]
   [(equal? orig-sym content)
(datum->syntax #f new-sym stx #f)]
   [else
stx])))

@(define-syntax (replace stx)
   (syntax-parse stx
 [(_ [orig:id new:id] body:expr)
  (replace-helper #'body (syntax-e #'orig) (syntax-e #'new))]))

@(replace
  [SET set]
  @interaction[
 (let ((SET 1)) (add1 SET))])


On Sunday, May 24, 2020 at 11:26:54 AM UTC-5, jos.koot wrote:
>
> Hi,
>
> I have:
>
>  
>
> #lang scribble/manual
>
> @(require (for-label racket) scribble/eval)
>
> @interaction[
>
> (let ((set 1)) (add1 set))]
>
>  
>
> I prepare a HTML document with DrRacket (in Windows 10).
>
> Works, but local variable set is hyperlinked to procedure set in the 
> documents (racket/set). I would like this variable to be typeset as any 
> other local variable. How can I do that without loosing the hyperlink where 
> I do mean the procedure from racket/set ?
>
>  
>
> Thanks, Jos
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/ffd4f155-ee18-409d-b92f-9450d976220f%40googlegroups.com.