Changeset 6647:638d1bf0fe74
- Timestamp:
- 10/04/07 19:46:31 (6 years ago)
- Branch:
- default
- Children:
- 6648:1b0ff5e3f10d, 6653:0e8bb6f4816b
- File:
-
- 1 edited
-
sage/misc/edit_module.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/misc/edit_module.py
r6645 r6647 51 51 template_defaults = { 52 52 'vi' : Template('vi -c ${line} ${file}'), 53 'vim' : Template('vim -c ${line} ${file}'), 53 54 'emacs' : Template('emacs ${opts} +${line} ${file}'), 54 55 'nedit-nc' : Template('nedit-nc -line ${line} ${file}'), … … 128 129 129 130 if template_string in template_defaults.keys(): 130 template_string = template_defaults[template_string]131 template_string = template_defaults[template_string] 131 132 edit_template = Template(template_string) 132 133 133 def edit(obj ):134 def edit(obj, bg=False, editor=None): 134 135 r""" 135 Open source of obj in editor of your choice. 136 136 Open source code of obj in editor of your choice. 137 138 INPUT: 139 bg -- bool (default: False); if True, then the 140 editor is run in the background 141 137 142 AUTHOR: 138 143 Nils Bruin (2007-10-03) … … 169 174 170 175 try: 171 EDITOR = os.environ['EDITOR'].split() 176 if editor: 177 ED = editor 178 else: 179 ED = os.environ['EDITOR'] 180 EDITOR = ED.split() 172 181 base = EDITOR[0] 173 182 opts = ' '.join(EDITOR[1:]) … … 177 186 filename, lineno = file_and_line(obj) 178 187 cmd = edit_template.substitute(opts = opts, line = lineno, file = filename) 179 cmd += ' &' 188 if bg: 189 cmd += ' &' 180 190 print cmd 181 191 os.system(cmd)
Note: See TracChangeset
for help on using the changeset viewer.
