help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

help needed writing a mode for axiom


From: Martin Rubey
Subject: help needed writing a mode for axiom
Date: 25 May 2007 23:50:32 +0200

Dear all,

I'm stuck.  I tried to write an emacs mode for the computer algebra system
axiom, based on comint mode.  One feature that was generally requested was to
write-protect all output, and colorize it.  So, what I thought was to use

  (add-hook 'comint-output-filter-functions 'axiom-output-filter))

and set text-properties as text is sent by the process:

(defvar axiom-prompt "^(\\([0-9]+\\)) -> ")
(defface axiom-output '((t (:background "green")))
  "Face used for output."
  :group 'axiom)

(defun axiom-make-output (begin end)
  (let ((inhibit-read-only t))
    (put-text-property begin (1- end) 'face 'axiom-output)
;    (put-text-property begin (1- end) 'front-sticky t)  
;    (put-text-property (1+ begin) end 'rear-non-sticky t)  
    (put-text-property begin (1- end) 'read-only t)))

(defvar axiom-last-output-end 0)
(defun axiom-output-filter (str)
  (when (zerop axiom-last-output-end)
    (setq axiom-last-output-end comint-last-input-end))
  
  (axiom-make-output axiom-last-output-end 
                     (setq axiom-last-output-end 
                           (+ axiom-last-output-end
                              (length str))))
  
  (when (string-match axiom-prompt str) 
    (setq axiom-last-output-end 0
          axiom-waiting-for-output nil)))

However, as written here, it does not work.  After axiom (or in fact, a shell)
sends the first line of output, it complains that the text is read only.  As
you can see I played around with the rear-non-sticky property, but without
success.  Since at times it is not clear whether more output is still going to
arrive or not, I'd really love to set text-properties as output comes in.  But
I seem to be missing something.

In a different version, I was unable to use C-c C-c to interrupt the process.
But I find it hard to nail down the cause.

By the way, why is axiom-output-filter such a pain to debug? if I "instrument"
it for edebug, it get's the last strings sent to the buffer first!?

(in emacs 21.4.1, on kubuntu, that is.)

Many many thanks,

Martin

(34, using emacs since 2000, I think. )


reply via email to

[Prev in Thread] Current Thread [Next in Thread]