summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2017-02-09 00:15:26 +0100
committernfnty <git@nfnty.se>2017-02-09 00:16:53 +0100
commita3ccb616e6fc8c88cf7ffcd079dab76655bcc002 (patch)
treebe96caa70553f6137bb3831a6105cfa6d93dd49c
parentc377b4814a5560a6fc34c5e5a5df2fe39d289cad (diff)
downloadranger-a3ccb616e6fc8c88cf7ffcd079dab76655bcc002.tar.gz
commands: Add `quitall!`, Change behavior of `quit!`
Fixes #802
-rw-r--r--doc/ranger.116
-rw-r--r--doc/ranger.pod15
-rw-r--r--doc/rifle.12
-rwxr-xr-xranger/config/commands.py37
-rw-r--r--ranger/config/rc.conf14
5 files changed, 56 insertions, 28 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 1cb2d8ed..1d709719 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-08" "ranger manual"
+.TH RANGER 1 "ranger-1.8.1" "2017-02-09" "ranger manual"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@@ -938,6 +938,7 @@ ranger. For your convenience, this is a list of the \*(L"public\*(R" commands i
\& quit
\& quit!
\& quitall
+\& quitall!
\& relink newpath
\& rename_append [\-FLAGS...]
\& rename newname
@@ -1171,17 +1172,18 @@ a row.
Removes key mappings of the pager. Works like the \f(CW\*(C`unmap\*(C'\fR command.
.IP "quit" 2
.IX Item "quit"
-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
+Closes the current tab, if there's only one tab. Otherwise quits if there are no tasks in progress.
+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!"
-Force quit ranger, even if tasks are running. The current directory will still
-be bookmarked similarly to \f(CW\*(C`quit\*(C'\fR.
+Like \f(CW\*(C`quit\*(C'\fR, except will force quit even if tasks are in progress.
.IP "quitall" 2
.IX Item "quitall"
-Like \f(CW\*(C`quit\*(C'\fR, will close ranger even if multiple tabs are open.
+Like \f(CW\*(C`quit\*(C'\fR, except will quit even if multiple tabs are open.
+.IP "quitall!" 2
+.IX Item "quitall!"
+Like \f(CW\*(C`quitall\*(C'\fR, except will force quit even if tasks are in progress.
.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 8a783094..8b02ee63 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -959,6 +959,7 @@ ranger. For your convenience, this is a list of the "public" commands including
quit
quit!
quitall
+ quitall!
relink newpath
rename_append [-FLAGS...]
rename newname
@@ -1225,19 +1226,21 @@ Removes key mappings of the pager. Works like the C<unmap> command.
=item quit
-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
+Closes the current tab, if there's only one tab. Otherwise quits if there are no tasks in progress.
+The current directory will be bookmarked as ' so you can re-enter it by typing `` or '' the next time you
start ranger.
=item quit!
-Force quit ranger, even if tasks are running. The current directory will still
-be bookmarked similarly to C<quit>.
+Like C<quit>, except will force quit even if tasks are in progress.
=item quitall
-Like C<quit>, will close ranger even if multiple tabs are open.
+Like C<quit>, except will quit even if multiple tabs are open.
+
+=item quitall!
+
+Like C<quitall>, except will force quit even if tasks are in progress.
=item relink I<newpath>
diff --git a/doc/rifle.1 b/doc/rifle.1
index b61423e7..3c97c771 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-08" "rifle manual"
+.TH RIFLE 1 "rifle-1.8.1" "2017-02-09" "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 012cbbde..8f71b241 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -477,9 +477,9 @@ 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's only one tab.
+ Otherwise quits if there are no tasks in progress.
"""
-
def _exit_no_work(self):
if self.fm.loader.has_work():
self.fm.notify('Not quitting: Tasks in progress: Use `quit!` to force quit')
@@ -493,22 +493,43 @@ class quit(Command): # pylint: disable=redefined-builtin
self._exit_no_work()
-class quitall(quit):
+class quit_bang(Command):
+ """:quit!
+
+ Closes the current tab, if there's only one tab.
+ Otherwise force quits immediately.
+ """
+ name = 'quit!'
+ allow_abbrev = False
+
+ def execute(self):
+ if len(self.fm.tabs) >= 2:
+ self.fm.tab_close()
+ else:
+ self.fm.exit()
+
+
+class quitall(Command):
""":quitall
- Quits the program immediately.
+ Quits if there are no tasks in progress.
"""
+ def _exit_no_work(self):
+ if self.fm.loader.has_work():
+ self.fm.notify('Not quitting: Tasks in progress: Use `quitall!` to force quit')
+ else:
+ self.fm.exit()
def execute(self):
self._exit_no_work()
-class quit_bang(Command):
- """:quit!
+class quitall_bang(Command):
+ """:quitall!
- Quits the program immediately.
+ Force quits immediately.
"""
- name = 'quit!'
+ name = 'quitall!'
allow_abbrev = False
def execute(self):
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 0f60c195..5b301b3c 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -231,12 +231,14 @@ set wrap_scroll false
# == Command Aliases in the Console
# ===================================================================
-alias e edit
-alias q quit
-alias q! quit!
-alias qa quitall
-alias qall quitall
-alias setl setlocal
+alias e edit
+alias q quit
+alias q! quit!
+alias qa quitall
+alias qa! quitall!
+alias qall quitall
+alias qall! quitall!
+alias setl setlocal
alias filter scout -prt
alias find scout -aeit