##// END OF EJS Templates
- improve support for tab-completion under emacs...
fperez -
Show More
@@ -1,7 +1,7 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Magic functions for InteractiveShell.
3 3
4 $Id: Magic.py 984 2005-12-31 08:40:31Z fperez $"""
4 $Id: Magic.py 986 2005-12-31 23:07:31Z fperez $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -128,12 +128,21 b' license. To use profiling, please install"python2.3-profiler" from non-free.""")'
128 128
129 129 The set of slices is given as a list of strings (like ['1','4:8','9'],
130 130 since this function is for use by magic functions which get their
131 arguments as strings."""
131 arguments as strings.
132
133 Note that slices can be called with two notations:
134
135 N:M -> standard python form, means including items N...(M-1).
136
137 N-M -> include items N..M (closed endpoint)."""
132 138
133 139 cmds = []
134 140 for chunk in slices:
135 141 if ':' in chunk:
136 142 ini,fin = map(int,chunk.split(':'))
143 elif '-' in chunk:
144 ini,fin = map(int,chunk.split('-'))
145 fin += 1
137 146 else:
138 147 ini = int(chunk)
139 148 fin = ini+1
@@ -1539,7 +1548,7 b' Currently the magic system has the following functions:\\n"""'
1539 1548 """Define a set of input lines as a macro for future re-execution.
1540 1549
1541 1550 Usage:\\
1542 %macro name n1:n2 n3:n4 ... n5 .. n6 ...
1551 %macro name n1-n2 n3-n4 ... n5 .. n6 ...
1543 1552
1544 1553 This will define a global variable called `name` which is a string
1545 1554 made of joining the slices and lines you specify (n1,n2,... numbers
@@ -1548,8 +1557,12 b' Currently the magic system has the following functions:\\n"""'
1548 1557 you had typed them. You just type 'name' at the prompt and the code
1549 1558 executes.
1550 1559
1551 Note that the slices use the standard Python slicing notation (5:8
1552 means include lines numbered 5,6,7).
1560 The notation for indicating number ranges is: n1-n2 means 'use line
1561 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1562 using the lines numbered 5,6 and 7.
1563
1564 Note: as a 'hidden' feature, you can also use traditional python slice
1565 notation, where N:M means numbers N through M-1.
1553 1566
1554 1567 For example, if your history contains (%hist prints it):
1555 1568
@@ -1563,7 +1576,7 b' Currently the magic system has the following functions:\\n"""'
1563 1576 you can create a macro with lines 44 through 47 (included) and line 49
1564 1577 called my_macro with:
1565 1578
1566 In [51]: %macro my_macro 44:48 49
1579 In [51]: %macro my_macro 44-47 49
1567 1580
1568 1581 Now, typing `my_macro` (without quotes) will re-execute all this code
1569 1582 in one pass.
@@ -1600,7 +1613,7 b' Currently the magic system has the following functions:\\n"""'
1600 1613 """Save a set of lines to a given filename.
1601 1614
1602 1615 Usage:\\
1603 %save filename n1:n2 n3:n4 ... n5 .. n6 ...
1616 %save filename n1-n2 n3-n4 ... n5 .. n6 ...
1604 1617
1605 1618 This function uses the same syntax as %macro for line extraction, but
1606 1619 instead of creating a macro it saves the resulting string to the
@@ -1,7 +1,7 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Release data for the IPython project.
3 3
4 $Id: Release.py 984 2005-12-31 08:40:31Z fperez $"""
4 $Id: Release.py 986 2005-12-31 23:07:31Z fperez $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
@@ -22,9 +22,9 b" name = 'ipython'"
22 22 # because bdist_rpm does not accept dashes (an RPM) convention, and
23 23 # bdist_deb does not accept underscores (a Debian convention).
24 24
25 version = '0.7.0.rc4'
25 version = '0.7.0.rc5'
26 26
27 revision = '$Revision: 984 $'
27 revision = '$Revision: 986 $'
28 28
29 29 description = "An enhanced interactive Python shell."
30 30
@@ -256,6 +256,12 b' class IPCompleter(Completer):'
256 256 self.space_name_re = re.compile(r'([^\\] )')
257 257 # Hold a local ref. to glob.glob for speed
258 258 self.glob = glob.glob
259
260 # Determine if we are running on 'dumb' terminals, like (X)Emacs
261 # buffers, to avoid completion problems.
262 term = os.environ.get('TERM','xterm')
263 self.dumb_terminal = term in ['dumb','emacs']
264
259 265 # Special handling of backslashes needed in win32 platforms
260 266 if sys.platform == "win32":
261 267 self.clean_glob = self._clean_glob_win32
@@ -496,7 +502,10 b' class IPCompleter(Completer):'
496 502 # completions' message, just do the right thing and give the user
497 503 # his tab! Incidentally, this enables pasting of tabbed text from
498 504 # an editor (as long as autoindent is off).
499 if not self.get_line_buffer().strip():
505
506 # don't apply this on 'dumb' terminals, such as emacs buffers, so we
507 # don't interfere with their own tab-completion mechanism.
508 if not (self.dumb_terminal or self.get_line_buffer().strip()):
500 509 self.readline.insert_text('\t')
501 510 return None
502 511
@@ -1,9 +1,17 b''
1 1 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
2 2
3 * IPython/completer.py (IPCompleter.complete): small patch to help
4 tab-completion under Emacs, after a suggestion by John Barnard
5 <barnarj-AT-ccf.org>.
6
7 * IPython/Magic.py (Magic.extract_input_slices): added support for
8 the slice notation in magics to use N-M to represent numbers N...M
9 (closed endpoints). This is used by %macro and %save.
10
3 11 * IPython/completer.py (Completer.attr_matches): for modules which
4 12 define __all__, complete only on those. After a patch by Jeffrey
5 Collins <jcollins-AT-boulder.net>. Also, clean up and speed up
6 this routine.
13 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
14 speed up this routine.
7 15
8 16 * IPython/Logger.py (Logger.log): fix a history handling bug. I
9 17 don't know if this is the end of it, but the behavior now is
General Comments 0
You need to be logged in to leave comments. Login now