1. Ivan Andrus
  2. sage-mode

Commits

Ivan Andrus  committed 618448a

Fix completion by fixing prompts
Respect python-shell-enable-font-lock if defined

  • Participants
  • Parent commits 37219e0
  • Branches default

Comments (0)

Files changed (1)

File emacs/sage-mode.el

View file
   (add-to-list 'compilation-error-regexp-alist 'sage-build-compilation)
 
   (pcomplete-sage-setup)
+
+  ;; The new python.el does things a little differently wrt prompts.
+  ;; In particular it has debugger and normal operation separated.
+  ;; If we don't set them correctly things like completion don't work.
+  (setq python-shell-prompt-regexp ">>>\\|sage:")
+  (setq python-shell-prompt-pdb-regexp "[(<]*[Ii]?[PpGg]db[>)]+ ")
+
+  ;; Respect python-shell-enable-font-lock
+  (when (or (not (boundp 'python-shell-enable-font-lock))
+	     python-shell-enable-font-lock)
+    (sage-font-lock))
+
   (compilation-shell-minor-mode 1))
 
+
 (defun inferior-sage-wait-for-prompt ()
   "Wait until the SAGE process is ready for input."
   (message "Waiting for sage: prompt...")
 
 \\{sage-mode-map}"
   (setq comment-column 60)
-  (set (make-local-variable 'font-lock-multiline) t))
+  (set (make-local-variable 'font-lock-multiline) t)
+  (sage-font-lock))
 
 (defun sage-font-lock ()
   "Install Sage font-lock patterns."
   (font-lock-add-keywords 'sage-mode python-font-lock-keywords 'set) ;; XXX
 ;;   (font-lock-add-keywords 'sage-mode
 ;; 			  `(("\\(\\*\\*\\)test\\(\\*\\*\\)" . 'font-lock-comment-face)))
-)
-
-(add-hook 'sage-mode-hook 'sage-font-lock)
-(add-hook 'inferior-sage-mode-hook 'sage-font-lock)
+  )
 
 ;;;_* Treat SAGE code as Python source code