*** /tmp/skip/python-mode.el.~4.67~ Mon Nov 15 22:15:01 2004 --- /tmp/skip/python-mode.el Mon Nov 15 22:15:01 2004 *************** *** 80,85 **** --- 80,86 ---- (require 'custom) (require 'cl) (require 'compile) + (require 'ansi-color) ;; user definable variables *************** *** 345,350 **** --- 346,369 ---- "*Alist of interpreters and python shells. Used by `py-choose-shell' to select the appropriate python interpreter mode for a file.") + (defcustom py-shell-input-prompt-1-regexp "^>>> " + "*A regular expression to match the input prompt of the shell." + :type 'string + :group 'python) + + (defcustom py-shell-input-prompt-2-regexp "^[.][.][.] " + "*A regular expression to match the input prompt of the shell after the + first line of input." + :type 'string + :group 'python) + + (defcustom py-shell-switch-buffers-on-execute t + "*Controls switching to the Python buffer where commands are + executed. When non-nil the buffer switches to the Python buffer, if + not no switching occurs." + :type 'boolean + :group 'python) + (defcustom py-name-buffers-with-packages 'always "Determines how buffers containing python modules are named. *************** *** 1390,1396 **** (procbuf (process-buffer proc)) ; (comint-scroll-to-bottom-on-output t) (msg (format "## working on region in file %s...\n" filename)) ! (cmd (format "execfile(r'%s')\n" filename))) (unwind-protect (save-excursion (set-buffer procbuf) --- 1409,1416 ---- (procbuf (process-buffer proc)) ; (comint-scroll-to-bottom-on-output t) (msg (format "## working on region in file %s...\n" filename)) ! ;; add some comment, so that we can filter it out of history ! (cmd (format "execfile(r'%s') # PYTHON-MODE\n" filename))) (unwind-protect (save-excursion (set-buffer procbuf) *************** *** 1403,1414 **** (defun py-comint-output-filter-function (string) "Watch output for Python prompt and exec next file waiting in queue. This function is appropriate for `comint-output-filter-functions'." ! ;; TBD: this should probably use split-string ! (when (and (or (string-equal string ">>> ") ! (and (>= (length string) 5) ! (string-equal (substring string -5) "\n>>> "))) ! py-file-queue) ! (pop-to-buffer (current-buffer)) (py-safe (delete-file (car py-file-queue))) (setq py-file-queue (cdr py-file-queue)) (if py-file-queue --- 1423,1435 ---- (defun py-comint-output-filter-function (string) "Watch output for Python prompt and exec next file waiting in queue. This function is appropriate for `comint-output-filter-functions'." ! ;;remove ansi terminal escape sequences from string, not sure why they are ! ;;still around... ! (setq string (ansi-color-filter-apply string)) ! (when (and (string-match py-shell-input-prompt-1-regexp string) ! py-file-queue) ! (if py-shell-switch-buffers-on-execute ! (pop-to-buffer (current-buffer))) (py-safe (delete-file (car py-file-queue))) (setq py-file-queue (cdr py-file-queue)) (if py-file-queue *************** *** 1690,1696 **** (switch-to-buffer-other-window (apply 'make-comint py-which-bufname py-which-shell nil args)) (make-local-variable 'comint-prompt-regexp) ! (setq comint-prompt-regexp "^>>> \\|^[.][.][.] \\|^(pdb) ") (add-hook 'comint-output-filter-functions 'py-comint-output-filter-function) ;; pdbtrack --- 1711,1719 ---- (switch-to-buffer-other-window (apply 'make-comint py-which-bufname py-which-shell nil args)) (make-local-variable 'comint-prompt-regexp) ! (setq comint-prompt-regexp (concat py-shell-input-prompt-1-regexp "\\|" ! py-shell-input-prompt-2-regexp "\\|" ! "^(Pdb) ")) (add-hook 'comint-output-filter-functions 'py-comint-output-filter-function) ;; pdbtrack