From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Christoph Scholtes Newsgroups: gmane.emacs.devel Subject: python.el cleanup Date: Mon, 28 Mar 2011 20:34:02 -0600 Message-ID: <86ipv28xk5.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1301366427 9343 80.91.229.12 (29 Mar 2011 02:40:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 29 Mar 2011 02:40:27 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 29 04:40:23 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4Oqr-0007Vy-48 for ged-emacs-devel@m.gmane.org; Tue, 29 Mar 2011 04:40:23 +0200 Original-Received: from localhost ([127.0.0.1]:58203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4Oqo-00083k-B8 for ged-emacs-devel@m.gmane.org; Mon, 28 Mar 2011 22:40:10 -0400 Original-Received: from [140.186.70.92] (port=34825 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4Ol8-0002Hz-Mt for emacs-devel@gnu.org; Mon, 28 Mar 2011 22:34:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4Ol7-0004iJ-AI for emacs-devel@gnu.org; Mon, 28 Mar 2011 22:34:18 -0400 Original-Received: from mail-iw0-f169.google.com ([209.85.214.169]:52598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4Ol7-0004iC-1a for emacs-devel@gnu.org; Mon, 28 Mar 2011 22:34:17 -0400 Original-Received: by iwg8 with SMTP id 8so4818747iwg.0 for ; Mon, 28 Mar 2011 19:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:from:to:subject:user-agent:date:message-id :mime-version:content-type; bh=ClHhHtJBoMwuANaBo5UJ4gEe/CqWSFIp2c9s8A+8+08=; b=rY1q6x3Go3bYrR/jcYpoqeGYfAjrUMrAmlS41+CG9C1Y4KSZLGlTgnU7uezxD1WJ/k CNcXp3HKM/Lc+ISNBzVCJM2AnzuuYNizMxyGZkPyHGi9kpvBemsEZ5Sj1qazZS6oXtLK xusn2NooQ3Glec8gL9u9gz+cRkdwMwFwqvEUE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:subject:user-agent:date:message-id:mime-version :content-type; b=i+Qwh+e6XsTn97M6pgxjoBCen62WeI57/BFrBgxEYDNU3RZuJYpEjG5+COsU/d6vio QsZhyDtBBgPlg6vuUVy4IUG1JH5aYBu0XkAUiziBGldaEGOEoMWGbL8YR+zUuIZuMv8s BJzNSsgGyARlqyjSTjNmctWICGAiuYTwuB2/U= Original-Received: by 10.231.123.141 with SMTP id p13mr5086223ibr.29.1301366056264; Mon, 28 Mar 2011 19:34:16 -0700 (PDT) Original-Received: from localhost (71-208-176-211.hlrn.qwest.net [71.208.176.211]) by mx.google.com with ESMTPS id y10sm3322270iba.63.2011.03.28.19.34.14 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 28 Mar 2011 19:34:15 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (windows-nt) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.214.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:137831 Archived-At: --=-=-= Content-Type: text/plain Find attached a patch to clean up the trunk's python.el in preparation for merging in Fabian's new python mode. Most of it (if not all) was added by Ken Manheimer's commits in revnos 84728 and 84779 when adding pdbtrack support, but as far as I can tell none of it is really needed for pdbtrack. Christoph --=-=-= Content-Type: text/x-patch; charset=iso-8859-1 Content-Disposition: inline; filename=python.patch Content-Transfer-Encoding: quoted-printable Content-Description: Patch for python.el =3D=3D=3D modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-03-27 10:55:07 +0000 +++ lisp/ChangeLog 2011-03-29 02:20:59 +0000 @@ -1,3 +1,12 @@ +2011-03-29 Christoph Scholtes + + * progmodes/python.el (python-default-interpreter) + (python-python-command-args, python-jython-command-args) + (python-which-shell, python-which-args, python-which-bufname) + (python-file-queue, python-comint-output-filter-function) + (python-toggle-shells, python-shell): Remove obsolete defcustoms, + variables and functions. + 2011-03-27 Jan Dj=C3=A4rv =20 * cus-start.el (all): Add boolean ns-auto-hide-menu-bar. =3D=3D=3D modified file 'lisp/progmodes/python.el' --- lisp/progmodes/python.el 2011-01-26 08:36:39 +0000 +++ lisp/progmodes/python.el 2011-02-24 06:15:59 +0000 @@ -499,44 +499,6 @@ :type 'integer) =20 =20 -(defcustom python-default-interpreter 'cpython - "*Which Python interpreter is used by default. -The value for this variable can be either `cpython' or `jpython'. - -When the value is `cpython', the variables `python-python-command' and -`python-python-command-args' are consulted to determine the interpreter -and arguments to use. - -When the value is `jpython', the variables `python-jpython-command' and -`python-jpython-command-args' are consulted to determine the interpreter -and arguments to use. - -Note that this variable is consulted only the first time that a Python -mode buffer is visited during an Emacs session. After that, use -\\[python-toggle-shells] to change the interpreter shell." - :type '(choice (const :tag "Python (a.k.a. CPython)" cpython) - (const :tag "JPython" jpython)) - :group 'python) - -(defcustom python-python-command-args '("-i") - "*List of string arguments to be used when starting a Python shell." - :type '(repeat string) - :group 'python) - -(defcustom python-jython-command-args '("-i") - "*List of string arguments to be used when starting a Jython shell." - :type '(repeat string) - :group 'python - :tag "JPython Command Args") - -;; for toggling between CPython and JPython -(defvar python-which-shell nil) -(defvar python-which-args python-python-command-args) -(defvar python-which-bufname "Python") -(make-variable-buffer-local 'python-which-shell) -(make-variable-buffer-local 'python-which-args) -(make-variable-buffer-local 'python-which-bufname) - (defcustom python-pdbtrack-do-tracking-p t "*Controls whether the pdbtrack feature is enabled or not. =20 @@ -562,11 +524,6 @@ (push '(python-pdbtrack-is-tracking-p python-pdbtrack-minor-mode-strin= g) minor-mode-alist)) =20 -;; Bind python-file-queue before installing the kill-emacs-hook. -(defvar python-file-queue nil - "Queue of Python temp files awaiting execution. -Currently-active file is at the head of the list.") - (defcustom python-shell-prompt-alist '(("ipython" . "^In \\[[0-9]+\\]: *") (t . "^>>> ")) @@ -2584,20 +2541,6 @@ =20 ;; pdbtrack features =20 -(defun python-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 (string-match python--prompt-regexp string) - python-file-queue) - (condition-case nil - (delete-file (car python-file-queue)) - (error nil)) - (setq python-file-queue (cdr python-file-queue)) - (if python-file-queue - (let ((pyproc (get-buffer-process (current-buffer)))) - (python-execute-file pyproc (car python-file-queue)))))) - (defun python-pdbtrack-overlay-arrow (activation) "Activate or deactivate arrow at beginning-of-line in current buffer." (if activation @@ -2742,45 +2685,6 @@ (setq got buf))) got)) =20 -(defun python-toggle-shells (arg) - "Toggles between the CPython and JPython shells. - -With positive argument ARG (interactively \\[universal-argument]), -uses the CPython shell, with negative ARG uses the JPython shell, and -with a zero argument, toggles the shell. - -Programmatically, ARG can also be one of the symbols `cpython' or -`jpython', equivalent to positive arg and negative arg respectively." - (interactive "P") - ;; default is to toggle - (if (null arg) - (setq arg 0)) - ;; preprocess arg - (cond - ((equal arg 0) - ;; toggle - (if (string-equal python-which-bufname "Python") - (setq arg -1) - (setq arg 1))) - ((equal arg 'cpython) (setq arg 1)) - ((equal arg 'jpython) (setq arg -1))) - (let (msg) - (cond - ((< 0 arg) - ;; set to CPython - (setq python-which-shell python-python-command - python-which-args python-python-command-args - python-which-bufname "Python" - msg "CPython" - mode-name "Python")) - ((> 0 arg) - (setq python-which-shell python-jython-command - python-which-args python-jython-command-args - python-which-bufname "JPython" - msg "JPython" - mode-name "JPython"))) - (message "Using the %s shell" msg))) - ;; Python subprocess utilities and filters (defun python-execute-file (proc filename) "Send to Python interpreter process PROC \"execfile('FILENAME')\". @@ -2801,71 +2705,6 @@ (set-buffer curbuf)) (process-send-string proc cmd))) =20 -;;;###autoload -(defun python-shell (&optional argprompt) - "Start an interactive Python interpreter in another window. -This is like Shell mode, except that Python is running in the window -instead of a shell. See the `Interactive Shell' and `Shell Mode' -sections of the Emacs manual for details, especially for the key -bindings active in the `*Python*' buffer. - -With optional \\[universal-argument], the user is prompted for the -flags to pass to the Python interpreter. This has no effect when this -command is used to switch to an existing process, only when a new -process is started. If you use this, you will probably want to ensure -that the current arguments are retained (they will be included in the -prompt). This argument is ignored when this function is called -programmatically. - -Note: You can toggle between using the CPython interpreter and the -JPython interpreter by hitting \\[python-toggle-shells]. This toggles -buffer local variables which control whether all your subshell -interactions happen to the `*JPython*' or `*Python*' buffers (the -latter is the name used for the CPython buffer). - -Warning: Don't use an interactive Python if you change sys.ps1 or -sys.ps2 from their default values, or if you're running code that -prints `>>> ' or `... ' at the start of a line. `python-mode' can't -distinguish your output from Python's output, and assumes that `>>> ' -at the start of a line is a prompt from Python. Similarly, the Emacs -Shell mode code assumes that both `>>> ' and `... ' at the start of a -line are Python prompts. Bad things can happen if you fool either -mode. - -Warning: If you do any editing *in* the process buffer *while* the -buffer is accepting output from Python, do NOT attempt to `undo' the -changes. Some of the output (nowhere near the parts you changed!) may -be lost if you do. This appears to be an Emacs bug, an unfortunate -interaction between undo and process filters; the same problem exists in -non-Python process buffers using the default (Emacs-supplied) process -filter." - (interactive "P") - (require 'ansi-color) ; For ipython - ;; Set the default shell if not already set - (when (null python-which-shell) - (python-toggle-shells python-default-interpreter)) - (let ((args python-which-args)) - (when (and argprompt - (called-interactively-p 'interactive) - (fboundp 'split-string)) - ;; TBD: Perhaps force "-i" in the final list? - (setq args (split-string - (read-string (concat python-which-bufname - " arguments: ") - (concat - (mapconcat 'identity python-which-args " ") " ") - )))) - (switch-to-buffer-other-window - (apply 'make-comint python-which-bufname python-which-shell nil args)) - (set-process-sentinel (get-buffer-process (current-buffer)) - 'python-sentinel) - (python--set-prompt-regexp) - (add-hook 'comint-output-filter-functions - 'python-comint-output-filter-function nil t) - ;; pdbtrack - (set-syntax-table python-mode-syntax-table) - (use-local-map python-shell-map))) - (defun python-pdbtrack-toggle-stack-tracking (arg) (interactive "P") (if (not (get-buffer-process (current-buffer))) --=-=-=--