From fungsin.lui at gmail.com Fri Oct 20 05:50:07 2006 From: fungsin.lui at gmail.com (Lui Fungsin) Date: Thu, 19 Oct 2006 22:50:07 -0700 Subject: [linedit-devel] Re: Exception when using linedit:linedit on lispworks 5.0 (linux 2.6) In-Reply-To: <3990b5930608181733v4289f229tcc8dd510ebd46e97@mail.gmail.com> References: <3990b5930608181724wc8ee1c6rc8d23d83788bd7e2@mail.gmail.com> <3990b5930608181733v4289f229tcc8dd510ebd46e97@mail.gmail.com> Message-ID: <3990b5930610192250g5ea74983g1bac0d5204885155@mail.gmail.com> So I spent some time reading the lispworks manual, the uffi manual and the linedit source to debug a little. It turns out that the :module keyword arg is required for lw and that it needs to be unique for different "so" object files. BTW, the CLOS hack on the asd file to compile the c file and loading the foreign library is very neat and clever! Here's a patch, in case anyone wants to use linedit with lispworks. Next up, I need to find out why linedit defaults to dumb mode with lw while I can use smart mode with sbcl. If you guys have any hints I'd greatly appreciated. (I'm running lw pro 5.0 32bit on ubuntu) Thanks! CL-USER 2 > (linedit:linedit :prompt ">>>") Linedit version 0.15.12 [dumb mode] >>>23 "23" Index: terminal.lisp =================================================================== --- terminal.lisp (revision 904) +++ terminal.lisp (working copy) @@ -27,21 +27,24 @@ (uffi:def-function ("linedit_terminal_columns" c-terminal-columns) ((default :int)) - :returning :int) + :returning :int + :module "terminal_glue") (defmethod backend-columns ((backend terminal)) (c-terminal-columns *default-columns*)) (uffi:def-function ("linedit_terminal_lines" c-terminal-lines) ((default :int)) - :returning :int) + :returning :int + :module "terminal_glue") (defmethod backend-lines ((backend terminal)) (c-terminal-lines *default-lines*)) (uffi:def-function ("linedit_terminal_init" c-terminal-init) () - :returning :int) + :returning :int + :module "terminal_glue") (defmethod backend-init ((backend terminal)) (invariant (not (backend-ready-p backend))) @@ -50,7 +53,8 @@ (uffi:def-function ("linedit_terminal_close" c-terminal-close) () - :returning :int) + :returning :int + :module "terminal_glue") (defmethod backend-close ((backend terminal)) (invariant (backend-ready-p backend)) Index: editor.lisp =================================================================== --- editor.lisp (revision 904) +++ editor.lisp (working copy) @@ -127,14 +127,16 @@ (uffi:def-function ("linedit_interrupt" c-interrupt) () - :returning :void) + :returning :void + :module "signals") (defun editor-interrupt (editor) (without-backend editor (c-interrupt))) (uffi:def-function ("linedit_stop" c-stop) () - :returning :void) + :returning :void + :module "signals") (defun editor-stop (editor) (without-backend editor (c-stop))) Index: linedit.asd =================================================================== --- linedit.asd (revision 904) +++ linedit.asd (working copy) @@ -43,7 +43,7 @@ (defmethod perform ((o load-op) (c uffi-c-source-file)) (let ((loader (intern "LOAD-FOREIGN-LIBRARY" :uffi))) (dolist (f (asdf::input-files o c)) - (funcall loader f)))) + (funcall loader f :module (pathname-name f))))) (defmethod perform ((o compile-op) (c uffi-c-source-file)) (unless (zerop (run-shell-command "~A ~A ~{~A ~}-o ~A" From fungsin.lui at gmail.com Fri Oct 20 07:18:24 2006 From: fungsin.lui at gmail.com (Lui Fungsin) Date: Fri, 20 Oct 2006 00:18:24 -0700 Subject: [linedit-devel] Re: Exception when using linedit:linedit on lispworks 5.0 (linux 2.6) In-Reply-To: <3990b5930608181724wc8ee1c6rc8d23d83788bd7e2@mail.gmail.com> References: <3990b5930608181724wc8ee1c6rc8d23d83788bd7e2@mail.gmail.com> Message-ID: <3990b5930610200018k40f3c3a3rd6be65010b8b8d45@mail.gmail.com> It turns out that terminfo.lisp needs a lispworks patch to read the env var TERM. Also, after some trial and error I located that the problem with smart terminal w/ lispworks is in the smart-terminal display method. CLHS states that The effect of changing the value of *terminal-io*, either by binding or assignment, is implementation-defined. http://www.lispworks.com/documentation/HyperSpec/Body/v_termin.htm I'm not sure what is the reason for rebinding *terminal-io* to *standard-output*. Might be a SBCL specific thing but lispworks apparently get confused by this. Commenting out this for lw and everything seems to work fine. BTW thanks for this nice little library. I learned quite a bit going through the source. Index: terminfo.lisp =================================================================== --- terminfo.lisp (revision 904) +++ terminfo.lisp (working copy) @@ -977,6 +977,8 @@ (sys:getenv "TERM") #+SBCL (sb-ext:posix-getenv "TERM") + #+lispworks + (lispworks:environment-variable "TERM") #| if all else fails |# "dumb")))) Index: smart-terminal.lisp =================================================================== --- smart-terminal.lisp (revision 904) +++ smart-terminal.lisp (working copy) @@ -73,7 +73,7 @@ (ti:tputs ti:column-address col)) (defmethod display ((backend smart-terminal) &key prompt line point markup) - (let* ((*terminal-io* *standard-output*) + (let* (#-lispworks (*terminal-io* *standard-output*) (columns (backend-columns backend)) (old-markup (old-markup backend)) (old-point (old-point backend)) From nikodemus at random-state.net Fri Oct 20 07:31:52 2006 From: nikodemus at random-state.net (Nikodemus Siivola) Date: Fri, 20 Oct 2006 10:31:52 +0300 Subject: [linedit-devel] Re: Exception when using linedit:linedit on lispworks 5.0 (linux 2.6) In-Reply-To: <3990b5930610200018k40f3c3a3rd6be65010b8b8d45@mail.gmail.com> (Lui Fungsin's message of "Fri, 20 Oct 2006 00:18:24 -0700") References: <3990b5930608181724wc8ee1c6rc8d23d83788bd7e2@mail.gmail.com> <3990b5930610200018k40f3c3a3rd6be65010b8b8d45@mail.gmail.com> Message-ID: <87ejt3l9xz.fsf@logxor.random-state.net> "Lui Fungsin" writes: > I'm not sure what is the reason for rebinding *terminal-io* to > *standard-output*. Might be a SBCL specific thing but lispworks > apparently get confused by this. Yes, it is an SBCL/CMUCL specific kludge for the way they user *terminal-io*. > Commenting out this for lw and everything seems to work fine. > > BTW thanks for this nice little library. I learned quite a bit going > through the source. Thanks! Sorry for being so unresponsive so far, but things have been really busy. I'll try to get the patches committed soonish. Cheers, -- Nikodemus Schemer: "Buddha is small, clean, and serious." Lispnik: "Buddha is big, has hairy armpits, and laughs." From fungsin.lui at gmail.com Thu Oct 26 00:45:04 2006 From: fungsin.lui at gmail.com (Lui Fungsin) Date: Wed, 25 Oct 2006 17:45:04 -0700 Subject: [linedit-devel] Patch for div by zero error Message-ID: <3990b5930610251745p6ceaaf9by5e6e2a3edb4ac5c6@mail.gmail.com> For some reason, if I drive the terminal with a expect script, backend-columns will return 0 and cause a div by zero error. Attached is a patch to fix this problem. --fungsin -------------- next part -------------- A non-text attachment was scrubbed... Name: terminal.lisp.diff Type: application/octet-stream Size: 490 bytes Desc: not available URL: