[racket-users] Changing code fonts and turning off Unicode replacement in Scribble LaTeX output?

2017-10-23 Thread David Christiansen
Hi all,

I'm working on a set of lecture notes in Scribble, and the code blocks
contain identifiers that are Greek letters (namely, capital gamma and
lowercase rho). I'd like to render a pretty PDF as well as HTML output.
In the resulting LaTeX, however, the code includes things like
\RktSym{$\lambda$} and \RktVar{$\Gamma$}, which causes these
identifiers to be displayed using the math font instead of the
monospace code font, causing them to stick out like a sore thumb. I've
tested it by manually editing the file to put the Unicode names back
in, and the PDF looks fine coming out of both XeLaTeX and LuaLaTeX. 

I can certainly rig up a hacky Makefile to postprocess the output a
bit, but it would be nice to have a more elegant solution. Is there a
better way to configure the Unicode replacement?

Relatedly, I'd like to customize the TeX monospace font to one that I
happen to know contains lots of Unicode, and that I like the looks of.
As far as I can tell, declaring a TeX prefix at the command line will
blow away all of scribble/manual, while I just want to insert 2 lines.
The best I've been able to do so far is to add:

@(require scribble/core
  scribble/html-properties
  scribble/latex-properties)

@(define mycode
   (make-style "mycode"
   (list (make-tex-addition "mycode.tex"

to the top of the main document that includes all the sections, and
then 

@elem[#:style mycode]{}

somewhere to get the style included. mycode.tex contains:

\usepackage{fontspec}
\setmonofont{PragmataPro}
\newcommand*{\mycode}[1]{}

I'm not particularly concerned about compatibility with old-school
pdflatex here.

Is there a more elegant way to cause some LaTeX code to appear in the
preamble?

Thanks!

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Multiple namespaces in Racket

2017-10-15 Thread David Christiansen
> Ultimately, though, that would mean that it would separate the runtime
> value and type namespaces, but now types and users’ phase 1 bindings
> would share the same namespace, which is still probably confusing and
> unintuitive. Maybe that’s okay? Again, I feel like I’d need to
> understand better why we idiomatically use phase 0 transformer bindings
> for these things — I don’t really get it.

The LCF-style tactic engine that Sam and I have running in the macro
expander uses a transformer binding to _invoke_ the tactic engine, but
all of the individual tactics live in phase 1 bindings. Though there's
no call to syntax-local-eval - they're just used directly.

I would think that, similarly, type ascription could be a macro that
associates entirely phase-1 type values with run-time expressions. But
there's surely aspects of this that I don't see :-)

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Multiple namespaces in Racket

2017-10-15 Thread David Christiansen
> It would probably cause trouble iif we ever were to generalize to
> dependent types.

Sure, but those same problems will be there anyway if the compile-time
and run-time bindings live in separate namespaces and are allowed to
bind the same identifier to different things, as is done in languages
like Haskell.

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Multiple namespaces in Racket

2017-10-15 Thread David Christiansen
Hi Alexis,

What about keeping type bindings separate from program bindings as a
matter of phase? This seems to me to fit in with the Hindley-Milner
program, where types exist only at compile time only, and programs
exist at run time only.

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread David Christiansen

> Not with map, which requires equal-length arguments.
>
> You could do the slightly less ugly:
>
> (map
> foo
> lst-A
> lst-B
> (range (length lst-A)))

Why not do it this way?

(struct foo (a b c))
(define lst-A '(a b))
(define lst-B '(d e))
(for/list ([a (in-list lst-A)]
   [b (in-list lst-B)]
   [n (in-naturals)])
  (foo a b n))

This seems to be the nicest of the lot.

/David

--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How do I find where a module is located?

2017-02-14 Thread David Christiansen

On 02/14/2017 12:00 PM, David Storrs wrote:


I prefer Emacs to Dr Racket


In that case, if you're using racket-mode, you can use 
racket-open-require-path (C-c C-x C-f by default) or M-x 
racket-find-collection to get to the source of particular import or of a 
collection. You can probably find out how to do this programmatically by 
reading the racket-mode source.


Hope this is handy.

/David

--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] DrRacket: Interactive choice of what submodules to run when clicking Run

2017-01-24 Thread David Christiansen
In Greg Hendershott's racket-mode for Emacs, the "run" command will run 
the submodule that's under the cursor. Something similar that would let 
one right-click a submodule to run it in DrRacket would be quite nice.


/David


On 01/24/2017 12:17 PM, Robby Findler wrote:

There's not a simple way to do that right now, but I think a change to
the code to make that more configurable would be great.

It is probably best to make this as a change to DrRacket proper and
support a cleaner interface all around. It might be nice to be able to
click on things in the interactions window to change the set that will
be run next time, for example.

I've been thinking that this needs cleanup but haven't find time to
actually do it, sadly.

Robby


On Tue, Jan 24, 2017 at 11:13 AM, Laurent  wrote:

Hi all,

Currently we can choose what submodules to run via the 'Choose Language...'
settings.

I'd like to make a keyboard shortcut that executes the current module but
first asks the user what submodules she wants to run.

So far I found
(add-drs-function "run"  (λ (frame) (send frame execute-callback)))
https://github.com/racket/drracket/blob/da4d2db396290edebee0e87908a0ff265c4c6f3a/drracket/drracket/private/rep.rkt#L213

and the 'execute-callback':
https://github.com/racket/drracket/blob/da4d2db396290edebee0e87908a0ff265c4c6f3a/drracket/drracket/private/unit.rkt#L2854

But it seems that what submodules are run may be buried in
'module-language-settings'. Or is there a simple way to dynamically override
these settings, say with an argument to 'execute-callback'?

If that's too difficult, as a workaround I could go with running the module
without any submodule---so I can choose afterwards what submodules to enter.

Thanks,
Laurent

--
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.
For more options, visit https://groups.google.com/d/optout.




--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] list->set behavior on lists of symbols

2016-12-28 Thread David Christiansen
Hi Deyaa,

> I wonder why (list->set '('1)) evaluates to (set ''1) instead of (set '1).
> I use Racket v6.7.

The expression

'('1)

is a shorter way of writing

(quote ((quote 1)))

The value of (quote x) is x, so the value of that is the list containing
(quote 1), or ((quote 1)). In other words, the list contains a quote form.

When making that into a set, you stick the quoted form into the set, so
the set contains the form (quote 1), not just the 1.

Then, when the set is displayed, it is displayed in a way that you could
type it in to get something equal to it. This means putting the extra
quote around the data in it, so that it evaluates back to the original
form, because procedures like set do evaluate their arguments.

So the list contained (quote 1), and thus the set did as well. An
expression that evaluates to (quote 1) is (quote (quote 1)), or ''1.

Hope this made sense.

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Meta-question: "Racket to go"andtheformatofthedocumentation...

2016-11-05 Thread David Christiansen
Hi Meino,

> ... the resulting file was 46x times bigger than the input.
> This is little to much for a flash based budget tablet...;)
> Any idea to circumeven this?

Unfortunately not. I typically just print the resulting file.

Good luck!

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Meta-question: "Racket to go"andtheformatofthedocumentation...

2016-11-05 Thread David Christiansen
Hello,

> Is there a (simple) way to get rid of most
> of the white blank border and to create
> the pdfs in a differen page format (aspect
> ratio) ?

I often use a little command-line utility called pdfcrop to remove margins
from PDF files. It's also useful for economical printing of long texts,
because printing 2 pages per side has less wasted space.

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Better? or less good?

2016-10-21 Thread David Christiansen
Hi again,

> The latter has the same meaning as this:
>
> (let ((v #t))
>   (if v v fnord))
>
> This is not even a program, because "fnord" has no meaning.

Robby pointed out off-list that I should point out that this is a
feature of Racket, not programming languages in general. In many other
languages, variable references are a runtime feature rather than a
part of the syntax. Here's some Elisp, which makes the other decision:

el> (let ((v t)) (if v v fnord))
t

Similar results are obtained in many languages. Others, however, work
as Racket does in this respect, like Idris:

Idris> let v = True in if v then v else fnord
When checking argument val to constructor Delay:
No such variable fnord

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Thanks for slideshow, racket/gui, and the rest!

2016-09-20 Thread David Christiansen
Today I delivered a talk at ICFP with slides written in slideshow,
with an embedded Idris interactive editor and REPL. The slides got
good feedback from the audience. I used a similar setup for my PhD
defense in January.

Thanks so much to Matthew, Robby, and the rest of you for all the hard
work on slideshow, pict, and the editor framework that allowed me to
do this!

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] DrRacket's auto-indentation outside DrRacket?

2016-08-25 Thread David Christiansen
> The code I sent would be influenced by the preferences I believe. But you
> could test that?

I will, when I'm next on a machine with Racket. Is there a way to set
these preferences programmatically, though? I intend to run the code
in a VM that is created from scratch each time the tests are run (on
Travis), so scripting the setting of the preferences is pretty
important.

Thanks again!

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] DrRacket's auto-indentation outside DrRacket?

2016-08-25 Thread David Christiansen
>>> The specification has to come with feature and/or the language, not the 
>>> tool. How would Emacs know about it? Or Notepad? Every editor — and every 
>>> tool in the tool chain — must know what indentation means if it may touch 
>>> it.

My goal here is not for Emacs to know how to indent things perfectly,
it is merely to ensure that Emacs or my merge tool have not made a
hash of it. Also, perhaps more importantly, it should ensure that
other contributors' editors haven't made a hash of it! This is a much
easier problem!

> How would a library express indentation rules? Would indentation rules meant 
> for s-expression languages be useful in at-exp or sweet-exp notations?

At least in Elisp, indentation rules are specified by using a
"declare" form in a macro definition [1]. racket-mode for Emacs also
allows a similar customization of indentation by setting properties on
symbol plists, which provides something about as expressive as the
DrRacket configuration dialog. A good indenter for Racket would
probably need to macroexpand the source, but I imagine that something
like a designated submodule could contain indentation specifications
in a similar format.

[1]: 
https://www.gnu.org/software/emacs/manual/html_node/elisp/Indenting-Macros.html#Indenting-Macros

I don't know how to properly indent things from other readers, though.

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] DrRacket's auto-indentation outside DrRacket?

2016-08-25 Thread David Christiansen
Hi Robby,

Thank you very much for a fast and useful answer!

> I'm not sure about the suitable configuration: that should probably
> happen via the #lang line and shouldn't be configured "from the
> outside" (we're not quite there yet, but that's where we should be
> heading, IMO).

Today, this is done by setting individual preferences in DrRacket. Is
there a reasonably easy way to set these preferences for the
racket:text% ?  It's clearly not a general solution, and I agree that
either the #lang line or the macro definition should be able to affect
these things, but in my case I've got a project that defines a couple
of macros, and I am happy to manually configure them in my CI setup. I
already have Emacs directory variables to set up their indentation for
racket-mode in Emacs, for instance.

> But for point 2, here's a script. It depends on the GUI library.
> Removing that dependency is possible, but probably a lot of work.

My test suite already depends on the GUI library, so that's no problem
at all for me.

Thanks again!

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] DrRacket's auto-indentation outside DrRacket?

2016-08-25 Thread David Christiansen
Hi all,

As far as I know, the standard for indentation in Racket is "Do like
DrRacket", after DrRacket has been suitably configured for new syntax
introduced by the application in question.

I'd like to arrange for this to be enforced by Travis. As far as I can
see, my building blocks for this are the following:

1. A way to represent indentation specifications for new syntactic forms

2. A way to invoke automatic indentation on a file without running a
GUI, using these specifications in addition to the default rules

Is there a canonical way to achieve these things?

Thanks!

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Detecting mouse events on top of picts?

2016-06-08 Thread David Christiansen

> Looking at the docs for region%, Racket doesn't have a simple way to do
> this - it still could be done by force and might not be that slow
> depending on the complexity of the "scene" in the image.  If you're
> familiar with image processing, the basic idea is recursive "blob"
> identification.

I don't have much background in image processing, but I'll keep this in
mind in case the current method becomes untenable at some point. Thanks
for the pointer!

> I saw in your reply to Matthias that you are "drawing" the pictures into
> an offscreen bitmap.  I know that word  "drawing" is overloaded:  did
> you mean you loaded a bitmap (from a file?) and made an offscreen copy,
> or that you are composing the image with pen/brush.  Reason I ask is
> that if you are composing, constructing a corresponding region% might be
> relatively easy.

What I mean is that I'm using draw-pict to cause the contents of a pict
to be drawn on a dc<%> that I get from a bitmap%. The bitmap is
initialized empty and transparent, and then the pict is drawn to it. I
can tell which pixels are affected by the drawing by seeing if they are
still transparent.

I don't know a good way to get a region% out of that, or even if it
would be faster than the current approach.

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Detecting mouse events on top of picts?

2016-06-07 Thread David Christiansen
> Why don’t you check the location of the mouse movement? The coordinates are 
> close enough. 

I do check the location of the mouse movement to find a canvas location.
What I was looking for a smarter way to do was to check whether or not
that particular pixel was drawn by a particular pict that has previously
been displayed in the canvas.

My best approach thus far is to draw the pict into a bitmap, off-screen,
and see if it the corresponding pixel has been modified. I was hoping
that someone knew a smarter way, perhaps in a part of the GUI API that I
had not found, but it doesn't seem to be the case.

In any case, my current solution is working well enough for now.

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Detecting mouse events on top of picts?

2016-06-06 Thread David Christiansen
> That seems overly complicated.  Can you not just compare the mouse's
> coordinates to the picture's location in the canvas?

I don't have a good way to know where the picture itself is - only its
bounding box. So if the picture consists of a doughnut shape, I want
the center of the doughnut and the region around its edge to not count
as clicks on it.

My first go at this was actually built on an image combinator library
where each image also could report on which pixels within its bounding
box were occluded, but I'd much rather re-use all the great things in
pict than develop my own.

So I use the location on the canvas and the size of the bounding boxes
to determine which pictures to actually check, and then the drawing
test to see if the mouse is actually over them.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Detecting mouse events on top of picts?

2016-06-06 Thread David Christiansen
> If I understand the goal, you could render to one bitmap that has an
> alpha channel, and then check whether the pixel under the mouse ends up
> with a non-zero alpha.

That's a good simplification. Thanks!

I had kind of been hoping that there was an alternative approach that
I was missing, but this at least will save one drawing.

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket PPA updated for 6.5

2016-05-01 Thread David Christiansen
Hi Asumu,

Thanks for maintaining this! It's great to have it for my Ubuntu machine!

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket PPA updated for 6.4

2016-02-09 Thread David Christiansen
Asumu,

Thanks so much for maintaining this!

/David

2016-02-09 20:26 GMT-05:00 Asumu Takikawa :
> Hi all,
>
> The Racket PPA for Ubuntu has been updated to v6.4:
>
>   https://launchpad.net/~plt/+archive/ubuntu/racket
>
> I've tested it on Wily. Let me know if you find any problems.
>
> Cheers,
> Asumu
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Ligatures for monospace fonts in editors?

2016-01-03 Thread David Christiansen
All right, no worries. It would make the slides a bit prettier, but
Pragmata is also beautiful without the ligatures. Now that I know it's
non-trivial, I will do other things!

Thanks!

/David

On 03/01/16 01:36, Matthew Flatt wrote:
> The `text%` layer currently manipulates characters individually.
> Unfortunately, I think it would be a lot of work to change that layer
> so that kerning and ligatures work in a `text%` editor --- but I
> haven't actually tried it.
> 
> At Sat, 2 Jan 2016 16:18:39 -0800, Alexis King wrote:
>> This is well-timed, as I was wondering precisely the same thing myself just
>> yesterday. Atom recently gained support for ligatures, and I was trying out
>> Hasklig, since I normally use Source Code Pro as my monospace font. I tried 
>> it
>> out in DrRacket as well, and I was disappointed (though not surprised) to 
>> find
>> that the ligatures were ignored.
>>
>> I don’t know how much effort it would take to add support for this in 
>> Racket’s
>> text rendering engine, but I think it would be a welcome addition, probably
>> for a lot more than just rendering pretty code ligatures.
>>
>> Alexis
>>
>>> On Jan 2, 2016, at 4:13 PM, David Christiansen <da...@davidchristiansen.dk> 
>> wrote:
>>>
>>> Hello all,
>>>
>>> I'm using the font Pragmata Pro to display code samples in Slideshow. In
>>> particular, I've developed a sort of mini-IDE for Idris that can be
>>> embedded in a slide, using the `interactive' procedure to show it.
>>>
>>> Pragmata Pro has some very nice ligatures for code punctuation. In
>>> particular, it displays => as a fat arrow, -> as a thin arrow, and /= as
>>> a slashed-out equals sign. I'd like to display these in my editor, but
>>> it seems to disable ligatures. I've attempted manually setting the
>>> family to 'swiss and the face to "PragmataPro", in the hope of avoiding
>>> the 'modern family (which at least the `text' procedure in pict ignores
>>> ligatures for), but this hasn't helped.
>>>
>>> I know that Racket can display the ligatures, because evaluating (text
>>> "->" "PragmataPro") at the REPL displays the ligature.
>>>
>>> Does anyone have a suggestion?
>>>
>>> Thanks!
>>>
>>> /David
>>>
>>> -- 
>>> 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.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>> -- 
>> 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.
>> For more options, visit https://groups.google.com/d/optout.
> 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Ligatures for monospace fonts in editors?

2016-01-03 Thread David Christiansen
Matthew,

> 1) In a Unicode-aware language like Racket, there's no way to visually
> distinguish a presentational use of a ligature from a syntactic use. For
> instance, these two strings would be displayed the same way:
> 
> (string-append* '("m" "f" "l" "a" "t" "t"))
> (string-append* '("m" "fl" "a" "t" "t"))

I agree that this particular ligature would be unfortunate!

> 2) Additionally, many of the ligatures being introduced in programming
> fonts are visually similar to real Unicode characters. So if '!=' becomes
> some ligaturistic '≠', how do we distinguish that from #\u2260?

At least in Pragmata, -> and → or /= and ≠ are quite visually distinct.
It's a monospace font, so all of the programming punctuation ligatures
are two or three times as wide as the single-character Unicode ligatures
(depending on how many characters the ligature combines).

> 3) There are a lot of ways for a given string literal, like "->", to end up
> in source code, and it doesn't always mean the same thing. Therefore, any
> global ligature substitution is guaranteed to be wrong part of the time.

This is true. In particular, rendering <= as "less than or equal" rather
than "fat left arrow" can be confusing. In practice, when writing a
significant amount of code with it, it hasn't been a practical problem.
Though I think the ergonomics for Racket would be different than those
for Haskell or Idris, so I probably wouldn't want them in Racket.

> Sorry to yell at the clouds of progress. I once noticed a related problem
> in Dybvig and SICP [1]. The moral remains: prettifying code by glyph
> substitution is a swamp of despair. If you don't believe me, try it for 10
> or 15 years.

Will do :-) At least until complicated Unicode input becomes easy enough
and its display becomes universal enough to make Agda-style Unicode
syntax practical outside of Emacs :-)

Thanks for the warning! I imagine that further discussions of this sort
ought to be moved to private emails, rather than clogging up racket-users.

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Ligatures for monospace fonts in editors?

2016-01-02 Thread David Christiansen
Hello all,

I'm using the font Pragmata Pro to display code samples in Slideshow. In
particular, I've developed a sort of mini-IDE for Idris that can be
embedded in a slide, using the `interactive' procedure to show it.

Pragmata Pro has some very nice ligatures for code punctuation. In
particular, it displays => as a fat arrow, -> as a thin arrow, and /= as
a slashed-out equals sign. I'd like to display these in my editor, but
it seems to disable ligatures. I've attempted manually setting the
family to 'swiss and the face to "PragmataPro", in the hope of avoiding
the 'modern family (which at least the `text' procedure in pict ignores
ligatures for), but this hasn't helped.

I know that Racket can display the ligatures, because evaluating (text
"->" "PragmataPro") at the REPL displays the ligature.

Does anyone have a suggestion?

Thanks!

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Letter spacing in slideshow

2015-12-17 Thread David Christiansen
I'm in the process of learning slideshow, and it's tons of fun! I vastly
prefer Racket to LaTeX for algorithmically generating slides :-)

However, I'm encountering a pretty major issue with font rendering. I'm
running Racket 6.3 under GNOME 3.16 on Linux.

I have noticed that, with a number of fonts, lowercase letters following
a capital T are drawn very close to the T. My understanding is that
Racket uses GTK, Pango, and Cairo to draw, so I tested it out in gedit
with the same font, as well as XeTeX.

At https://imgur.com/a/BVi2r, you can see the results. The first
screenshot is from slideshow, where the word "Types" looks very odd
compared to the other two, which have roughly the same layouts. Some
other letter spacings are also a bit compressed, but none as radically
as "Ty".

Is this a misconfiguration on my part? A bug in Racket somewhere? Can
anyone suggest a work-around?

Thanks in advance!

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Letter spacing in slideshow

2015-12-17 Thread David Christiansen
I seem to have clicked "Reply" rather than "Reply list" - sorry for the
duplicate email, Matthew!

--

Thanks so much for a quick answer! Sorry it took me a bit to get back, I
had to go read up on the relevant APIs.

I've managed to cause the problem at the REPL, and it does seem to be
dependent on the backing scale.

Here's my test program:

#lang racket

(require racket/gui)

(define (get-bitmap backing-scale) (make-object bitmap% 500 300 #f #f
backing-scale))

(define (test backing-scale kern?)
  (let* ((bitmap (get-bitmap backing-scale))
 (dc (new bitmap-dc% [bitmap bitmap])))
(send dc set-font (make-object font% 100 "PT Sans Narrow" 'default))
(send dc draw-text "Types" 0 0 kern?)
bitmap))

And here's what I get when I evaluate the following at the REPL:
(for*/list ([scale (list 1.0 2.0)] [combine (list #f #t)]) (list scale
combine (test scale combine)))

https://imgur.com/Sj2qhOp

It seems that the problem occurs with kerning enabled, but a backing
scale of 2.0.

Any ideas on how I can work around this?

Thanks again!

/David


On 17/12/15 16:37, Matthew Flatt wrote:
> Letter spacing there certainly does look wrong. While "Ty" is the most
> obvious problem, "Pr" and "Re" look too closely spaced, also. It
> appears that spacing is going wrong for kerning pairs, and not for
> other pairs of letters.
> 
> You're correct that Racket defers to Pango and Cairo to kern and draw
> text. One possibility is that something is going wrong with using a
> font at size N with a drawing scale of M (as opposed to using a font of
> size N*M and a drawing scale of 1). Slideshow is likely using a value
> of M other than 1, and other programs seem unlikely to be using a
> drawing scale. In particular, as I recall, you have a high-resolution
> display, which means that Slideshow will render to a bitmap with a
> backing scale of 2, and likely an additional drawing scale to stretch
> the 1024x768 slide dimensions to fit your screen.
> 
> To help diagnose the problem, could you perform experiments along those
> lines at the level of a `bitmap%` and `bitmap-dc%`? The key is to call
> `draw-text` with #t as the fourth argument, which enables kerning. You
> could create a bitmap with different backing scales and also use
> different drawing scales (as set by the `scale` method of `dc<%>`, for
> example).
> 
> At Thu, 17 Dec 2015 16:21:07 +0100, David Christiansen wrote:
>> I'm in the process of learning slideshow, and it's tons of fun! I vastly
>> prefer Racket to LaTeX for algorithmically generating slides :-)
>>
>> However, I'm encountering a pretty major issue with font rendering. I'm
>> running Racket 6.3 under GNOME 3.16 on Linux.
>>
>> I have noticed that, with a number of fonts, lowercase letters following
>> a capital T are drawn very close to the T. My understanding is that
>> Racket uses GTK, Pango, and Cairo to draw, so I tested it out in gedit
>> with the same font, as well as XeTeX.
>>
>> At https://imgur.com/a/BVi2r, you can see the results. The first
>> screenshot is from slideshow, where the word "Types" looks very odd
>> compared to the other two, which have roughly the same layouts. Some
>> other letter spacings are also a bit compressed, but none as radically
>> as "Ty".
>>
>> Is this a misconfiguration on my part? A bug in Racket somewhere? Can
>> anyone suggest a work-around?
>>
>> Thanks in advance!
>>
>> /David
>>
>> -- 
>> 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.
>> For more options, visit https://groups.google.com/d/optout.
> 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Letter spacing in slideshow

2015-12-17 Thread David Christiansen
On 17/12/15 17:52, Matthew Flatt wrote:
> The problem appears to be fixed in Pango 1.37:
> 
>   https://bugzilla.gnome.org/show_bug.cgi?id=700592
> 
> Is upgrading your Pango installation a possibility?

That would be a pretty major disturbance for my machine - I'm a bit
hesitant to change distros right now, as the talk I'm preparing is
intended as a PhD defense!

> Otherwise, `racket/draw` could can probably work around this problem,
> much the same as
> 
>   https://mail.gnome.org/archives/commits-list/2014-May/msg06383.html
> 
> but it would be a little complicated, since scaling can come from
> different layers.

What about working around it by making slideshow's instances of
racket/gui think that I'm not on a high-res display, so that it uses 1.0
as the backing scale? I've tried setting GDK_SCALE=1 and
GDK_DPI_SCALE=1, but I still see the issue.

Is there some other setting, or command line option, or even some
variable that I can set! to change the backing scale?

Thanks for the help!

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Letter spacing in slideshow

2015-12-17 Thread David Christiansen
> It might work to drop a repaired "libpangocairo.so" into the "lib"
> directory of your Racket installation. I'll see if I can build one,
> just to see how hard that is. :)

I made the problem go away by building libpango from source and putting
the just-built libpango, libpangocairo, libpangoxft, and libpangoft
libraries into LD_PRELOAD. I can definitely make a shell script that
does this before launching slideshow as a temporary workaround.

Building libpango from scratch was really easy - download, extract,
./configure, make.

This looks like it will work! Thanks!

>> What about working around it by making slideshow's instances of
>> racket/gui think that I'm not on a high-res display, so that it uses 1.0
>> as the backing scale? I've tried setting GDK_SCALE=1 and
>> GDK_DPI_SCALE=1, but I still see the issue.
> 
> You could set PLT_DISPLAY_BACKING_SCALE=1, but I think that won't help,
> because Slideshow will still scale the content to match the screen size
> (so it should arrive at the same overall scale factor).

This doesn't fix it, unfortunately, as you predicted.

> Can you set your laptop's screen to 1024x768 resolution? Then there
> would be no scaling. It seems like that might happen anyway when
> connecting to a projector, but I don't know well enough how changing
> the display works with Unix/X.

Setting it to 1024x768 fixes the text display, consistent with
expectations. I'm not confident that I can run our projectors at
precisely that resolution, however, so I don't want to rely on that
specifically! But I think the LD_PRELOAD hack is good enough for what I
need it to do, and I'll test extensively beforehand for stability.

> In another direction, you could disable kerning by adjusting your font
> description to include 'no-combine:
> 
>  (parameterize ([current-main-font (cons 'no-combine (current-main-font))])
>(slide
> (para "Types")))

That makes it ugly, but not quite as ugly as the over-the-top kerning.
I'll keep it in mind in case the LD_PRELOADed libpango causes some other
issue, as a potential last-minute fix if I've invested all my prep time
into an interactive Racket-Idris-slideshow thing that I don't have time
to replace at the last minute, and my other machine running stretch
doesn't work for some reason.

Thanks so much for fast and effective support turn-around! I really
appreciate it, and the sinking feeling in my gut has left.

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Letter spacing in slideshow

2015-12-17 Thread David Christiansen

> Assuming that you're on 64-bit Linux, here is a set of libraries to
> try:
> 
>   http://www.cs.utah.edu/~mflatt/tmp/pango-1-37-libs.tgz
> 
> Unpack in some directory , and run
> 
>  env LD_LIBRARY_PATH= racket 
> 
> To avoid setting `LD_LIBRARY_PATH`, you could probably adjust rpaths in
> the ".so" files an install into Racket's library search path, but I
> didn't try that.

I can confirm that this works just as well as my own build of
libpango-1.38, including that LD_LIBRARY_PATH works instead of
LD_PRELOAD, as one would expect.

Thanks again!

/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] racket/gui: Implementing new snips with multiple items

2015-12-09 Thread David Christiansen
I'll give it a shot with this approach then. Thanks!

/David

On 09/12/15 21:21, Robby Findler wrote:
> You'd need to wire up your table with the after-insert and
> after-delete methods, invalidating the appropriate parts. The behavior
> you seem to want below is simple calls into the data/enumerate library
> and more interesting invalidation is possible if you wish it.
> 
> And you want to look at text%, not editor<%>. Some of the mixins in
> the framework may also be interesting to you.
> 
> You can do all the same fancyness if you have the data structure
> parallel to the snip%s, of course. And it means you don't have to deal
> with saving the information in files, which what snips are designed
> for.
> 
> Robby
> 
> 
> On Wed, Dec 9, 2015 at 2:18 PM, David Christiansen
> <da...@davidchristiansen.dk> wrote:
>> Thanks for a fast answer, and for the recommendation!
>>
>> Right, it's all from the compiler. When the user opens a file, it is
>> normal text; type checking turns it into an angry fruit salad of
>> semantic information.
>>
>> Is there a way to automatically keep these things updated as the user
>> edits the text? Ideally, if I edit the text "Nat", its semantic
>> highlight should disappear, but all of the others should remain valid
>> until the user type-checks the buffer again or edits them. In Emacs, I
>> implement this kind of thing with overlays and markers, which stay
>> synchronized with buffer positions as text is edited, but I don't see
>> any way to mark a position in an `editor%' such that it moves according
>> to insertions. Type checking an Idris module is fairly heavy, so I don't
>> want to do it without the user asking for it, but the display should
>> still look as nice as possible underway. This is why I was turning to a
>> custom snip. A custom snip also seems to let the display be a bit more
>> fancy, e.g. lighting up when the mouse goes over a semantic tag.
>>
>> Thanks!
>>
>> /David
>>
>> On 09/12/15 21:08, Robby Findler wrote:
>>> My experience with this kind of thing suggests that keeping separate
>>> tables on the side that map ranges in the editor to whatever
>>> information you want is simpler and better. (Eg, check syntax.) Check
>>> out data/interval-map.
>>>
>>> You don't want to save this information when the user saves, right?
>>> That is, the user doesn't edit the file to insert this information;
>>> it's all generated by the compiler, right?
>>>
>>> Robby
>>>
>>> On Wed, Dec 9, 2015 at 1:59 PM, David Christiansen
>>> <da...@davidchristiansen.dk> wrote:
>>>> Hi all,
>>>>
>>>> Summary:
>>>>
>>>> Do I need to do anything over and above defining `get-count' and
>>>> `partial-offset' in a custom snip that has multiple items in order to
>>>> have it work properly in an editor derived from `text%'?
>>>>
>>>> Details:
>>>>
>>>> I'm in the process of making a library to interface Racket with the
>>>> Idris compiler, so that I can use the Racket slideshow language to make
>>>> nifty interactive presentations that feature live Idris demos. As a part
>>>> of doing this, I'm developing editors for Idris code and Idris REPLs.
>>>>
>>>> This library uses Idris's machine-readable REPL syntax, just like the
>>>> Emacs and Atom modes. This will sometimes send strings to be shown to
>>>> the user along with a list of offset-length-metadata triples that give
>>>> additional information about the contents of the string (for example,
>>>> that a certain three-character region refers to the qualified name
>>>> "Prelude.Nat" with type "Type" and documentation summary "Unary natural
>>>> numbers", and that the referent of this name is itself a type).
>>>>
>>>> What I want to do is to highlight some of these substrings by replacing
>>>> them with a custom snip class that has a particular display, along with
>>>> easy access to things like additional commands from the Idris compiler.
>>>> Basically, they'll get a fancy UI, but most of the fanciness will be not
>>>> immediately visible. When a user modifies the items (= characters) in
>>>> the snip, it should revert back to an ordinary `string-snip%'.
>>>>
>>>> My problem is that, once I've replaced a portion of an editor with my
>>>> custom snip class, the inserted snip is only considered

Re: [racket-users] racket/gui: Implementing new snips with multiple items

2015-12-09 Thread David Christiansen
Thanks for a fast answer, and for the recommendation!

Right, it's all from the compiler. When the user opens a file, it is
normal text; type checking turns it into an angry fruit salad of
semantic information.

Is there a way to automatically keep these things updated as the user
edits the text? Ideally, if I edit the text "Nat", its semantic
highlight should disappear, but all of the others should remain valid
until the user type-checks the buffer again or edits them. In Emacs, I
implement this kind of thing with overlays and markers, which stay
synchronized with buffer positions as text is edited, but I don't see
any way to mark a position in an `editor%' such that it moves according
to insertions. Type checking an Idris module is fairly heavy, so I don't
want to do it without the user asking for it, but the display should
still look as nice as possible underway. This is why I was turning to a
custom snip. A custom snip also seems to let the display be a bit more
fancy, e.g. lighting up when the mouse goes over a semantic tag.

Thanks!

/David

On 09/12/15 21:08, Robby Findler wrote:
> My experience with this kind of thing suggests that keeping separate
> tables on the side that map ranges in the editor to whatever
> information you want is simpler and better. (Eg, check syntax.) Check
> out data/interval-map.
> 
> You don't want to save this information when the user saves, right?
> That is, the user doesn't edit the file to insert this information;
> it's all generated by the compiler, right?
> 
> Robby
> 
> On Wed, Dec 9, 2015 at 1:59 PM, David Christiansen
> <da...@davidchristiansen.dk> wrote:
>> Hi all,
>>
>> Summary:
>>
>> Do I need to do anything over and above defining `get-count' and
>> `partial-offset' in a custom snip that has multiple items in order to
>> have it work properly in an editor derived from `text%'?
>>
>> Details:
>>
>> I'm in the process of making a library to interface Racket with the
>> Idris compiler, so that I can use the Racket slideshow language to make
>> nifty interactive presentations that feature live Idris demos. As a part
>> of doing this, I'm developing editors for Idris code and Idris REPLs.
>>
>> This library uses Idris's machine-readable REPL syntax, just like the
>> Emacs and Atom modes. This will sometimes send strings to be shown to
>> the user along with a list of offset-length-metadata triples that give
>> additional information about the contents of the string (for example,
>> that a certain three-character region refers to the qualified name
>> "Prelude.Nat" with type "Type" and documentation summary "Unary natural
>> numbers", and that the referent of this name is itself a type).
>>
>> What I want to do is to highlight some of these substrings by replacing
>> them with a custom snip class that has a particular display, along with
>> easy access to things like additional commands from the Idris compiler.
>> Basically, they'll get a fancy UI, but most of the fanciness will be not
>> immediately visible. When a user modifies the items (= characters) in
>> the snip, it should revert back to an ordinary `string-snip%'.
>>
>> My problem is that, once I've replaced a portion of an editor with my
>> custom snip class, the inserted snip is only considered to be one item
>> long for purposes of calculating positions later in the editor. I've
>> overridden get-count and partial-offset according to the instructions,
>> and I believe that they are correct. Because this snip class simply has
>> a field that is the string being highlighted, it has a field
>> `display-name' that is the string to show. My `get-count' simply returns
>> the length of this string, and I believe that `partial-offset' is
>> correct because moving the caret over the new snip precisely highlights
>> the width of the first character in blue.
>>
>> Do I need to do anything more to register this snip as containing
>> multiple items, and to have its count taken into consideration when
>> calculating positions and moving the caret?
>>
>> Thanks in advance!
>> /David
>>
>> --
>> 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.
>> For more options, visit https://groups.google.com/d/optout.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] racket/gui: Implementing new snips with multiple items

2015-12-09 Thread David Christiansen
Hi all,

Summary:

Do I need to do anything over and above defining `get-count' and
`partial-offset' in a custom snip that has multiple items in order to
have it work properly in an editor derived from `text%'?

Details:

I'm in the process of making a library to interface Racket with the
Idris compiler, so that I can use the Racket slideshow language to make
nifty interactive presentations that feature live Idris demos. As a part
of doing this, I'm developing editors for Idris code and Idris REPLs.

This library uses Idris's machine-readable REPL syntax, just like the
Emacs and Atom modes. This will sometimes send strings to be shown to
the user along with a list of offset-length-metadata triples that give
additional information about the contents of the string (for example,
that a certain three-character region refers to the qualified name
"Prelude.Nat" with type "Type" and documentation summary "Unary natural
numbers", and that the referent of this name is itself a type).

What I want to do is to highlight some of these substrings by replacing
them with a custom snip class that has a particular display, along with
easy access to things like additional commands from the Idris compiler.
Basically, they'll get a fancy UI, but most of the fanciness will be not
immediately visible. When a user modifies the items (= characters) in
the snip, it should revert back to an ordinary `string-snip%'.

My problem is that, once I've replaced a portion of an editor with my
custom snip class, the inserted snip is only considered to be one item
long for purposes of calculating positions later in the editor. I've
overridden get-count and partial-offset according to the instructions,
and I believe that they are correct. Because this snip class simply has
a field that is the string being highlighted, it has a field
`display-name' that is the string to show. My `get-count' simply returns
the length of this string, and I believe that `partial-offset' is
correct because moving the caret over the new snip precisely highlights
the width of the first character in blue.

Do I need to do anything more to register this snip as containing
multiple items, and to have its count taken into consideration when
calculating positions and moving the caret?

Thanks in advance!
/David

-- 
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.
For more options, visit https://groups.google.com/d/optout.