From 6cc91c85a090cbe73d773f69a68d9da7fd2f7a07 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 28 Aug 2006 21:13:34 +0000 Subject: (python-send-command): Don't wait for the command to terminate. Don't fiddle with compilation-parsing-end. --- lisp/progmodes/python.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index c38a6e82f83..4821376ec7b 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1373,11 +1373,16 @@ COMMAND should be a single statement." (let ((end (marker-position (process-mark (python-proc))))) (with-current-buffer python-buffer (goto-char (point-max))) (compilation-forget-errors) - ;; Must wait until this has completed before re-setting variables below. - (python-send-receive (concat command "; print '_emacs_out ()'")) + (python-send-string command) (with-current-buffer python-buffer - (set-marker compilation-parsing-end end) - (setq compilation-last-buffer (current-buffer))))) + (setq compilation-last-buffer (current-buffer))) + ;; No idea what this is for but it breaks the call to + ;; compilation-fake-loc in python-send-region. -- Stef + ;; Must wait until this has completed before re-setting variables below. + ;; (python-send-receive "print '_emacs_out ()'") + ;; (with-current-buffer python-buffer + ;; (set-marker compilation-parsing-end end)) + )) (defun python-send-region (start end) "Send the region to the inferior Python process." -- cgit v1.2.1 From e2ac11eba7776e890e2668d7c74e9c0b0b860b8e Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 28 Aug 2006 21:58:27 +0000 Subject: (python-send-command): Simplify. (run-python): Don't generate a new buffer unless `new' was specified. Make sure we send `import emacs' to the proper process. --- lisp/progmodes/python.el | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 4821376ec7b..ca22e36cb40 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1330,30 +1330,30 @@ buffer for a list of commands.)" ;; (not a name) in Python buffers from which `run-python' &c is ;; invoked. Would support multiple processes better. (when (or new (not (comint-check-proc python-buffer))) - (save-current-buffer - (let* ((cmdlist (append (python-args-to-list cmd) '("-i"))) - (path (getenv "PYTHONPATH")) - (process-environment ; to import emacs.py - (cons (concat "PYTHONPATH=" data-directory - (if path (concat ":" path))) - process-environment))) - (set-buffer (apply 'make-comint-in-buffer "Python" - (generate-new-buffer "*Python*") - (car cmdlist) nil (cdr cmdlist))) - (setq-default python-buffer (current-buffer)) - (setq python-buffer (current-buffer))) + (with-current-buffer + (let* ((cmdlist (append (python-args-to-list cmd) '("-i"))) + (path (getenv "PYTHONPATH")) + (process-environment ; to import emacs.py + (cons (concat "PYTHONPATH=" data-directory + (if path (concat ":" path))) + process-environment))) + (apply 'make-comint-in-buffer "Python" + (if new (generate-new-buffer "*Python*") "*Python*") + (car cmdlist) nil (cdr cmdlist))) + (setq-default python-buffer (current-buffer)) + (setq python-buffer (current-buffer)) (accept-process-output (get-buffer-process python-buffer) 5) - (inferior-python-mode))) + (inferior-python-mode) + ;; Load function definitions we need. + ;; Before the preoutput function was used, this was done via -c in + ;; cmdlist, but that loses the banner and doesn't run the startup + ;; file. The code might be inline here, but there's enough that it + ;; seems worth putting in a separate file, and it's probably cleaner + ;; to put it in a module. + ;; Ensure we're at a prompt before doing anything else. + (python-send-receive "import emacs; print '_emacs_out ()'"))) (if (derived-mode-p 'python-mode) (setq python-buffer (default-value 'python-buffer))) ; buffer-local - ;; Load function definitions we need. - ;; Before the preoutput function was used, this was done via -c in - ;; cmdlist, but that loses the banner and doesn't run the startup - ;; file. The code might be inline here, but there's enough that it - ;; seems worth putting in a separate file, and it's probably cleaner - ;; to put it in a module. - ;; Ensure we're at a prompt before doing anything else. - (python-send-receive "import emacs; print '_emacs_out ()'") ;; Without this, help output goes into the inferior python buffer if ;; the process isn't already running. (sit-for 1 t) ;Should we use accept-process-output instead? --Stef @@ -1369,8 +1369,8 @@ buffer for a list of commands.)" (defun python-send-command (command) "Like `python-send-string' but resets `compilation-shell-minor-mode'. COMMAND should be a single statement." - (assert (not (string-match "\n" command))) - (let ((end (marker-position (process-mark (python-proc))))) + ;; (assert (not (string-match "\n" command))) + ;; (let ((end (marker-position (process-mark (python-proc))))) (with-current-buffer python-buffer (goto-char (point-max))) (compilation-forget-errors) (python-send-string command) @@ -1382,7 +1382,7 @@ COMMAND should be a single statement." ;; (python-send-receive "print '_emacs_out ()'") ;; (with-current-buffer python-buffer ;; (set-marker compilation-parsing-end end)) - )) + ) ;;) (defun python-send-region (start end) "Send the region to the inferior Python process." -- cgit v1.2.1 From 132579d3e8faeb95087aa972bfbbdf2ab9a35e03 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 30 Aug 2006 21:10:10 +0000 Subject: (python-eldoc-function): Re-enable quit while waiting for process. --- lisp/progmodes/python.el | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index ca22e36cb40..66d8cd4714f 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1599,24 +1599,26 @@ Only works when point is in a function name, not its arg list, for instance. Assumes an inferior Python is running." (let ((symbol (with-syntax-table python-dotty-syntax-table (current-word)))) - ;; First try the symbol we're on. - (or (and symbol - (python-send-receive (format "emacs.eargs(%S, %s)" - symbol python-imports))) - ;; Try moving to symbol before enclosing parens. - (let ((s (syntax-ppss))) - (unless (zerop (car s)) - (when (eq ?\( (char-after (nth 1 s))) - (save-excursion - (goto-char (nth 1 s)) - (skip-syntax-backward "-") - (let ((point (point))) - (skip-chars-backward "a-zA-Z._") - (if (< (point) point) - (python-send-receive - (format "emacs.eargs(%S, %s)" - (buffer-substring-no-properties (point) point) - python-imports))))))))))) + ;; This is run from timers, so inhibit-quit tends to be set. + (with-local-quit + ;; First try the symbol we're on. + (or (and symbol + (python-send-receive (format "emacs.eargs(%S, %s)" + symbol python-imports))) + ;; Try moving to symbol before enclosing parens. + (let ((s (syntax-ppss))) + (unless (zerop (car s)) + (when (eq ?\( (char-after (nth 1 s))) + (save-excursion + (goto-char (nth 1 s)) + (skip-syntax-backward "-") + (let ((point (point))) + (skip-chars-backward "a-zA-Z._") + (if (< (point) point) + (python-send-receive + (format "emacs.eargs(%S, %s)" + (buffer-substring-no-properties (point) point) + python-imports)))))))))))) ;;;; Info-look functionality. -- cgit v1.2.1