[racket-users] Re: Complete Word (Ctrl+/)

2018-11-05 Thread Glenn Hoetker
I'm afraid I don't have a suggestion, but a question.  The code you 
provided makes sense to me and duplicates something I'd like, but I'm 
unsure how to enable it in DrRacket. May I ask how you did so?  Thank you. 
 Glen

On Wednesday, September 12, 2018 at 6:11:12 PM UTC+10, Gregor Kopp wrote:
>
> Hi!
> I like DrRacket very much, because it's hassle-free.
> I like fast startup times, that's why I disabled all tools in the 
> preferences, because at the moment I don't use them.
> Further more, it's easier for me to map "Complete Word" to the tabulator 
> key. I do not use the emacs keybindings.
> I have in the preferences, tab "Editing", subtab "General Editing" "Enable 
> keybindings in menus" checked. It's more convenient for me.
>
> For that purpose I did a custom keybinding which I successfully enabled in 
> DrRacket:
>
> #lang s-exp framework/keybinding-lang
> (keybinding "TAB" (λ (editor event) (send editor auto-complete)))
> (keybinding "c:l" (λ (editor event) (send editor insert "λ")))
>
> That all works very well, DrRacket starts very fast, and editing is also 
> fast enough. The λ is also very helpful for me because I don't have an 
> english keyboard.
> There is only one thing I would like to change:
>
> If I invoke the auto-complete method, the first time I'm using it it takes 
> some time (2-3 seconds maybe?) until the complete suggestions are 
> appearing. After the first time using it its fast enough.
> I think it's loading on demand.
>
> Finally my question: Is there any way to tell DrRacket to load that 
> required data on startup?
>
> I know, why bother about it, but 2 seconds are 2 seconds.
>
> Thank you for your suggestions.
>

-- 
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] Naive question on how to capitalize only the first word of a string

2017-06-19 Thread Glenn Hoetker
I'm quite new to Racket/LISP, so I hope this isn't breathtakingly obvious.  Can 
someone please tell me the best way to capitalize just the first word in a 
multiword string.  So, given the string "it was a dark and stormy night", I 
would like to get "It was a dark and stormy night". I see functions for turning 
everything lower case, everything uppercase or capitalizing each word, but 
nothing in line with what I hope to do.

> (define it "cat dog")
> (string-titlecase it)
"Dog Cat"  ; So close, but not quite "Dog cat" as I want.

Many thanks.


-- 
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] Naive question on how to capitalize only the first word of a string

2017-06-19 Thread Glenn Hoetker
Wow. In addition to getting my question answered, I learned about 6 other 
things.  Thank you so much, everyone!

Glenn

-- 
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] Code critique (of naive code) would be very appreciated

2017-06-21 Thread Glenn Hoetker
With help from this group, I've written my first baby-program in Racket and 
would really appreciate any feedback on how to make it more idiomatic, 
efficient and well-formatted (I struggle with where to break lines). Thank you 
in advance.

The purpose is to fix the irregular capitalization of entries in the "Keywords" 
field of a large BibLaTeX (.bib) file. A sample entry in the input file might be

@article{Ender-2016-Review-00,
Author = {Ender, P. B.},
Keywords = {Book Review, Behaviorial sciences, ANALYSIS OF VARIANCE, 
experimental design},
...}

I want non-Keyword lines passed unchanged to the output file and each keyword 
entry (potentially multiword) changed to have only its first word capitalized. 
Thus

@article{Ender-2016-Review-00,
Author = {Ender, P. B.},
Keywords = {Book review, Behaviorial sciences, Analysis of variance, 
Experimental design},
...}


Here is what I came up with.

;;;
#lang racket

(define in (open-input-file "/Users/me/BibDeskPapers/oldBib.bib"))
(define out (open-output-file "/Users/me/BibDeskPapers/newBib.bib" #:exists 
'replace))
(define keyword-prefix "\tKeywords = {")

;; Return a string with only the first word capitalized and all else in lower 
case
;; Courtesy https://groups.google.com/forum/m/#!topic/racket-users/gw8Ivm5HSZQ
(provide 
 (contract-out 
  [string-upcase-first-word (-> string? string?)])) 

(define (string-upcase-first-word s) 
  (apply 
   string 
   (for/list ([c (in-string s)] 
  [i (in-naturals)]) 
 (if (= i 0) 
 (char-upcase c) 
 (char-downcase c)

(module+ test 
  (require rackunit) 
  (check-equal? (string-upcase-first-word "") "") 
  (check-equal? (string-upcase-first-word "Cat Dog") "Cat dog") 
  (check-equal? (string-upcase-first-word "cat dog") "Cat dog"))

;; Main program
(for ([aLine (in-lines in)])
  (cond
[(string-prefix? aLine "\tKeywords = {") ; Identify Keywords lines
 (define keywords-as-list (string-split (string-replace aLine "\tKeywords = 
{" "") ","))
 (define cleaned-keywords (map (lambda (aString)
 (string-upcase-first-word
  (string-trim aString)))
   keywords-as-list))
 (display keyword-prefix out)
 (display (string-join cleaned-keywords ", ") out)
 (display "," out)
 (newline out)]
[else (display aLine out) (newline out)]))

;;;

Thank you again.

-- 
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] Code critique (of naive code) would be very appreciated

2017-06-22 Thread Glenn Hoetker
Thank you, everyone!! I've gained some nice big picture lessons and appreciate 
the welcome to the community.

-- 
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] Built-in way to list all children of a directory?

2017-06-27 Thread Glenn Hoetker
Naive question, here.  As far as I can tell, (directory-list some-path) yields 
a list of files and directories immediately below some-path. I wish to capture 
all files and directories in some-path or any of the sub-directories of 
some-path.  I didn't find an obvious option for doing so. Before I write my 
own--probably inefficient--way of doing so, I wanted to ask if there was a 
built-in command that would yield all the children of a path.  Many thanks.

-- 
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] Built-in way to list all children of a directory?

2017-06-27 Thread Glenn Hoetker
Struggling as a newbie with the documentation for find-files. In particular, 
the "predicate" part of 

(find-files  
predicate
 [  start-path]  
#:skip-filtered-directory? skip-filtered-directory?  
#:follow-links? follow-links?)

Can anyone offer a working example?  All file, all pdfs. Doesn't really matter. 
Just something concrete to get me started. Many thanks!

-- 
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] Re: Searching diffrences in two lists

2017-06-28 Thread Glenn Hoetker
If order doesn't matter and it would be okay for duplicates *within* a list to 
be deleted, you might make use of

* Lists can be converted to sets, via list->set and back again
* There are many set methods to yield unions, intersections and differences 
between sets. See https://docs.racket-lang.org/reference/sets.html.

That should be a good start. Follow up if you get stuck.

-- 
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] Hint on opening enclosing directory of current file from DrRacket

2017-06-28 Thread Glenn Hoetker
I hope this isn't painfully obvious to everyone but me, but I'd found it really 
frustrating until I found a solution. So, I thought I'd share. (If that's not 
appropriate traffic for the mailing list, I'd appreciate a more veteran hand 
letting me know. I'm still observing the norms.)

Issue: While using DrRacket, I often want to open (in the Finder) the folder in 
which the current file is located. Many Mac applications allow one to do this 
with command-clicking the icon atop a window, but DrRacket doesn't. So, I need 
an alternative.

Solution: Issue the command

  (system "open .")

from the Interaction window (one could do it from the Definition window, 
although I'm not sure why one would).

Why it works (I think...): The documentation for "system" indicates that it 
operates in the current working directory unless otherwise directed. DrRacket 
sets, unless otherwise directed, the current working directory to the directory 
of the most recently run file. Since "." indicates the current directory, the 
command opens that directory.

Caveats: 1. Since CWD is set to the most recently run file, you have to have 
run the file whose enclosing directory you wish to open. The default appears to 
the home directory. 2. I know this works on MacOS. I can't see why it wouldn't 
work on Unix systems. Windows scares me, so I have idea if it would work there.

-- 
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] Hint on opening enclosing directory of current file from DrRacket

2017-06-28 Thread Glenn Hoetker
Thanks for the quick comment. Unless I'm missing something (quite 
possible...nay, likely), the triangle in the upper left launches a File Open 
dialog at the requested location. That's cool and useful, but a bit different. 
The use case I had in mind was wanting access to the folder *in the Finder* so 
I could drag the file onto an email to send, create a new non-Racket file like 
notes or belatedly put the project under git control.  Perhaps I'm just missing 
something about the menu you pointed out...

Many thanks!

-- 
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] Hint on opening enclosing directory of current file from DrRacket

2017-06-28 Thread Glenn Hoetker
No apology needed.  The pop-up menu is a great feature. Thank you very much.

-- 
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.