[Openmcl-devel] GraphSketcher Anyone? (or: can I write to the clipboard)
Steven Núñez
steven.nunez at inference.sg
Wed Dec 31 16:07:10 PST 2014
Hi Ron,
Just a quick note for the benefit of anyone that's trying to do this in future: the problem appears to be with ASDF. If the require and objc code is in the same file, ccl will load it just fine, however if ASDF needs to compile it, then reader errors are thrown.
The work-around is to put the require in a separate file and then have the file with the objc code in :depends-on the require file. I don't know why this work or if it's just masking some fundamental error on my part, but it works for me.
Regards,
- SteveN
From: Openmcl-devel [mailto:openmcl-devel-bounces at clozure.com] On Behalf Of Ron Garret
Sent: Thursday, 25 December 2014 9:24
To: Steven Núñez
Cc: openmcl-devel at clozure.com
Subject: Re: [Openmcl-devel] GraphSketcher Anyone? (or: can I write to the clipboard)
I have no idea why loading the code from QL would cause problems. But if you're running this code form the command line rather than the IDE then you might want to try (require :objc-support) instead of (require :cocoa). The latter does all kinds of funky things that you don't really need.
If you continue to have problems I suggest creating a file that contains nothing but the REQUIRE and the DEFUN WRITE-TO-CLIPBOARD forms and see if you can get QL to successfully load that. I can't imagine anything that QL could possibly do that would cause that to fail, but I don't really know much about what it does behind the scenes.
Merry Lispmas!
On Dec 25, 2014, at 9:01 AM, Steven Núñez <sales at illation.com<mailto:sales at illation.com>> wrote:
Hi Ron,
Thanks. That code works well and shaves a good bit of awkwardness off the workflow. I¹ve got one problem however: loading the file containing the code via quicklisp, e.g. (ql:quickload "foo") errors out in the reader when parsing that code. The problem appears to be related to (require "cocoa") not being evaluated before the write-to-clipboard function is. It works fine in slime/emacs when evaluating things individually (perhaps it is a timing issue?)
Two questions:
1. What is best practice when using (require "cocoa") and a project to be loaded from quicklisp?
2. Do I need to bring in all the Objective-C bridge just to use the clipboard? I.e. Is there a lighter-weight way to access pasteboard?
Happy Christmas,
- Steve
From: Ron Garret <ron at flownet.com<mailto:ron at flownet.com>>
Date: Monday, 22 December 2014 11:22
To: Steven Núñez <sales at illation.com<mailto:sales at illation.com>>
Cc: "openmcl-devel at clozure.com<mailto:openmcl-devel at clozure.com>" <openmcl-devel at clozure.com<mailto:openmcl-devel at clozure.com>>
Subject: Re: [Openmcl-devel] GraphSketcher Anyone? (or: can I write to the clipboard)
Turns out objc:make-nsstring is a built-in function now, so you can just do this:
(defun write-to-clipboard (string)
(let ((pb (#/generalPasteboard ns:ns-pasteboard)))
(#/clearContents pb)
(objc:with-autorelease-pool
(#/writeObjects: pb (#/initWithObject:
(#/alloc ns:ns-array)
(objc:make-nsstring string))))))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20150101/2155739e/attachment.htm>
More information about the Openmcl-devel
mailing list