[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: axiom mode
Re: axiom mode
10 Jun 2007 08:41:48 +0200
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4
Tom Tromey <address@hidden> writes:
> >>>>> "Martin" == Martin Rubey <address@hidden> writes:
> I'm just guessing, based on what you wrote & a quick glance at the code, but
> I think you want to set local hooks.
> Martin> (add-hook 'comint-output-filter-functions 'axiom-output-filter)
> So here you would want:
> (add-hook 'comint-output-filter-functions 'axiom-output-filter nil t)
many thanks, that did the trick.
> I don't know the answers to your other questions, sorry.
well, there remain only two things I don't know how to do. Maybe there are
some more emacs gurus around:
* port to xemacs
* write clean initalisation code. In particular, it should be possible to have
several buffers with different axiom processes, just like in shell mode. I
looked at shell.el, but fail to understand it.
For those who don't want to dig through all the code, I copy the relevant
four routines below. (It's not me who wrote them, and I find them rather
difficult to follow.)
Again, many many thanks
(defun axiom-comint-run ()
"Run PROGRAM in a comint buffer with ARGS and switch to it."
(switch-to-buffer (make-comint "axiom" axiom-command nil axiom-args)))
(define-derived-mode axiom-mode comint-mode "AXIOM")
(defun axiom ()
"Run axiom in a terminal environment"
(if (and (processp axiom-process)
(eq (process-status axiom-process) 'run))
;; If there is a running axiom process switch to this axiom buffer
;; In the other case clean buffer and process variables and
;; start a new process in a new buffer.
(defun axiom-mode-new-axiom-process ()
(when (processp axiom-process)
(setq axiom-process nil))
(setq axiom-end-of-input 0)
;; First, let's get axiom up and running.
;; we make also the banner write-protected
;; note that because of the axiom-output-filter we might already have
;; write protected the banner.
(let ((inhibit-read-only t))
(remove-text-properties 1 (point) '(face nil rear-nonsticky nil))
(put-text-property 1 (point) 'front-sticky t)
(put-text-property 1 (point) 'read-only t)
;; We need to tell Emacs how to clean up if we close this
;; buffer - otherwise restarting is difficult:
(add-hook 'kill-buffer-hook 'axiom-cleanup)
;; Then we clean up the prompt.
;; We need to explicitly write protect the first prompt, since it
;; is outside the normal write protect mode used for subsequent
(axiom-make-prompt (- (point) 7) (point))
;; Next, we turn on some key bindings for our new mode:
;; HyperDoc currently sends loading messages to the buffer. Because of the
;; current setup, they are going to be read-only, and they are not followed
;; by a prompt. Thus, lest we cannot append any further input, we have to
;; mute them. Currently this is only possible via
;; )set messages autoload off
(insert ")se me au of")
(defun axiom-run ()
"Run Axiom in a buffer."
;; Get the command to use
;; Run that command and switch to the new buffer
;; and identify the process as well:
(setq axiom-process (get-buffer-process (current-buffer)))
;; We need a custom wait condition for the first case, since two input
;; prompts appear when "axiom" is used to as the startup command.
;; Note that the REGEXP used in re-search-backward
;; is not compatible with grep or other tools - it is specific to the
;; behavior of Emacs
(when (equal axiom-command "axiom")
(while (not (re-search-backward "(1) -> [^ ](1) ->" nil t))
(when (equal axiom-command "AXIOMsys")
(while (not (re-search-backward "(1) -> " nil t))
;; Tom Tromey: last argument being true means that the hook is buffer-local
(add-hook 'comint-output-filter-functions 'axiom-output-filter nil t)
(sit-for 0 axiom-after-output-wait))
- axiom mode, Martin Rubey, 2007/06/09
- Re: axiom mode, Tom Tromey, 2007/06/09
- Re: axiom mode,
Martin Rubey <=
- Re: axiom mode, martin rudalics, 2007/06/10
- Re: axiom mode, Martin Rubey, 2007/06/10
- Re: axiom mode, martin rudalics, 2007/06/11
- Re: axiom mode, Martin Rubey, 2007/06/11