summaryrefslogtreecommitdiffstats
path: root/Misc/python-mode.el
Commit message (Collapse)AuthorAgeFilesLines
* (py-goto-statement-below): Watch out for landing in a triple quotedBarry Warsaw2002-05-231-3/+4
| | | | | string with text in column zero. Skip that stuff when looking for the "first statement following the statement containing point".
* (py-execute-region): Do the blank line skipping inside theBarry Warsaw2002-05-121-8/+7
| | | | | save-excursion so that when the function is complete, point is preserved.
* Watch out for older XEmacsen for which requiring info-look doesn'tBarry Warsaw2002-04-301-8/+11
| | | | define info-lookup-maybe-add-help.
* (py-comint-output-filter-function): Put the pop-to-buffer call insideBarry Warsaw2002-04-261-1/+1
| | | | | the `when' condition so other non-Python shell comint changes won't cause random buffers to pop.
* Fix typo in the setup of interpreter-mode-alist.Barry Warsaw2002-04-251-1/+1
|
* SF patch #510288 by Kevin J. Butler, mod'd by Barry. This providesBarry Warsaw2002-04-251-7/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | better auto-recognition of a Jython file vs. a CPython (or agnostic) file by looking at the #! line more closely, and inspecting the import statements in the first 20000 bytes (configurable). Specifically, (py-import-check-point-max): New variable, controlling how far into the buffer it will search for import statements. (py-jpython-packages): List of package names that are Jython-ish. (py-shell-alist): List of #! line programs and the modes associated with them. (jpython-mode-hook): Extra hook that runs when entering jpython-mode (what about Jython mode? <20k wink>). (py-choose-shell-by-shebang, py-choose-shell-by-import, py-choose-shell): New functions. (python-mode): Use py-choose-shell. (jpython-mode): New command. (py-execute-region): Don't use my previous hacky attempt at doing this, use the new py-choose-shell function. One other thing this file now does: it attempts to add the proper hooks to interpreter-mode-alist and auto-mode-alist if they aren't already there. Might help with Emacs users since that editor doesn't come with python-mode by default.
* (py-execute-region): Alexander Schmolck points out that leadingBarry Warsaw2002-04-251-0/+7
| | | | | whitespace can hose the needs-if test. So just skip all blank lines at the start of the region right off the bat.
* (py-comint-output-filter-function): Add a pop-to-buffer call so youBarry Warsaw2002-04-251-0/+1
| | | | | always get to see the result of e.g. a py-execute-region. Funny, this bugged both me /and/ Guido!
* (py-shell-hook): A new hook variable, run at the end of py-shell.Barry Warsaw2002-04-251-0/+14
| | | | | | | | | Allows for some customization of the underlying comint buffer. (py-shell): Call the new hook. (info-lookup-maybe-add-help): A new call suggested by Milan Zamazal to make lookups in the Info documentation easier.
* Merge in Skip's last few updates w.r.t. py-help-at-point:Barry Warsaw2002-04-221-2/+6
| | | | | | | | (py-mode-map): Bind py-help-at-point to f1 as well as C-c C-h (py-help-at-point): Make sure the symbol is quoted so things like pydoc.help('sys.platform') work correctly. Also, leave the *Python Output* buffer in help-mode; this may be a bit more controversial.
* Some contributions and ideas by Alexander Schmolck: add a keybindingBarry Warsaw2002-04-221-9/+52
| | | | | | | | | | | | | | | | | | | to call pychecker on the current file, add a face for pseudo keywords self, None, True, False, and Ellipsis. Specifically, (py-pychecker-command, py-pychecker-command-args): New variables. (py-pseudo-keyword-face): New face variable, defaulting to a copy of font-lock-keyword-face. (python-font-lock-keywords): Add an entry for self, None, True, False, Ellipsis to be rendered in py-pseudo-keyword-face. (py-pychecker-history): New variable. (py-mode-map): Bind C-c C-w to py-pychecker-run. (py-pychecker-run): New command.
* Skip Montanaro's contribution (slightly mod'd by Barry) to provide aBarry Warsaw2002-04-221-4/+54
| | | | | | | | | | | | | | "help-on-symbol-at-point" feature which uses pydoc to provide help on the symbol under point, if available. Mods include some name changes, a port to Emacs, binding the command to C-c C-h, and providing a more informative error message if the symbol's help can't be found (through use of a nasty bare except). Note also that py-describe-mode has been moved off of C-c C-h m; it's now just available on C-c ? Closes SF patch #545439.
* (py-execute-region): If the line at the beginning of the region is aBarry Warsaw2002-04-221-6/+11
| | | | | | | | | | | | | | | #! line, use the command on that line as the shell command to use to execute the region. I.e. if the region looks like ---------------- #! /usr/bin/env python1.5 print 'hello world'.startswith('hello') ---------------- you'll get an exception! :) This closes SF bug #232398.
* (py-execute-region): If you ran this without having visited aBarry Warsaw2002-04-221-45/+23
| | | | | | | | | | | | | | | | | | python-mode file, py-which-shell would have been nil and the command to use would not get set correctly. This changes things so that 1) the temporary file has a .py extension, 2) the temporary file is put into python-mode, and 3) the temporary file's py-which-shell is captured in a local `shell' variable, which is used to calculate the command to use. Closes SF bug #545436. (py-parse-state): Rip out the XEmacs-specific calls to buffer-syntactic-context, which can get quite confused if there's an open paren in column zero say, embedded in a triple quoted string. This was always a performance hack anyway, and computers are fast enough now that we should be able to get away with the slower, more portable, full-parse branch. Closes SF bug #451841. Update the comments at the top of the file.
* (py-temp-directory): Add /var/tmp to the list of directories thisBarry Warsaw2002-03-181-3/+4
| | | | | | searches. This is added after /tmp. Closes SF bug #505488, except that /var/tmp comes after /tmp instead of the patch's suggestion of putting it before /usr/tmp.
* (py-honor-comment-indentation, py-compute-indentation): Fix theBarry Warsaw2002-03-151-3/+7
| | | | | | | | | implementation to match the documentation for py-honor-comment-indentation w.r.t. not nil or t value. In that case it should still ignore ## for indentation purposes. Closes SF bug #523825, w/ patch provided by Christian Stork (mod'd by Barry). Python 2.2.1 candidate.
* (py-version): Hopefully fixed my XEmacs settings so this doesn't getBarry Warsaw2001-07-061-1/+1
| | | | clobbered on checkin.
* (py-continuation-offset): Update docstring to describe that thisBarry Warsaw2001-07-061-4/+9
| | | | | | | | additional offset is only applied to continuation lines for block opening statements. (py-compute-indentation): Only add py-continuation-offset if py-statement-opens-block-p is true.
* (python-font-lock-keywords): Add "yield" as a keyword to support theBarry Warsaw2001-06-191-2/+2
| | | | new "simple generators" feature of 2.2. See PEP 255.
* (py-continuation-offset): New variable which controls how much toBarry Warsaw2001-06-181-3/+12
| | | | | | | indent continuation lines, defined as lines following those that end in backslash. (py-compute-indentation): Support for py-continuation-offset.
* (py-pdbtrack-track-stack-file): On Ken's suggestion, add "pdbtrack:"Barry Warsaw2001-04-111-3/+3
| | | | prefix to the message lines.
* intermediateBarry Warsaw2001-04-111-51/+148
|
* (py-parse-state): Teach python-mode how to scan code which followsBarry Warsaw2001-02-241-3/+11
| | | | multi-line list comprehensions.
* (py-execute-region): This one's easy... kill the temporary file'sBarry Warsaw2001-02-201-2/+4
| | | | buffer after executing its contents.
* (python-font-lock-keywords): Add highlighting of `as' as a keyword,Barry Warsaw2000-12-271-0/+2
| | | | | but only in "import foo as bar" statements (including optional preceding `from' clause).
* (py-goto-beginning-of-tqs): When searching backwards for the matchingBarry Warsaw2000-10-271-4/+8
| | | | | | delimiter, watch out for backslash escaped delimiters. Also use = instead of eq for character comparison (because a character is = to it's integer value, but not eq to it).
* (py-execute-region): Make sure the new temporary buffer is current forBarry Warsaw2000-06-231-3/+4
| | | | the insertion of the text.
* (py-execute-region): Based on suggestions by Francois Pinard and SkipBarry Warsaw2000-05-231-4/+25
| | | | | | Montanaro, handle execution of indented regions by inserting an "if 1:" in front of the block. This better preserves things like triple quoted strings and commented regions. This patch resolves PR#264.
* (py-shell): Set the default shell if not set yet. It's sometimesBarry Warsaw1999-08-101-0/+3
| | | | | convenient to call py-shell before the first Python file has been visited.
* A few minor Customize changes:Barry Warsaw1999-07-281-3/+6
| | | | | | | (python): Set defgroup :prefix to "py-" to make variable names cleaner. (py-jpython-command, py-jpython-command-args): Set :tag for proper capitalization of JPython in variable name display.
* (python-mode): Set which interpreter (CPython or JPython) to use theBarry Warsaw1999-07-281-18/+21
| | | | | | | | | | | | | | | | | first time a py buffer is visited during the Emacs session. This ensures that py-which-shells is initialized and also guarantees that the mode lines reflect the correct shell. First bug found by GvR, second one has long bugged :) me. (py-toggle-shells): Programmatically, arg can also take the symbols `cpython' or `jpython', which makes it easy to call with the value of py-default-interpreter. (py-shell): Don't need to initialize py-which-* variables since these will guarantee to be initialized by python-mode when the first py buffer is visited. (py-default-interpreter): Update docstring.
* (py-beginning-of-def-or-class): Only move to match-beginning if theBarry Warsaw1999-07-271-2/+2
| | | | regex match actually succeeded!
* (py-statement-closes-block-p): py-goto-initial-line could leave us inBarry Warsaw1999-06-031-2/+2
| | | | the line's whitespace. back-to-indentation should /follow/ this call.
* (py-electric-backspace): I'm not sure this function should be specialBarry Warsaw1999-05-241-4/+5
| | | | | | casing when py-honor-comment-indentation is nil, but this could be a religious issue with some. Seems to me we should still be dedenting such comment lines one level.
* (py-parse-state): When running under Emacs -- which doesn't haveBarry Warsaw1999-05-241-1/+7
| | | | | | buffer-syntactic-context -- just short circuit the TQS test by jumping to point-min and doing the test from there. For long files, this will be faster than looping with a re-search-backwards.
* (py-statement-closes-block-p): Add a py-goto-initial-line which fixesBarry Warsaw1999-05-241-0/+1
| | | | | | | | | | | | | | | indentation when the return value is a multiline sexp: def bug(): try: if 2>1: return (11+ 12) else: #XXX return 12 except: return 13
* (py-shell): Added optional argprompt, which will prompt for additionalBarry Warsaw1999-02-161-12/+30
| | | | switches to pass into the shell process (only on initial startup).
* (py-default-interpreter): New variable which selects whether CPythonBarry Warsaw1999-02-161-2/+32
| | | | | or JPython is the default interpreter to use when `C-c !' is entered for the first time.
* (py-mode-map): Add back force of RET (aka C-m) toBarry Warsaw1999-01-211-0/+9
| | | | py-newline-and-indent.
* (py-mode-map): Removed special bindings for C-m and C-j toBarry Warsaw1999-01-191-3/+0
| | | | | | | | | | | py-newline-and-indent. These ought to get picked up by the mapcar that follows; any existing binding to newline-and-indent gets shadowed to py-newline-and-indent. This will break some people who, e.g. bind C-m or C-j to newline but still want these bound to py-newline-and-indent in Python mode. On the other hand, the forced binding pisses off Emacs diehards. So consider this experimental and see if any tall Dutch guys complain :-)
* (py-narrow-to-defun): New command (bound to C-x n d) which mimics theBarry Warsaw1999-01-181-0/+15
| | | | | | standard narrow-to-defun but works with Python classes and methods. With no arg, narrows to most enclosing def/method. With C-u arg, narrows to most enclosing class.
* (py-electric-delete): Implement the XEmacs 21 blessed way of checkingBarry Warsaw1999-01-151-3/+4
| | | | for delete forwardness.
* (py-outdent-p): Short circuit infloop for illegal constructBarry Warsaw1999-01-091-0/+2
| | | | (e.g. except: on first line of buffer).
* (py-goto-beginning-of-tqs): Finds the beginning of the triple quotedBarry Warsaw1998-12-151-11/+28
| | | | | | | | | | | | | | | | | | | | | | | string we find ourselves in, based on the passed in delimiter. (py-compute-indentation): Fixes for indentation errors when we land inside a triple quoted string. For example: def foo(): if os.path.isfile(o_pri_mbox_file) and os.path.isfile(o_pub_mbox_file): print """\ I found both a private and a public mbox archive file private: %s public : %s I won't move either file, but you should choose one and move it to %s You may want to merge them manually, but be careful about exposing private correspondences to the public.""" % ( o_pri_mbox_file, o_pub_mbox_file, mbox_file) *----indentation would be wrong on this line.
* (py-execute-region): Hack around the different behavior and switchBarry Warsaw1998-11-201-14/+21
| | | | | semantics between CPython/JPython when the script source is piped to stdin.
* (py-execute-region): Patch by Hunter Kelly so that execution uses theBarry Warsaw1998-11-171-4/+4
| | | | correct Python shell (CPython or JPython).
* (py-imenu-method-regexp): Fix suggested by Daniel Calvelo toBarry Warsaw1998-10-281-2/+6
| | | | generalize the matching of function arguments.
* #XEmacs 21 now supports Imenu, so I am able to test (and fix) someBarry Warsaw1998-10-281-92/+73
| | | | | | | | | | | | | #simple things. First step: rename the Imenu supportive variables and #functions in this file to py-imenu-* so I can grok what is part of #python-mode and what is part of Imenu. (py-imenu-create-index-engine): Fixed problem with two classes in a single file, caused by new semantics of py-beginning-of-def-or-class when called programmatically. #Note, there are still some problems with Imenu when arguments to #functions are funky, but it should be much better now.
* #Some minor changes in the commentary, obstensibly to test the newBarry Warsaw1998-10-271-8/+9
| | | | #checkin script.
* #Fixed some typos in docstrings.Barry Warsaw1998-10-271-6/+6
|