Pymacs 0.2 for testing!

Carey Evans careye at spamcop.net
Mon Sep 10 06:06:04 EDT 2001


Great toy!

I've been playing with Pymacs under XEmacs 21.4 a bit, and I've come
up with a just a few problems so far.  Only the first seems to be an
XEmacs vs. Emacs issue:

Signaling: (error "Invalid time format")
  signal(error ("Invalid time format"))
  cerror("Invalid time format")
  apply(cerror "Invalid time format" nil)
  error("Invalid time format")
  run-at-time(t 20 pymacs-schedule-gc)
  (setq pymacs-weak-hash (make-hash-table :weakness (quote value)) pymacs-gc-timer (run-at-time t 20 (quote pymacs-schedule-gc)))
  (lambda nil (interactive) (let (...) (when ... ...) (setq pymacs-transit-buffer ...)) (with-current-buffer pymacs-transit-buffer (let ... ... ...)) (setq pymacs-weak-hash (make-hash-table :weakness ...) pymacs-gc-timer (run-at-time t 20 ...)))()
  call-interactively(pymacs-start-services)
  command-execute(pymacs-start-services t)
  execute-extended-command(nil)
  call-interactively(execute-extended-command)

It looks like XEmacs doesn't allow "t" as the first argument to
run-at-time, so I'm using the following patch at the moment.  I hope
it does the same:

--- pymacs.el.0.2	Mon Sep 10 05:20:51 2001
+++ pymacs.el	Mon Sep 10 19:13:42 2001
@@ -218,7 +218,7 @@
 	       (not (search-forward "<9\t(started)" nil t)))
 	(accept-process-output process))))
   (setq pymacs-weak-hash (make-hash-table :weakness 'value)
-	pymacs-gc-timer (run-at-time t 20 'pymacs-schedule-gc)))
+	pymacs-gc-timer (run-at-time 20 20 'pymacs-schedule-gc)))
 
 (defun pymacs-terminate-services ()
   ;; This function is provided for completeness.  It is not really needed.

Strangely enough, pymacs-eval only got an error the first time it was
called.  Shouldn't the whole process fail if pymacs-start-services
doesn't set everything up properly?

The second problem is an error from Python with:

    (pymacs-eval "()")

There's a simple patch for this, too:

--- pymacs.py.0.2	Mon Sep 10 04:40:06 2001
+++ pymacs.py	Mon Sep 10 21:08:27 2001
@@ -291,10 +291,11 @@
         if quoted:
             write("'")
         write('(')
-        print_lisp(value[0], write)
-        for sub_value in value[1:]:
-            write(' ')
-            print_lisp(sub_value, write)
+        if len(value) > 0:
+            print_lisp(value[0], write)
+            for sub_value in value[1:]:
+                write(' ')
+                print_lisp(sub_value, write)
         write(')')
     elif type(value) == types.ListType:
         write('[')

When Python crashed with an IndexError, the editor froze until I
pressed C-g.  Should Pymacs be checking for an end of file or similar
on the process buffer?

All in all, this is very impressive.  I'd looked at embedding Python
in XEmacs, or writing Python in Emacs Lisp a bit like like Jython (!),
but the much simpler scheme of using a separate process like this
never occurred to me.

(The reimplementation in Lisp still has some appeal to me, but I don't
think there's enough time in this life.)

-- 
	 Carey Evans  http://home.clear.net.nz/pages/c.evans/

	You think you know... what's to come... what you are.



More information about the Python-list mailing list