@@ -209,6 +209,8 @@ def buffer_add(editor, location):
209209 editor .window_arrangement .open_buffer (location )
210210
211211
212+ @cmd ('files' )
213+ @cmd ('ls' )
212214@cmd ('buffers' )
213215def buffer_list (editor ):
214216 """
@@ -280,22 +282,18 @@ def buffer_edit(editor, location, force=False):
280282
281283@cmd ('q' , accepts_force = True )
282284@cmd ('quit' , accepts_force = True )
283- def quit (editor , all_ = False , force = False ):
285+ def quit (editor , force = False ):
284286 """
285287 Quit.
286288 """
287- ebs = editor .window_arrangement .editor_buffers
288-
289- # When there are buffers that have unsaved changes, show balloon.
290- if not force and any (eb .has_unsaved_changes for eb in ebs ):
289+ eb = editor .window_arrangement .active_editor_buffer
290+ eb_is_open_in_another_window = len (list (editor .window_arrangement .get_windows_for_buffer (eb ))) > 1
291+ if not force and eb .has_unsaved_changes and not eb_is_open_in_another_window :
291292 editor .show_message (_NO_WRITE_SINCE_LAST_CHANGE_TEXT )
292-
293- # When there is more than one buffer open.
294- elif not all_ and len (ebs ) > 1 :
295- editor .show_message ('%i more files to edit' % (len (ebs ) - 1 ))
296-
297- else :
293+ elif editor .window_arrangement .active_tab .window_count () == 1 and len (editor .window_arrangement .tab_pages ) == 1 :
298294 editor .application .exit ()
295+ else :
296+ editor .window_arrangement .close_window ()
299297
300298
301299@cmd ('qa' , accepts_force = True )
@@ -304,7 +302,11 @@ def quit_all(editor, force=False):
304302 """
305303 Quit all.
306304 """
307- quit (editor , all_ = True , force = force )
305+ ebs = editor .window_arrangement .editor_buffers
306+ if not force and any (eb .has_unsaved_changes for eb in ebs ):
307+ editor .show_message (_NO_WRITE_SINCE_LAST_CHANGE_TEXT )
308+ else :
309+ editor .application .exit ()
308310
309311
310312@location_cmd ('w' , accepts_force = True )
@@ -329,7 +331,7 @@ def write_and_quit(editor, location, force=False):
329331 Write file and quit.
330332 """
331333 write (editor , location , force = force )
332- editor . application . exit ( )
334+ quit ( editor )
333335
334336
335337@cmd ('cq' )
@@ -343,13 +345,26 @@ def quit_nonzero(editor):
343345 editor .application .exit ()
344346
345347
348+ @cmd ('wa' )
349+ def write_all (editor ):
350+ """
351+ Write all changed buffers
352+ """
353+ for eb in editor .window_arrangement .editor_buffers :
354+ if eb .location is None :
355+ editor .show_message (_NO_FILE_NAME )
356+ break
357+ else :
358+ eb .write ()
359+
360+
346361@location_cmd ('wqa' , accepts_force = True )
347362def write_and_quit_all (editor , location , force = False ):
348363 """
349- Write current buffer and quit all.
364+ Write all changed buffers and quit all.
350365 """
351- write (editor , location , force = force )
352- quit (editor , all_ = True , force = force )
366+ write_all (editor )
367+ quit_all (editor )
353368
354369
355370@cmd ('h' )
0 commit comments