From: Martin Rubey <axiomize@yahoo.de>
To: help-gnu-emacs@gnu.org
Cc: axiom-devel <axiom-developer@nongnu.org>
Subject: Re: axiom mode
Date: 10 Jun 2007 08:41:48 +0200 [thread overview]
Message-ID: <9qps44wbtf.fsf__23537.3290641748$1181461244$gmane$org@aquin.mat.univie.ac.at> (raw)
In-Reply-To: mailman.1841.1181428556.32220.help-gnu-emacs@gnu.org
Dear Tom,
Tom Tromey <tromey@redhat.com> writes:
> >>>>> "Martin" == Martin Rubey <axiomize@yahoo.de> 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
Martin
(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"
(interactive)
(if (and (processp axiom-process)
(eq (process-status axiom-process) 'run))
(switch-to-buffer (axiom-buffer))
(axiom-mode-new-axiom-process))
(axiom-mode))
;; 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)
(delete-process axiom-process)
(kill-buffer (axiom-buffer))
(setq axiom-process nil))
(setq axiom-end-of-input 0)
;; First, let's get axiom up and running.
(axiom-run)
;; 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.
(axiom-clean-up-prompt)
;; We need to explicitly write protect the first prompt, since it
;; is outside the normal write protect mode used for subsequent
;; output:
(axiom-make-prompt (- (point) 7) (point))
;; Next, we turn on some key bindings for our new mode:
(use-local-map axiom-mode-map)
(substitute-key-definition 'comint-previous-input
'axiom-scroll-previous-input axiom-mode-map)
(substitute-key-definition 'comint-next-input
'axiom-scroll-next-input axiom-mode-map)
;; 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")
(axiom-eval)))
(defun axiom-run ()
"Run Axiom in a buffer."
;; Get the command to use
(axiom-get-command)
;; Run that command and switch to the new buffer
(axiom-comint-run)
;; 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))
(accept-process-output axiom-process)))
(when (equal axiom-command "AXIOMsys")
(while (not (re-search-backward "(1) -> " nil t))
(accept-process-output axiom-process)))
;; 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))
next prev parent reply other threads:[~2007-06-10 6:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-09 18:29 axiom mode Martin Rubey
2007-06-09 21:50 ` Tom Tromey
[not found] ` <mailman.1841.1181428556.32220.help-gnu-emacs@gnu.org>
2007-06-10 6:41 ` Martin Rubey [this message]
[not found] <9qd505x9pf.fsf@aquin.mat.univie.ac.at>
2007-06-09 21:10 ` Martin Rubey
-- strict thread matches above, loose matches on Subject: below --
2007-06-10 12:11 martin rudalics
[not found] <mailman.1862.1181477508.32220.help-gnu-emacs@gnu.org>
2007-06-10 14:24 ` Martin Rubey
2007-06-11 8:39 martin rudalics
2007-06-11 12:45 ` martin rudalics
[not found] <mailman.1911.1181551178.32220.help-gnu-emacs@gnu.org>
2007-06-11 9:11 ` Martin Rubey
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='9qps44wbtf.fsf__23537.3290641748$1181461244$gmane$org@aquin.mat.univie.ac.at' \
--to=axiomize@yahoo.de \
--cc=axiom-developer@nongnu.org \
--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.