Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - cormullion

#2026
newLISP and the O.S. /
December 02, 2005, 01:22:01 PM
I wonder if I can post it here. Worth a try (if there's not a post limit). Save as "/Users/me/Library/Application Support/BBEdit/Language Modules/newlisp.plist". But this is my first attempt at such a beast, so please improve it!



Improved version at http://newlisp.org/index.cgi?Code_Contributions">http://newlisp.org/index.cgi?Code_Contributions
#2027
Since I prefer to use OSX-friendly editors such as BBEdit rather than emacs, I had a go at defining a LanguageModule for newLISP. It starting to work OK in both BBEdit and TextWrangler (the free version of BBEdit), so if you'd like a copy (or would like to make it better) let me know (message here or email to my .mac address).



Another good text editor is TextMate. There is already a generic LISP definition module for TextMate, but that would need some editing, I think.
#2028
newLISP and the O.S. / MacOS - resource forks
December 02, 2005, 04:20:51 AM
Sorry for yet another Mac post (in the Linux forum...), but I've discovered how to work with resource forks (weird Mac technology from the old days :-))... You can access resource forks using the "/rsrc" form, although the 'file?' function can't see them.



(set 'sysfontdir "/System/Library/Fonts/")

(set 'item "HelveLTMM")

(println (exec (format "ls -alt '%s%s/rsrc'" sysfontdir item )))

 ; -> ("-rw-r--r--   1 root  wheel  181804 Mar 28  2005 /System/Library/Fonts/HelveLTMM/rsrc")

(println (file? (format "'%s%s/rsrc'" sysfontdir item )))

 ; -> nil
#2029
I'd be interested in your opinions as to what you think are the main benefits of newLISP compared with some of the other mainstream scripting languages (Perl, Python, Ruby)... I can certainly see the benefits of newLISP over old LISP, and if you already know some form of LISP it's quick to pick up.



I don't think benchmarks are very illuminating, although I've seen elsewhere on this forum that newLISP is very competitive.
#2030
newLISP in the real world /
December 02, 2005, 12:15:47 AM
Neat. Thanks.
#2031
newLISP in the real world /
December 01, 2005, 11:15:42 AM
Thanks. I've also just had this inspiration:



(set 'f "/Applications/Address Book.app/")

(exec (string "ls -l " (format  "'%s'" f )))



- a way of putting single quotes round the string. If there's nothing better, that'll do nicely!
#2032
newLISP in the real world /
December 01, 2005, 11:04:05 AM
Hi folks. Thanks for the replies. But the problem is with files and directories that have spaces in their names. (Perhaps this is a MacOS X-only thing?) So this works:



"/Applications/Firefox.app/"



but this doesn't:



"/Applications/Address Book.app/"



Loads of files and directories have spaces in, and I was looking for a way to quote them for the (process ) or (exec) functions.
#2033
Just before my brain packs up for the day:



(set 'f "/Users/me/folder 1/file 1") ; yes, spaces in pathnames...  

(process  (append "ls -l " f )) ; doesn't work



I need to pass some kind of quoted form of f to the shell. What's the best way of doing that?



Sorry if the question is a bit too simple...!
#2034
Anything else we might add? /
December 01, 2005, 07:55:35 AM
Wow. What fantastic support for a newcomer!



thanks much
#2035
Anything else we might add? / Misc newbie queries
December 01, 2005, 04:41:34 AM
Hi.



Where should I post newLISP questions that are neither Windows or Linux or MacOS? The forums are a strange mixture of platform-specific and general newLISP and non-newLISP questions.



Can I get a UTF-8 version for MacOS X without having to build from source..?



Can I get an RSS feed for these forums (I found the News one...)?



Why does the logo on the BB have curly brackets ? just kidding now :-)



thanks!
#2036
newLISP and the O.S. /
November 30, 2005, 02:06:34 PM
Quote from: "Lutz"Here is a simple way to get output back from osascript:

> (exec {osascript -e 'tell app "Finder" to display dialog "hello world"'})
("button returned:OK")
>


Lutz


That's very nice - no quoting problems and AppleScript responses too!



Thanks. This is looking pretty good!
#2037
newLISP and the O.S. /
November 30, 2005, 07:13:35 AM
I've used the 'osascript' command to run AppleScripts before (eg from Ruby or Perl), but was wondering whether there was any more basic communication (eg an OSA interface that generates raw Apple Events).



I'll try (process) now:

--

#!/usr/bin/newlisp

(process "osascript -e 'tell app "Finder" to display dialog "hello world"'")

--



oh cool, it works! As ever, managing the quotes is the hard part... :-)



I've only just discovered newLISP so haven't even started the manual. :-) So much to learn... :-) The only two languages I know are Lisp (from the 1980s when I used Ultrix and Sun workstations) and AppleScript (from the 1990s when I went Mac) so combining the two is the next step.



I'm glad to have discovered newLisp - I haven't been enjoying my encounters with Common Lisp installations this week. newLISP looks like a great idea!
#2038
How can I send some AppleScript from newLISP?