axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-developer] A multi-line mode for Emacs.


From: Francois Maltey
Subject: Re: [Axiom-developer] A multi-line mode for Emacs.
Date: 24 Jun 2007 21:15:32 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

Dear Martin,

> > > [[M-x axiom]] should switch to the buffer [[*axiom*]], 
> > > if it exists and if it is an "axiom buffer".  

> > > If there is no such buffer, 
> > > it should create a new buffer and a new axiom process.
> > 
> > The axiom command in axiom.el file works so.
> 
> Not for me.

What do you get when you type ?

   [[M-x axiom]]         the first time.
   [[C-x b return]]      to switch to an other buffer
   [[M-x axiom]]         a second time

I switch to the first axiom buffer, as in shell mode.

Could you send me your axiom.el please ?
Do you have any line about axiom.el in your .emacs ?
In my .emacs I have only : 
  
(load "~/Configuration/emacs/axiom.el")

for this axiom.el file that I extract from june 16th. *.pamphlet file.

> > Do you want to run several axiom in several buffers ?

> Yes.  I'd like behaviour as with shell mode. 
All right, I test... 
But it seem today impossible to do this with axiom because
variables in axiom.el are global for all axiom-process, 
and it's necessary to create local variable for each axiom buffer.

> M-x axiom switches to *axiom* if present and 
> if it is a buffer in axiom-mode, otherwise it creates such a buffer.

Perhaps [[M-x axiom]] will be right if you delete this line from 
your .emacs...

> (add-hook 'axiom-mode-hook (lambda () (rename-uniquely)))

This hook'll works right after we transform global variables to local ones. 

> Yes, the above looks far too complicated for me.  I'd like the way
> shell mode works far better, i.e., only one command, which works
> "the emacs way", though.
All right...

I only look for an axiom-run mode, not for an axiom-input mode
with font lock and so...

> > If axiom-multi-lines is true :
> > [return] doesn't look at underscore _ at the end of the lines.
> 
> So, how do you determine end of input then?

The end of the buffer or 2 empty lines or a line with ---- or others.

1> Really, I think the best thing would be a mode axiom-input.el, 
1> This would also allow us to do some syntax highlighting and possibly
1> even some indentation features for input files.

2> which
2> allows sending the region to axiom, via saving it into a temporary
2> file and )read ing it in the axiom buffer.  

3> Another good feature would be tab completion, by the way.  This works if you
3> start axiom in a terminal, so it should be possible...

I keep theses three wishes in my memory.

My first want is an axiom interface in emacs, not really an axiom-input mode.
What do you know about emacs fontification and indentation.
I'm very dull about it...

The second one is very easy.

I keep the third one in my mind.
It seem possible to send the tab key to axiom and get the reponse.
(even if axiom is running)
This completion ignore the new variables of a session, 
I only get system keyword.

But it'll be more easy to generate the complete list only one time
and browse it in an emacs list. But how can I get this complete list ?

About axiom.el code :

> But with clean up I also meant: clean up, i.e., make it tidy.  
> Currently, the code is a mess, at least for me.

I began to play with this very small file.

F. 

---------------------------------------------------------------------
(require 'comint)
(setq comint-highlight-prompt nil)

(defvar axiom-mode-map nil "Keyboard for axiom mode.")
(define-derived-mode axiom-mode comint-mode "AXIOM")

(defvar axiom-state nil)
(defvar axiom-process nil)
(defvar axiom-last-output nil)

(defun axiom-local ()
   "Run axiom in a terminal environment"
  (interactive)
  ;; Run that command and switch to the new buffer
  (switch-to-buffer (make-comint "axiom" "axiom" nil "-noclef" "-noht"))
  (add-hook 'comint-output-filter-functions 'axiom-output-filter nil t)
  (add-hook 'comint-preoutput-filter-functions 'axiom-preoutput-filter)
  ;; and identify the process as well:
  (setq axiom-process (get-buffer-process (current-buffer)))
  (axiom-mode))

(defface axiom-output-face '((t (:background "lightgrey")))
  "Face used for output."
  :group 'axiom)

(defun axiom-preoutput-filter (str) 
  (setq axiom-last-output (marker-position (process-mark axiom-process)))
  str)

(defun axiom-output-filter (str)
  (let ((inhibit-read-only t)
        (beg axiom-last-output) (end (process-mark axiom-process)))
    (put-text-property beg end 'front-sticky t)
    (put-text-property beg end 'rear-nonsticky t)
    (put-text-property beg end 'read-only t)
    (put-text-property beg end 'face 'axiom-output-face))
  str)

(defun axiom-eval ()
  "Evaluate the current input and append output."
  (interactive)
  (goto-char (point-max))
  (insert "\n")
  (comint-send-string 
    axiom-process
    (buffer-substring (process-mark axiom-process) (point-max)))
  (goto-char (point-max))
  (comint-set-process-mark))

(define-key axiom-mode-map "\C-m" 'axiom-eval)
(define-key axiom-mode-map "\C-j" 'newline)
----------------------------------------------------------------------------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]