diff options
| author | Fabián Ezequiel Gallina | 2012-07-31 20:43:31 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2012-07-31 20:43:31 -0300 |
| commit | 0d49da68b9cdc70a1f3ced0cae0b480ace5e28fc (patch) | |
| tree | e01075cea0f71c1248c5c7dc7066993bb5a2a592 | |
| parent | bc96620af40d80c4ccfb45671388c0640721fda1 (diff) | |
| download | emacs-0d49da68b9cdc70a1f3ced0cae0b480ace5e28fc.tar.gz emacs-0d49da68b9cdc70a1f3ced0cae0b480ace5e28fc.zip | |
Shell processes: enhancements to startup and CEDET compatibility.
* progmodes/python.el (python-shell-send-setup-max-wait): Delete var.
(python-shell-make-comint): accept-process-output at startup.
(run-python-internal): Set inferior-python-mode-hook to nil.
(python-shell-internal-get-or-create-process): call sit-for.
(python-preoutput-result): Add obsolete alias.
(python-shell-internal-send-string): Use it.
(python-shell-send-setup-code): Remove call to
accept-process-output.
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 69 |
2 files changed, 53 insertions, 28 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5bee28ab493..b961faf76c1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2012-07-31 Fabián Ezequiel Gallina <fgallina@cuca> | ||
| 2 | |||
| 3 | Shell processes: enhancements to startup and CEDET compatibility. | ||
| 4 | * progmodes/python.el (python-shell-send-setup-max-wait): Delete var. | ||
| 5 | (python-shell-make-comint): accept-process-output at startup. | ||
| 6 | (run-python-internal): Set inferior-python-mode-hook to nil. | ||
| 7 | (python-shell-internal-get-or-create-process): call sit-for. | ||
| 8 | (python-preoutput-result): Add obsolete alias. | ||
| 9 | (python-shell-internal-send-string): Use it. | ||
| 10 | (python-shell-send-setup-code): Remove call to | ||
| 11 | accept-process-output. | ||
| 12 | |||
| 1 | 2012-07-31 Andreas Schwab <schwab@linux-m68k.org> | 13 | 2012-07-31 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 14 | ||
| 3 | * buff-menu.el (list-buffers-noselect): Use prefix-numeric-value. | 15 | * buff-menu.el (list-buffers-noselect): Use prefix-numeric-value. |
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 001c28a00fa..f946509d6e0 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1354,14 +1354,6 @@ Restart the python shell after changing this variable for it to take effect." | |||
| 1354 | :group 'python | 1354 | :group 'python |
| 1355 | :safe 'booleanp) | 1355 | :safe 'booleanp) |
| 1356 | 1356 | ||
| 1357 | (defcustom python-shell-send-setup-max-wait 5 | ||
| 1358 | "Seconds to wait for process output before code setup. | ||
| 1359 | If output is received before the specified time then control is | ||
| 1360 | returned in that moment and not after waiting." | ||
| 1361 | :type 'integer | ||
| 1362 | :group 'python | ||
| 1363 | :safe 'integerp) | ||
| 1364 | |||
| 1365 | (defcustom python-shell-process-environment nil | 1357 | (defcustom python-shell-process-environment nil |
| 1366 | "List of environment variables for Python shell. | 1358 | "List of environment variables for Python shell. |
| 1367 | This variable follows the same rules as `process-environment' | 1359 | This variable follows the same rules as `process-environment' |
| @@ -1571,7 +1563,8 @@ non-nil the buffer is shown." | |||
| 1571 | (current-buffer (current-buffer))) | 1563 | (current-buffer (current-buffer))) |
| 1572 | (with-current-buffer buffer | 1564 | (with-current-buffer buffer |
| 1573 | (inferior-python-mode) | 1565 | (inferior-python-mode) |
| 1574 | (python-util-clone-local-variables current-buffer)))) | 1566 | (python-util-clone-local-variables current-buffer)) |
| 1567 | (accept-process-output (get-buffer-process buffer)))) | ||
| 1575 | (and pop (pop-to-buffer proc-buffer-name t)) | 1568 | (and pop (pop-to-buffer proc-buffer-name t)) |
| 1576 | proc-buffer-name))) | 1569 | proc-buffer-name))) |
| 1577 | 1570 | ||
| @@ -1605,17 +1598,19 @@ process buffer for a list of commands.)" | |||
| 1605 | "Run an inferior Internal Python process. | 1598 | "Run an inferior Internal Python process. |
| 1606 | Input and output via buffer named after | 1599 | Input and output via buffer named after |
| 1607 | `python-shell-internal-buffer-name' and what | 1600 | `python-shell-internal-buffer-name' and what |
| 1608 | `python-shell-internal-get-process-name' returns. This new kind | 1601 | `python-shell-internal-get-process-name' returns. |
| 1609 | of shell is intended to be used for generic communication related | 1602 | |
| 1610 | to defined configurations. The main difference with global or | 1603 | This new kind of shell is intended to be used for generic |
| 1611 | dedicated shells is that these ones are attached to a | 1604 | communication related to defined configurations, the main |
| 1612 | configuration, not a buffer. This means that can be used for | 1605 | difference with global or dedicated shells is that these ones are |
| 1613 | example to retrieve the sys.path and other stuff, without messing | 1606 | attached to a configuration, not a buffer. This means that can |
| 1614 | with user shells. Runs the hook | 1607 | be used for example to retrieve the sys.path and other stuff, |
| 1615 | `inferior-python-mode-hook' (after the `comint-mode-hook' is | 1608 | without messing with user shells. Note that |
| 1616 | run). \(Type \\[describe-mode] in the process buffer for a list | 1609 | `python-shell-enable-font-lock' and `inferior-python-mode-hook' |
| 1617 | of commands.)" | 1610 | are set to nil for these shells, so setup codes are not sent at |
| 1618 | (let ((python-shell-enable-font-lock nil)) | 1611 | startup." |
| 1612 | (let ((python-shell-enable-font-lock nil) | ||
| 1613 | (inferior-python-mode-hook nil)) | ||
| 1619 | (set-process-query-on-exit-flag | 1614 | (set-process-query-on-exit-flag |
| 1620 | (get-buffer-process | 1615 | (get-buffer-process |
| 1621 | (python-shell-make-comint | 1616 | (python-shell-make-comint |
| @@ -1658,12 +1653,25 @@ This is really not necessary at all for the code to work but it's | |||
| 1658 | there for compatibility with CEDET.") | 1653 | there for compatibility with CEDET.") |
| 1659 | (make-variable-buffer-local 'python-shell-internal-buffer) | 1654 | (make-variable-buffer-local 'python-shell-internal-buffer) |
| 1660 | 1655 | ||
| 1656 | (defvar python-shell-internal-last-output nil | ||
| 1657 | "Last output captured by the internal shell. | ||
| 1658 | This is really not necessary at all for the code to work but it's | ||
| 1659 | there for compatibility with CEDET.") | ||
| 1660 | (make-variable-buffer-local 'python-shell-internal-last-output) | ||
| 1661 | |||
| 1661 | (defun python-shell-internal-get-or-create-process () | 1662 | (defun python-shell-internal-get-or-create-process () |
| 1662 | "Get or create an inferior Internal Python process." | 1663 | "Get or create an inferior Internal Python process." |
| 1663 | (let* ((proc-name (python-shell-internal-get-process-name)) | 1664 | (let* ((proc-name (python-shell-internal-get-process-name)) |
| 1664 | (proc-buffer-name (format "*%s*" proc-name))) | 1665 | (proc-buffer-name (format "*%s*" proc-name))) |
| 1665 | (run-python-internal) | 1666 | (when (not (process-live-p proc-name)) |
| 1666 | (setq python-shell-internal-buffer proc-buffer-name) | 1667 | (run-python-internal) |
| 1668 | (setq python-shell-internal-buffer proc-buffer-name) | ||
| 1669 | ;; XXX: Why is this `sit-for' needed? | ||
| 1670 | ;; `python-shell-make-comint' calls `accept-process-output' | ||
| 1671 | ;; already but it is not helping to get proper output on | ||
| 1672 | ;; 'gnu/linux when the internal shell process is not running and | ||
| 1673 | ;; a call to `python-shell-internal-send-string' is issued. | ||
| 1674 | (sit-for 0.1 t)) | ||
| 1667 | (get-buffer-process proc-buffer-name))) | 1675 | (get-buffer-process proc-buffer-name))) |
| 1668 | 1676 | ||
| 1669 | (define-obsolete-function-alias | 1677 | (define-obsolete-function-alias |
| @@ -1672,6 +1680,9 @@ there for compatibility with CEDET.") | |||
| 1672 | (define-obsolete-variable-alias | 1680 | (define-obsolete-variable-alias |
| 1673 | 'python-buffer 'python-shell-internal-buffer "24.2") | 1681 | 'python-buffer 'python-shell-internal-buffer "24.2") |
| 1674 | 1682 | ||
| 1683 | (define-obsolete-variable-alias | ||
| 1684 | 'python-preoutput-result 'python-shell-internal-last-output "24.2") | ||
| 1685 | |||
| 1675 | (defun python-shell-send-string (string &optional process msg) | 1686 | (defun python-shell-send-string (string &optional process msg) |
| 1676 | "Send STRING to inferior Python PROCESS. | 1687 | "Send STRING to inferior Python PROCESS. |
| 1677 | When MSG is non-nil messages the first line of STRING." | 1688 | When MSG is non-nil messages the first line of STRING." |
| @@ -1723,11 +1734,14 @@ the output." | |||
| 1723 | (defun python-shell-internal-send-string (string) | 1734 | (defun python-shell-internal-send-string (string) |
| 1724 | "Send STRING to the Internal Python interpreter. | 1735 | "Send STRING to the Internal Python interpreter. |
| 1725 | Returns the output. See `python-shell-send-string-no-output'." | 1736 | Returns the output. See `python-shell-send-string-no-output'." |
| 1726 | (python-shell-send-string-no-output | 1737 | ;; XXX Remove `python-shell-internal-last-output' once CEDET is |
| 1727 | ;; Makes this function compatible with the old | 1738 | ;; updated to support this new mode. |
| 1728 | ;; python-send-receive. (At least for CEDET). | 1739 | (setq python-shell-internal-last-output |
| 1729 | (replace-regexp-in-string "_emacs_out +" "" string) | 1740 | (python-shell-send-string-no-output |
| 1730 | (python-shell-internal-get-or-create-process) nil)) | 1741 | ;; Makes this function compatible with the old |
| 1742 | ;; python-send-receive. (At least for CEDET). | ||
| 1743 | (replace-regexp-in-string "_emacs_out +" "" string) | ||
| 1744 | (python-shell-internal-get-or-create-process) nil))) | ||
| 1731 | 1745 | ||
| 1732 | (define-obsolete-function-alias | 1746 | (define-obsolete-function-alias |
| 1733 | 'python-send-receive 'python-shell-internal-send-string "24.2") | 1747 | 'python-send-receive 'python-shell-internal-send-string "24.2") |
| @@ -1808,7 +1822,6 @@ This function takes the list of setup code to send from the | |||
| 1808 | `python-shell-setup-codes' list." | 1822 | `python-shell-setup-codes' list." |
| 1809 | (let ((msg "Sent %s") | 1823 | (let ((msg "Sent %s") |
| 1810 | (process (get-buffer-process (current-buffer)))) | 1824 | (process (get-buffer-process (current-buffer)))) |
| 1811 | (accept-process-output process python-shell-send-setup-max-wait) | ||
| 1812 | (dolist (code python-shell-setup-codes) | 1825 | (dolist (code python-shell-setup-codes) |
| 1813 | (when code | 1826 | (when code |
| 1814 | (message (format msg code)) | 1827 | (message (format msg code)) |