* comint and point
@ 2007-10-01 6:43 Martin Rubey
2007-10-09 10:27 ` Johan Bockgård
0 siblings, 1 reply; 3+ messages in thread
From: Martin Rubey @ 2007-10-01 6:43 UTC (permalink / raw)
To: help-gnu-emacs
Dear all,
I'm still having a bad time with sending stuff to a proces, parsing the output
and deleting stuff and its output in comint mode. The thing that worries me
most: I have no idea what's going out and how things are intended to work.
The bigger picture is as follows: I'm writting a specialised mode derived from
comint for a computer algebra system called axiom. It does things like color
the output and make it read only, and enable tab-completion for file names if
the user is currently entering a system command, etc...
For the latter feature, I need to track the directory I'm in. So here's the
plan:
I can assume that we are just after an axiom prompt.
* delete the prompt
* send the axiom command ")sys pwd" to the axiom process, which will spit out
the directory name.
* move a line backwards and to the end of this line
* cd to the directory, which is given by the text in the current line
* delete the line
The following code works roughly, as long as I'm using emacs 21 on X. It
doesn't seem to work with emacs -nw.
But why do I need these (sit-for 0 100) and (sit-for 0) stuff? It took me
hours to figure out, and I came to this sequence of commands only by
experimentation. Could somebody PLEASE explain to me how to reliably position
point.
Many thanks in advance,
Martin
(defun axiom-resync-directory ()
"Send )sys pwd to the axiom process, parse the result, cd to it and clean up
output. Assumes that we are just after a prompt."
(let* ((inhibit-read-only t)
(begin (progn (forward-line 0) (point)))
(end (progn (end-of-line) (point)))
(dir))
(delete-region begin end)
(process-send-string (get-buffer-process (current-buffer)) ")sys pwd\n")
(sit-for 0 100)
(forward-line -1)
(end-of-line)
(sit-for 0)
(setq end (point))
(cd (buffer-substring-no-properties begin end))
(delete-region (1- begin) end)
(forward-line 1)
(end-of-line)))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: comint and point
2007-10-01 6:43 comint and point Martin Rubey
@ 2007-10-09 10:27 ` Johan Bockgård
2007-10-10 7:06 ` Martin Rubey
0 siblings, 1 reply; 3+ messages in thread
From: Johan Bockgård @ 2007-10-09 10:27 UTC (permalink / raw)
To: help-gnu-emacs
Martin Rubey <axiomize@yahoo.de> writes:
> I'm still having a bad time with sending stuff to a proces, parsing
> the output and deleting stuff and its output in comint mode.
Have you looked at `shell-resync-dirs' (or
`comint-redirect-results-list-from-process')?
--
Johan Bockgård
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: comint and point
2007-10-09 10:27 ` Johan Bockgård
@ 2007-10-10 7:06 ` Martin Rubey
0 siblings, 0 replies; 3+ messages in thread
From: Martin Rubey @ 2007-10-10 7:06 UTC (permalink / raw)
To: help-gnu-emacs
bojohan+news@dd.chalmers.se (Johan Bockgård) writes:
> Martin Rubey <axiomize@yahoo.de> writes:
>
> > I'm still having a bad time with sending stuff to a proces, parsing
> > the output and deleting stuff and its output in comint mode.
>
> Have you looked at `shell-resync-dirs' (or
> `comint-redirect-results-list-from-process')?
Oh, I didn't know about comint-redirect-*. That looks *very* useful! Many
many thanks!
Martin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-10-10 7:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-01 6:43 comint and point Martin Rubey
2007-10-09 10:27 ` Johan Bockgård
2007-10-10 7:06 ` Martin Rubey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).