     (define-key map "\C-c#" 'yacas-short-comment)
     (define-key map "\C-c*" 'yacas-long-comment)
     (define-key map "\C-c]" 'yacas-indent-region)
-    (define-key map "\C-c/" 'comment-region)
-    (define-key map "\C-c\\" 'yacas-uncomment-region)
+    (define-key map "\C-c;" 'comment-region)
+    (define-key map "\C-c:" 'yacas-uncomment-region)
     (define-key map "\C-c\C-t" 'yacas-title)
     (define-key map "\C-c\C-m" 'yacas-modify)
     ;; Motion commands
-    (define-key map "\C-c<" 'yacas-backward-to-same-indent)
-    (define-key map "\C-c>" 'yacas-forward-to-same-indent))
-
-(defun yacas-add-process-keys (map)
+    (define-key map "\M-\C-b" 'yacas-backward-to-same-indent)
+    (define-key map "\M-\C-f" 'yacas-forward-to-same-indent)
     ;; The run Yacas commands
-    (define-key map "\M-\C-p" 'yacas-start-process)
-    (define-key map "\M-\C-r" 'yacas-region)
-    (define-key map "\M-\C-b" 'yacas-buffer)
-    (define-key map "\M-\C-l" 'yacas-line)
-    (define-key map "\M-\C-k" 'yacas-kill-job)
-    (define-key map "\M-\C-s" 'yacas-eval-string)
-    (define-key map "\C-c=" 'yacas-recenter-output-buffer)
+    (define-key map "\C-c=" 'yacas-display-buffer)
+    (define-key map "\C-c\C-r" 'yacas-region)
+    (define-key map "\C-c\C-b" 'yacas-buffer)
+    (define-key map "\C-c\C-c" 'yacas-line)
+    (define-key map "\C-c\C-k" 'yacas-stop)
+    (define-key map "\C-c\C-s" 'yacas-eval-string)
     (define-key map "\C-c\C-h" 'yacas-help)
-;    (define-key map "\C-c\C-o" 'yacas-copy-last-output)
-;    (define-key map "\C-c\C-s" 'yacas-copy-complete-last-output)
-    (define-key map "\M-\C-q" 'yacas-reset))
-
-(if yacas-mode-map ()
-  (let ((map (make-sparse-keymap)))
-    (yacas-add-keys map)
-    (yacas-add-process-keys map)
-    (define-key map "\C-c?" 'yacas-info-help)
+    (define-key map "\C-c\C-q" 'yacas-reset)
+    ;; Misc
     (define-key map (kbd "M-TAB") 'yacas-complete)
+    (define-key map (kbd "C-TAB") 'yacas-dynamic-complete)
     (setq yacas-mode-map map)))
 
 ;;; Font-locking 

(defconst yacas-menu-help
  (list
   "Help"
   ["Yacas help" yacas-help yacas-have-w3]
   ["Yacas mode help" yacas-info-help]))

(defconst yacas-menu-yacas

menus after nil in the list will be displayed flushright in the
menubar.")

(defun inferior-yacas-menu-global-menubar ()
  (if yacas-running-xemacs
      (default-value 'default-menubar)
    (lookup-key (current-global-map) [menu-bar])))

(defvar inferior-yacas-mode-menu-map nil)

(defun inferior-yacas-menu-initialize-inferior-yacas-mode-menu-map ()
  (if (null inferior-yacas-mode-menu-map)
      (let ((map (make-sparse-keymap))
	    (dummy (make-sparse-keymap)))
	(require 'easymenu)
	;; initialize all the inferior-yacas-menu-*-menu variables
	;; with the menus.
	(easy-menu-define inferior-yacas-menu-yacas-menu (list dummy) nil
			  inferior-yacas-menu-yacas)
	(easy-menu-define inferior-yacas-menu-quit-menu (list dummy) nil
			  inferior-yacas-menu-quit)
	(easy-menu-define inferior-yacas-menu-arithmetic-menu (list dummy) nil
			  inferior-yacas-menu-arithmetic)
	(easy-menu-define inferior-yacas-menu-functions-menu (list dummy) nil
			  inferior-yacas-menu-functions)
	(easy-menu-define inferior-yacas-menu-linalg-menu (list dummy) nil
			  inferior-yacas-menu-linalg)
	(easy-menu-define inferior-yacas-menu-calculus-menu (list dummy) nil
			  inferior-yacas-menu-calculus)
	(easy-menu-define inferior-yacas-menu-simplify-menu (list dummy) nil
			  inferior-yacas-menu-simplify)
	(easy-menu-define inferior-yacas-menu-solve-menu (list dummy) nil
			  inferior-yacas-menu-solve)
	(easy-menu-define inferior-yacas-menu-poly-menu (list dummy) nil
			  inferior-yacas-menu-poly)
	(easy-menu-define inferior-yacas-menu-lists-menu (list dummy) nil
			  inferior-yacas-menu-lists)
	(easy-menu-define inferior-yacas-menu-config-menu (list dummy) nil
			  inferior-yacas-menu-config)
	(easy-menu-define inferior-yacas-menu-prog-menu (list dummy) nil
			  inferior-yacas-menu-prog)
	(easy-menu-define inferior-yacas-menu-others-menu (list dummy) nil
			  inferior-yacas-menu-others)
	(easy-menu-define inferior-yacas-menu-help-menu (list dummy) nil
			  inferior-yacas-menu-help)
	;; block the global menubar entries in the map so that YACAS
	;; can take over the menubar if necessary.
	(define-key map [rootmenu] (make-sparse-keymap))
	(define-key map [rootmenu inferior-yacas] 
	        (cons "Yacas Shell" (make-sparse-keymap "Yacas Shell")))
	(define-key map [rootmenu inferior-yacas file] 'undefined)	
	(define-key map [rootmenu inferior-yacas files] 'undefined)	
	(define-key map [rootmenu inferior-yacas edit] 'undefined)	
	(define-key map [rootmenu inferior-yacas options] 'undefined)	
	(define-key map [rootmenu inferior-yacas search] 'undefined)
	(define-key map [rootmenu inferior-yacas buffer] 'undefined)
	(define-key map [rootmenu inferior-yacas completion] 'undefined)	
	(define-key map [rootmenu inferior-yacas signals] 'undefined)	
	(define-key map [rootmenu inferior-yacas inout] 'undefined)	
	(define-key map [rootmenu inferior-yacas mule] 'undefined)
	(define-key map [rootmenu inferior-yacas tools] 'undefined)
	(define-key map [rootmenu inferior-yacas help] 'undefined)
	(define-key map [rootmenu inferior-yacas help-menu] 'undefined)
	;; now build YACAS's menu tree.
	(let ((menu-alist
	       '(
		 (arithmetic
		  (cons "Arith" inferior-yacas-menu-arithmetic-menu))
		 (yacas
		    (cons "Yacas>>" inferior-yacas-menu-yacas-menu))
		 (quit
		  (cons "Quit" inferior-yacas-menu-quit-menu))
		 (functions
		  (cons "Functions" inferior-yacas-menu-functions-menu))
		 (linalg
		  (cons "LinAlg" inferior-yacas-menu-linalg-menu))
		 (calculus
		  (cons "Calc" inferior-yacas-menu-calculus-menu))
		 (simplify
		  (cons "Simp" inferior-yacas-menu-simplify-menu))
		 (solve
		  (cons "Solve" inferior-yacas-menu-solve-menu))
		 (poly
		  (cons "Poly" inferior-yacas-menu-poly-menu))
		 (lists
		  (cons "Lists" inferior-yacas-menu-lists-menu))
		 (config
		  (cons "Config" inferior-yacas-menu-config-menu))
		 (progm
		  (cons "Prog" inferior-yacas-menu-prog-menu))
		 (others
		  (cons "Others" inferior-yacas-menu-others-menu))
		 (help
		  (cons "Help" inferior-yacas-menu-help-menu))))
	      cons
	      (vec (vector 'rootmenu 'inferior-yacas nil))
	      ;; menus appear in the opposite order that we
	      ;; define-key them.
	      (menu-list 
	       (if (consp inferior-yacas-use-menus)
		   (reverse inferior-yacas-use-menus)
		 (list nil 'help 'config 'progm 'others 'lists 'poly 
		       'solve 'simplify 'calculus 'linalg 'functions 
		       'arithmetic 'quit))))
	  (while menu-list
	    (if (null (car menu-list))
		nil;; no flushright support in FSF Emacs
	      (aset vec 2 (intern (concat "inferior-yacas-menu-"
					  (symbol-name
					   (car menu-list)) "-menu")))
	      (setq cons (assq (car menu-list) menu-alist))
	      (if cons
		  (define-key map vec (eval (car (cdr cons))))))
	    (setq menu-list (cdr menu-list))))
	(setq inferior-yacas-mode-menu-map map)
	(run-hooks 'inferior-yacas-menu-setup-hook))))

(defun inferior-yacas-menu-make-xemacs-menubar ()
  (let ((menu-alist
	 '((yacas    . inferior-yacas-menu-yacas)
	   (arithmetic  . inferior-yacas-menu-arithmetic)
	   (functions    . inferior-yacas-menu-functions)
	   (linalg     . inferior-yacas-menu-linalg)
	   (calculus     . inferior-yacas-menu-calculus)
	   (simplify     . inferior-yacas-menu-simplify)
	   (solve     . inferior-yacas-menu-solve)
	   (poly     . inferior-yacas-menu-poly)
	   (lists     . inferior-yacas-menu-lists)
	   (config     . inferior-yacas-menu-config)
	   (progm     . inferior-yacas-menu-prog)
	   (others     . inferior-yacas-menu-others)
	   (help . inferior-yacas-menu-help))
	 )
	cons
	(menubar nil)
	(menu-list inferior-yacas-use-menus))
    (while menu-list
      (cond
       ((null (car menu-list))
