all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* help needed writing a mode for axiom
@ 2007-05-25 21:50 Martin Rubey
  2007-05-25 22:18 ` Martin Rubey
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Rubey @ 2007-05-25 21:50 UTC (permalink / raw)
  To: help-gnu-emacs

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. )

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-06-02  3:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-25 21:50 help needed writing a mode for axiom Martin Rubey
2007-05-25 22:18 ` Martin Rubey
2007-05-25 22:35   ` Martin Rubey
2007-06-02  3:46     ` Kevin Rodgers

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.