Changeset 6647:638d1bf0fe74


Ignore:
Timestamp:
10/04/07 19:46:31 (6 years ago)
Author:
William Stein <wstein@…>
Branch:
default
Children:
6648:1b0ff5e3f10d, 6653:0e8bb6f4816b
Message:

Some fixes to the edit command.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sage/misc/edit_module.py

    r6645 r6647  
    5151template_defaults = { 
    5252      'vi'       : Template('vi -c ${line} ${file}'), 
     53      'vim'      : Template('vim -c ${line} ${file}'),       
    5354      'emacs'    : Template('emacs ${opts} +${line} ${file}'), 
    5455      'nedit-nc' : Template('nedit-nc -line ${line} ${file}'), 
     
    128129    
    129130   if template_string in template_defaults.keys(): 
    130      template_string = template_defaults[template_string] 
     131      template_string = template_defaults[template_string] 
    131132   edit_template = Template(template_string) 
    132133          
    133 def edit(obj): 
     134def edit(obj, bg=False, editor=None): 
    134135   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 
    137142   AUTHOR: 
    138143       Nils Bruin (2007-10-03) 
     
    169174 
    170175   try: 
    171       EDITOR = os.environ['EDITOR'].split() 
     176      if editor: 
     177         ED = editor 
     178      else: 
     179         ED = os.environ['EDITOR'] 
     180      EDITOR = ED.split() 
    172181      base = EDITOR[0] 
    173182      opts = ' '.join(EDITOR[1:]) 
     
    177186   filename, lineno = file_and_line(obj) 
    178187   cmd = edit_template.substitute(opts = opts, line = lineno, file = filename) 
    179    cmd += ' &' 
     188   if bg: 
     189      cmd += ' &' 
    180190   print cmd 
    181191   os.system(cmd) 
Note: See TracChangeset for help on using the changeset viewer.