diff options
author | Samuel Walladge <samuel@swalladge.id.au> | 2017-02-08 12:25:23 +1030 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2017-02-08 04:37:22 +0100 |
commit | 3fa65ae8bb8cca86742a4f4bf2980a9827aac748 (patch) | |
tree | 10c84ef76f0bcb0777f66a2b554ae998465e5b43 | |
parent | 9e2e196b1c090dcfe179132693f68f9638bc1c6b (diff) | |
download | ranger-3fa65ae8bb8cca86742a4f4bf2980a9827aac748.tar.gz |
config.commands: quit, quitall: Don't exit if loader has work
Fixes #739
-rw-r--r-- | doc/ranger.1 | 15 | ||||
-rw-r--r-- | doc/ranger.pod | 14 | ||||
-rw-r--r-- | doc/rifle.1 | 2 | ||||
-rwxr-xr-x | ranger/config/commands.py | 24 | ||||
-rw-r--r-- | ranger/config/rc.conf | 2 |
5 files changed, 41 insertions, 16 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1 index 89acdd78..1cb2d8ed 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.8.1" "2017-02-06" "ranger manual" +.TH RANGER 1 "ranger-1.8.1" "2017-02-08" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -937,6 +937,7 @@ ranger. For your convenience, this is a list of the \*(L"public\*(R" commands i \& punmap keys... \& quit \& quit! +\& quitall \& relink newpath \& rename_append [\-FLAGS...] \& rename newname @@ -1170,11 +1171,17 @@ a row. Removes key mappings of the pager. Works like the \f(CW\*(C`unmap\*(C'\fR command. .IP "quit" 2 .IX Item "quit" -Like quit!, but closes only this tab if multiple tabs are open. +If only one tab is currently open and no tasks are running, quit ranger. If +multiple tabs are open, only close this tab. The current directory will be +bookmarked as ' so you can re-enter it by typing `` or '' the next time you +start ranger. .IP "quit!" 2 .IX Item "quit!" -Quit ranger. The current directory will be bookmarked as ' so you can re-enter -it by typing `` or '' the next time you start ranger. +Force quit ranger, even if tasks are running. The current directory will still +be bookmarked similarly to \f(CW\*(C`quit\*(C'\fR. +.IP "quitall" 2 +.IX Item "quitall" +Like \f(CW\*(C`quit\*(C'\fR, will close ranger even if multiple tabs are open. .IP "relink \fInewpath\fR" 2 .IX Item "relink newpath" Change the link destination of the current symlink file to <newpath>. First diff --git a/doc/ranger.pod b/doc/ranger.pod index 9fc7e144..8a783094 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -958,6 +958,7 @@ ranger. For your convenience, this is a list of the "public" commands including punmap keys... quit quit! + quitall relink newpath rename_append [-FLAGS...] rename newname @@ -1224,12 +1225,19 @@ Removes key mappings of the pager. Works like the C<unmap> command. =item quit -Like quit!, but closes only this tab if multiple tabs are open. +If only one tab is currently open and no tasks are running, quit ranger. If +multiple tabs are open, only close this tab. The current directory will be +bookmarked as ' so you can re-enter it by typing `` or '' the next time you +start ranger. =item quit! -Quit ranger. The current directory will be bookmarked as ' so you can re-enter -it by typing `` or '' the next time you start ranger. +Force quit ranger, even if tasks are running. The current directory will still +be bookmarked similarly to C<quit>. + +=item quitall + +Like C<quit>, will close ranger even if multiple tabs are open. =item relink I<newpath> diff --git a/doc/rifle.1 b/doc/rifle.1 index feafb659..b61423e7 100644 --- a/doc/rifle.1 +++ b/doc/rifle.1 @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RIFLE 1" -.TH RIFLE 1 "rifle-1.8.1" "2017-02-06" "rifle manual" +.TH RIFLE 1 "rifle-1.8.1" "2017-02-08" "rifle manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l diff --git a/ranger/config/commands.py b/ranger/config/commands.py index aa955605..012cbbde 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -477,26 +477,33 @@ class default_linemode(Command): class quit(Command): # pylint: disable=redefined-builtin """:quit - Closes the current tab. If there is only one tab, quit the program. + Closes the current tab. If there is only one tab, quit the program. """ - def execute(self): - if len(self.fm.tabs) <= 1: + def _exit_no_work(self): + if self.fm.loader.has_work(): + self.fm.notify('Not quitting: Tasks in progress: Use `quit!` to force quit') + else: self.fm.exit() - self.fm.tab_close() + + def execute(self): + if len(self.fm.tabs) >= 2: + self.fm.tab_close() + else: + self._exit_no_work() -class quitall(Command): +class quitall(quit): """:quitall Quits the program immediately. """ def execute(self): - self.fm.exit() + self._exit_no_work() -class quit_bang(quitall): +class quit_bang(Command): """:quit! Quits the program immediately. @@ -504,6 +511,9 @@ class quit_bang(quitall): name = 'quit!' allow_abbrev = False + def execute(self): + self.fm.exit() + class terminal(Command): """:terminal diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 991c1d3a..0f60c195 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -233,7 +233,7 @@ set wrap_scroll false alias e edit alias q quit -alias q! quitall +alias q! quit! alias qa quitall alias qall quitall alias setl setlocal |