all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Martin Rubey <axiomize@yahoo.de>
To: help-gnu-emacs@gnu.org
Subject: help needed writing a mode for axiom
Date: 25 May 2007 23:50:32 +0200	[thread overview]
Message-ID: <9qd50oindj.fsf@aquin.mat.univie.ac.at> (raw)

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	other threads:[~2007-05-25 21:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-25 21:50 Martin Rubey [this message]
2007-05-25 22:18 ` help needed writing a mode for axiom Martin Rubey
2007-05-25 22:35   ` Martin Rubey
2007-06-02  3:46     ` Kevin Rodgers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9qd50oindj.fsf@aquin.mat.univie.ac.at \
    --to=axiomize@yahoo.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.