From 2288a40b45ccdc57d287648c96c5bbe378b95a6d Mon Sep 17 00:00:00 2001 From: toonn Date: Sat, 31 Mar 2018 16:01:59 +0200 Subject: ranger can select files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because `ranger somefile` used to invoke rifle but that moved to its own command `ranger somefile` seemed defunct. People expected ranger to select the file and were baffled when it crashed. Now the documentation using the verbiage "path" is no longer confusing/a lie because it just works™ (until it breaks). Fixes #930 --- ranger/core/tab.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ranger/core/tab.py b/ranger/core/tab.py index 1d5e69d4..7bb45d75 100644 --- a/ranger/core/tab.py +++ b/ranger/core/tab.py @@ -4,7 +4,7 @@ from __future__ import (absolute_import, division, print_function) import os -from os.path import abspath, normpath, join, expanduser, isdir +from os.path import abspath, normpath, join, expanduser, isdir, dirname import sys from ranger.container import settings @@ -123,9 +123,11 @@ class Tab(FileManagerAware, SettingsAware): # pylint: disable=too-many-instance # get the absolute path path = normpath(join(self.path, expanduser(path))) + selectfile = None if not isdir(path): - return False + selectfile = path + path = dirname(path) new_thisdir = self.fm.get_directory(path) try: @@ -155,6 +157,8 @@ class Tab(FileManagerAware, SettingsAware): # pylint: disable=too-many-instance self.thisdir.sort_directories_first = self.fm.settings.sort_directories_first self.thisdir.sort_reverse = self.fm.settings.sort_reverse self.thisdir.sort_if_outdated() + if selectfile: + self.thisdir.move_to_obj(selectfile) if previous and previous.path != path: self.thisfile = self.thisdir.pointed_obj else: -- cgit 1.4.1-2-gfad0 From 4d9d271d458aa65a69a897ab26a64771fd63f056 Mon Sep 17 00:00:00 2001 From: toonn Date: Sat, 31 Mar 2018 16:43:07 +0200 Subject: Added positional arguments section to manpage The optional positional argument "path" wasn't documented, changed the argument to "path ..." because you can provide more than one and documented what happens. Added a sentence to the `--selectfile` item pointing out it's superceded by the positional arguments. --- doc/ranger.1 | 17 ++++++++++++----- doc/ranger.pod | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index f362d263..7f307490 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.1" "05.03.2018" "ranger manual" +.TH RANGER 1 "ranger-1.9.1" "2018-03-31" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -145,7 +145,7 @@ ranger \- visual file manager [\fB\-\-choosedir\fR=\fItarget\fR] [\fB\-\-selectfile\fR=\fIfilepath\fR] [\fB\-\-show\-only\-dirs\fR] [\fB\-\-list\-unused\-keys\fR] [\fB\-\-list\-tagged\-files\fR=\fItag\fR] -[\fB\-\-profile\fR] [\fB\-\-cmd\fR=\fIcommand\fR] [\fIpath\fR] +[\fB\-\-profile\fR] [\fB\-\-cmd\fR=\fIcommand\fR] [\fIpath ...\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" ranger is a console file manager with \s-1VI\s0 key bindings. @@ -172,6 +172,12 @@ with other software. They are usually installed to The man page of \fIrifle\fR\|(1) describes the functions of the file opener .PP The section \fI\s-1LINKS\s0\fR of this man page contains further resources. +.SH "POSITIONAL ARGUMENTS" +.IX Header "POSITIONAL ARGUMENTS" +.IP "\fIpath ...\fR" 14 +.IX Item "path ..." +Each path will be opened in a tab and if the path is a file it will be selected. +Omitting this is equivalent to providing the current directory. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-d\fR, \fB\-\-debug\fR" 14 @@ -225,7 +231,8 @@ Allows you to pick a directory with ranger. When you exit ranger, it will write the last visited directory into \fItargetfile\fR. .IP "\fB\-\-selectfile\fR=\fItargetfile\fR" 14 .IX Item "--selectfile=targetfile" -Open ranger with \fItargetfile\fR selected. +Open ranger with \fItargetfile\fR selected. This is a legacy option, superseded by +the behavior for the \s-1POSITIONAL ARGUMENTS.\s0 .IP "\fB\-\-show\-only\-dirs\fR" 14 .IX Item "--show-only-dirs" Display only the directories. May be used in conjunction with @@ -599,7 +606,7 @@ Toggle the mark-status of all files .IP "V" 14 .IX Item "V" Starts the visual mode, which selects all files between the starting point and -the cursor until you press \s-1ESC. \s0 To unselect files in the same way, use \*(L"uV\*(R". +the cursor until you press \s-1ESC.\s0 To unselect files in the same way, use \*(L"uV\*(R". .IP "/" 14 Search for files in the current directory. .IP ":" 14 diff --git a/doc/ranger.pod b/doc/ranger.pod index 8599a1a6..470eaa7e 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -14,7 +14,7 @@ B [B<--version>] [B<--help>] [B<--debug>] [B<--clean>] [B<--choosedir>=I] [B<--selectfile>=I] [B<--show-only-dirs>] [B<--list-unused-keys>] [B<--list-tagged-files>=I] -[B<--profile>] [B<--cmd>=I] [I] +[B<--profile>] [B<--cmd>=I] [I] @@ -53,6 +53,18 @@ The section I of this man page contains further resources. +=head1 POSITIONAL ARGUMENTS + +=over 14 + +=item I + +Each path will be opened in a tab and if the path is a file it will be selected. +Omitting this is equivalent to providing the current directory. + + + + =head1 OPTIONS =over 14 @@ -117,7 +129,8 @@ write the last visited directory into I. =item B<--selectfile>=I -Open ranger with I selected. +Open ranger with I selected. This is a legacy option, superseded by +the behavior for the POSITIONAL ARGUMENTS. =item B<--show-only-dirs> -- cgit 1.4.1-2-gfad0 From 98a176469faa51a678f5ac703e0e11c251425fdd Mon Sep 17 00:00:00 2001 From: toonn Date: Mon, 2 Apr 2018 22:40:54 +0200 Subject: Add a TODO on deprecating --selectfile --- ranger/core/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ranger/core/main.py b/ranger/core/main.py index 4adea918..2ae4d16b 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -89,6 +89,7 @@ def main( SettingsAware.settings_set(Settings()) + # TODO: deprecate --selectfile if args.selectfile: args.selectfile = os.path.abspath(args.selectfile) args.paths.insert(0, os.path.dirname(args.selectfile)) -- cgit 1.4.1-2-gfad0 From 3c430ba0f1b3fe2e17225788866f37bcd1f85c3b Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 3 Apr 2018 14:10:35 +0200 Subject: Document change in :cd behavior Added a sentence about the file selecting behavior of `:cd` to the docstring and the manpage. Added missing `=back` to POSITIONAL ARGUMENTS section in the manpage. --- doc/ranger.1 | 12 ++++++------ doc/ranger.pod | 10 ++++++---- ranger/config/commands.py | 3 ++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 7f307490..bd6116d1 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.1" "2018-03-31" "ranger manual" +.TH RANGER 1 "ranger-1.9.1" "2018-04-03" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -996,7 +996,7 @@ ranger. For your convenience, this is a list of the \*(L"public\*(R" commands i .Vb 10 \& alias [newcommand] [oldcommand] \& bulkrename -\& cd [directory] +\& cd [path] \& chain command1[; command2[; command3...]] \& chmod octal_number \& cmap key command @@ -1072,10 +1072,10 @@ renaming according to the changes you did in the file. .Sp This shell script is opened in an editor for you to review. After you close it, it will be executed. -.IP "cd [\fIdirectory\fR]" 2 -.IX Item "cd [directory]" -The cd command changes the directory. The command \f(CW\*(C`:cd \-\*(C'\fR is equivalent to -typing ``. +.IP "cd [\fIpath\fR]" 2 +.IX Item "cd [path]" +The cd command changes the directory. If path is a file, selects that file. +The command \f(CW\*(C`:cd \-\*(C'\fR is equivalent to typing ``. .IP "chain \fIcommand1\fR[; \fIcommand2\fR[; \fIcommand3\fR...]]" 2 .IX Item "chain command1[; command2[; command3...]]" Combines multiple commands into one, separated by semicolons. diff --git a/doc/ranger.pod b/doc/ranger.pod index 470eaa7e..4b0e90b1 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -62,6 +62,8 @@ The section I of this man page contains further resources. Each path will be opened in a tab and if the path is a file it will be selected. Omitting this is equivalent to providing the current directory. +=back + @@ -1033,7 +1035,7 @@ ranger. For your convenience, this is a list of the "public" commands including alias [newcommand] [oldcommand] bulkrename - cd [directory] + cd [path] chain command1[; command2[; command3...]] chmod octal_number cmap key command @@ -1113,10 +1115,10 @@ renaming according to the changes you did in the file. This shell script is opened in an editor for you to review. After you close it, it will be executed. -=item cd [I] +=item cd [I] -The cd command changes the directory. The command C<:cd -> is equivalent to -typing ``. +The cd command changes the directory. If path is a file, selects that file. +The command C<:cd -> is equivalent to typing ``. =item chain I[; I[; I...]] diff --git a/ranger/config/commands.py b/ranger/config/commands.py index a3837d8e..2f1480b9 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -120,9 +120,10 @@ class echo(Command): class cd(Command): - """:cd [-r] + """:cd [-r] The cd command changes the directory. + If the path is a file, selects that file. The command 'cd -' is equivalent to typing ``. Using the option "-r" will get you to the real path. """ -- cgit 1.4.1-2-gfad0