Anonymous avatar Anonymous committed 3c2496e

Simple batchset in dialogs

Comments (0)

Files changed (5)

  Done
 ======
 
+- updating buffers with moved files : December 1, 2007
 - showing the old value of a field in dialogs : November 30, 2007
 - new file/directory/module/package; ``C-x p n [fdmp]`` : November 30, 2007
 - lucky-assist; ``M-?`` : November 29, 2007
 > Public Release 0.3
 
 * showing proposal type in code-assist
+* batchset in dialog

ropemacs/__init__.py

         else:
             self.project.validate(self.project.root)
 
-    def _reload_buffers(self, changed_resources):
+    def _reload_buffers(self, changed_resources, moved={}):
         for resource in changed_resources:
             buffer = lisp.find_buffer_visiting(str(resource.real_path))
-            if buffer and resource.exists():
-                lisp.set_buffer(buffer)
-                lisp.revert_buffer(None, 1)
+            if buffer:
+                if resource.exists():
+                    lisp.set_buffer(buffer)
+                    lisp.revert_buffer(None, 1)
+                elif resource in moved:
+                    new_resource = moved[resource]
+                    lisp.kill_buffer(buffer)
+                    lisp.find_file(new_resource.real_path)
 
     def _save_buffers(self, only_current=False):
         ask = lisp['rope-confirm-saving'].value()

ropemacs/dialog.py

     result = {}
     for name, conf in confs.items():
         result[name] = askdata(conf)
+    actions.append('batchset')
     names = list(confs.keys())
     names.extend(optionals.keys())
     names.extend(actions)
     base_question = Data('Choose what to do: ',
                          default=actions[0], values=names)
+    batchset_question = Data('Batch sets: ')
     while True:
         response = askdata(base_question)
         if response == '':
             response = base_question.default
-        if response in actions:
+        elif response == 'batchset':
+            sets = askdata(batchset_question)
+            for key, value in _parse_batchset(sets).items():
+                result[key] = value
+        elif response in actions:
             break
         else:
             if response in confs:
             oldvalue = result.get(response, None)
             result[response] = askdata(conf, starting=oldvalue)
     return response, result
+
+
+def _parse_batchset(sets):
+    result = {}
+    for line in sets.splitlines():
+        tokens = line.split(None, 1)
+        result[tokens[0]] = tokens[1]
+    return result
         self.assertEquals({'name': 'value'}, result)
         self.assertEquals('done', action)
 
+    def test_trivial_batchset(self):
+        optionals = {'name': dialog.Data()}
+        minibuffer = _MockAskConfig(['batchset', 'name value', 'done'])
+        action, result = dialog.show_dialog(minibuffer, ['done', 'cancel'],
+                                            optionals=optionals)
+        self.assertEquals({'name': 'value'}, result)
+        self.assertEquals('done', action)
+
+    def test_batchset_multiple_sets(self):
+        optionals = {'name1': dialog.Data(), 'name2': dialog.Data()}
+        minibuffer = _MockAskConfig(['batchset',
+                                     'name1 value1\nname2 value2', 'done'])
+        action, result = dialog.show_dialog(minibuffer, ['done', 'cancel'],
+                                            optionals=optionals)
+        self.assertEquals({'name1': 'value1', 'name2': 'value2'}, result)
+        self.assertEquals('done', action)
+
+    def test_trivial_batchset(self):
+        optionals = {'name': dialog.Data()}
+        minibuffer = _MockAskConfig(['batchset', 'name value', 'done'])
+        action, result = dialog.show_dialog(minibuffer, ['done', 'cancel'],
+                                            optionals=optionals)
+        self.assertEquals({'name': 'value'}, result)
+        self.assertEquals('done', action)
+
 
 class _MockAskConfig(object):
 
         self.responses = responses
         self.asked = []
 
-    def __call__(self, config):
+    def __call__(self, config, starting=None):
         self.asked.append(config)
         return self.responses[len(self.asked) - 1]
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.