Show More
@@ -12,6 +12,8 b' from IPython.ipapi import TryNext' | |||
|
12 | 12 | import IPython.macro |
|
13 | 13 | import IPython.Shell |
|
14 | 14 | |
|
15 | __leo_push_history = set() | |
|
16 | ||
|
15 | 17 | def init_ipython(ipy): |
|
16 | 18 | """ This will be run by _ip.load('ipy_leo') |
|
17 | 19 | |
@@ -336,6 +338,17 b' class LeoWorkbook:' | |||
|
336 | 338 | if re.match(cmp, node.h, re.IGNORECASE): |
|
337 | 339 | yield node |
|
338 | 340 | return |
|
341 | def require(self, req): | |
|
342 | """ Used to control node push dependencies | |
|
343 | ||
|
344 | Call this as first statement in nodes. If node has not been pushed, it will be pushed before proceeding | |
|
345 | ||
|
346 | E.g. wb.require('foo') will do wb.foo.ipush() if it hasn't been done already | |
|
347 | """ | |
|
348 | ||
|
349 | if req not in __leo_push_history: | |
|
350 | getattr(self.req).ipush() | |
|
351 | ||
|
339 | 352 | |
|
340 | 353 | @IPython.generics.complete_object.when_type(LeoWorkbook) |
|
341 | 354 | def workbook_complete(obj, prev): |
@@ -2693,6 +2693,8 b' Defaulting color scheme to \'NoColor\'"""' | |||
|
2693 | 2693 | |
|
2694 | 2694 | cd -<n>: changes to the n-th directory in the directory history. |
|
2695 | 2695 | |
|
2696 | cd -foo: change to directory that matches 'foo' in history | |
|
2697 | ||
|
2696 | 2698 | cd -b <bookmark_name>: jump to a bookmark set by %bookmark |
|
2697 | 2699 | (note: cd <bookmark_name> is enough if there is no |
|
2698 | 2700 | directory <bookmark_name>, but a bookmark with the name exists.) |
@@ -2712,6 +2714,7 b' Defaulting color scheme to \'NoColor\'"""' | |||
|
2712 | 2714 | |
|
2713 | 2715 | oldcwd = os.getcwd() |
|
2714 | 2716 | numcd = re.match(r'(-)(\d+)$',parameter_s) |
|
2717 | wordcd = re.match(r'(-)(\w+)$',parameter_s) | |
|
2715 | 2718 | # jump in directory history by number |
|
2716 | 2719 | if numcd: |
|
2717 | 2720 | nn = int(numcd.group(2)) |
@@ -2722,6 +2725,31 b' Defaulting color scheme to \'NoColor\'"""' | |||
|
2722 | 2725 | return |
|
2723 | 2726 | else: |
|
2724 | 2727 | opts = {} |
|
2728 | elif wordcd: | |
|
2729 | ps = None | |
|
2730 | fallback = None | |
|
2731 | pat = wordcd.group(2) | |
|
2732 | dh = self.shell.user_ns['_dh'] | |
|
2733 | # first search only by basename (last component) | |
|
2734 | for ent in reversed(dh): | |
|
2735 | if pat in os.path.basename(ent): | |
|
2736 | ps = ent | |
|
2737 | break | |
|
2738 | ||
|
2739 | if fallback is None and pat in ent: | |
|
2740 | fallback = ent | |
|
2741 | ||
|
2742 | # if we have no last part match, pick the first full path match | |
|
2743 | if ps is None: | |
|
2744 | ps = fallback | |
|
2745 | ||
|
2746 | if ps is None: | |
|
2747 | print "No matching entry in directory history" | |
|
2748 | return | |
|
2749 | else: | |
|
2750 | opts = {} | |
|
2751 | ||
|
2752 | ||
|
2725 | 2753 | else: |
|
2726 | 2754 | #turn all non-space-escaping backslashes to slashes, |
|
2727 | 2755 | # for c:\windows\directory\names\ |
General Comments 0
You need to be logged in to leave comments.
Login now