From 498ac4ffa7b90d385de6078a9162606a6bc524c3 Mon Sep 17 00:00:00 2001 From: toonn Date: Sat, 3 Aug 2019 00:29:10 +0200 Subject: Warn when nesting ranger Users frequently request that launching ranger in a subshell started from ranger (using `S`) instead exits the subshell so they end up in their original ranger instance without nesting, which is rarely useful. This isn't possible because a process can't easily kill its parent shell. To at least avoid such confusion we warn about nesting by default. A new setting `nested_ranger_warning` is added to `rc.conf`. The warning can be either disabled or the severity increased so the message is more visible. Fixes #1645 --- examples/rc_emacs.conf | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'examples/rc_emacs.conf') diff --git a/examples/rc_emacs.conf b/examples/rc_emacs.conf index 0462282e..a2e81892 100644 --- a/examples/rc_emacs.conf +++ b/examples/rc_emacs.conf @@ -206,6 +206,11 @@ set idle_delay 2000 # check all directories above the current one as well? set metadata_deep_search false +# Warn at startup if RANGER_LEVEL env var is greater than 0, in other words +# give a warning when you nest ranger in a subshell started by ranger. +# Special value "bad" makes the warning more visible. +set nested_ranger_warning true + # =================================================================== # == Local Options # =================================================================== -- cgit 1.4.1-2-gfad0 From 9511bd6e6b0d8a3e8ce04b723cf4903b81db1b61 Mon Sep 17 00:00:00 2001 From: Toon Nolten Date: Sun, 18 Aug 2019 15:05:08 +0200 Subject: Drop truth values; rename warning setting --- doc/ranger.1 | 29 ++++++++++++++++++----------- doc/ranger.pod | 8 ++++++++ examples/rc_emacs.conf | 2 +- ranger/config/rc.conf | 2 +- ranger/container/settings.py | 3 +-- ranger/core/main.py | 6 +++--- 6 files changed, 32 insertions(+), 18 deletions(-) (limited to 'examples/rc_emacs.conf') diff --git a/doc/ranger.1 b/doc/ranger.1 index bccbfa98..af13e690 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) +.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== @@ -46,7 +46,7 @@ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" -.\" If the F register is >0, we'll generate index entries on stderr for +.\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. @@ -56,12 +56,12 @@ .. .nr rF 0 .if \n(.g .if rF .nr rF 1 -.if (\n(rF:(\n(.g==0)) \{\ -. if \nF \{\ +.if (\n(rF:(\n(.g==0)) \{ +. if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. -. if !\nF==2 \{\ +. if !\nF==2 \{ . nr % 0 . nr F 2 . \} @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.2" "25/07/19" "ranger manual" +.TH RANGER 1 "ranger-1.9.2" "18-08-2019" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -173,7 +173,7 @@ plugins, sample configuration files and some programs for integrating ranger with other software. They are usually installed to \&\fI/usr/share/doc/ranger/examples\fR. .PP -The man page of \fBrifle\fR\|(1) describes the functions of the file opener +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" @@ -342,7 +342,7 @@ To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR t \fIkitty\fR .IX Subsection "kitty" .PP -This only works on Kitty. It requires \s-1PIL\s0 (or pillow) to work. +This only works on Kitty. It requires \s-1PIL \s0(or pillow) to work. Allows remote image previews, for example in an ssh session. .PP To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR to kitty. @@ -666,7 +666,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 @@ -971,6 +971,13 @@ all directories above the current one as well? .IP "mouse_enabled [bool] " 4 .IX Item "mouse_enabled [bool] " Enable mouse input? +.IP "nested_ranger_warning [string]" 4 +.IX Item "nested_ranger_warning [string]" +Warn at startup if \f(CW\*(C`RANGER_LEVEL\*(C'\fR is greater than 0, in other words give a +warning when you nest ranger in a subshell started by ranger. Allowed values +are \f(CW\*(C`true\*(C'\fR, \f(CW\*(C`false\*(C'\fR and \f(CW\*(C`error\*(C'\fR. The special value \f(CW\*(C`error\*(C'\fR promotes the +warning to an error, this is usually shown as red text but will crash ranger +when run with the \f(CW\*(C`\-\-debug\*(C'\fR flag. .IP "one_indexed [bool]" 4 .IX Item "one_indexed [bool]" Start line numbers from 1. Possible values are: @@ -1684,7 +1691,7 @@ Specifies the theme to be used for syntax highlighting when \fIpygmentize\fR is installed, unless \fIhighlight\fR is also installed. Find out possible values by running: python \-c 'import pygments.styles; [print(stl) for stl in - pygments.styles.\fBget_all_styles()\fR]' + pygments.styles.\fIget_all_styles()\fR]' .IP "\s-1HIGHLIGHT_STYLE\s0" 8 .IX Item "HIGHLIGHT_STYLE" Specifies the theme to be used for syntax highlighting when \fIhighlight\fR is @@ -1743,7 +1750,7 @@ copy, run: .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" -\&\fBrifle\fR\|(1) +\&\fIrifle\fR\|(1) .SH "BUGS" .IX Header "BUGS" Report bugs here: diff --git a/doc/ranger.pod b/doc/ranger.pod index 0fd5cc47..4b44fc92 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -985,6 +985,14 @@ all directories above the current one as well? Enable mouse input? +=item nested_ranger_warning [string] + +Warn at startup if C is greater than 0, in other words give a +warning when you nest ranger in a subshell started by ranger. Allowed values +are C, C and C. The special value C promotes the +warning to an error, this is usually shown as red text but will crash ranger +when run with the C<--debug> flag. + =item one_indexed [bool] Start line numbers from 1. Possible values are: diff --git a/examples/rc_emacs.conf b/examples/rc_emacs.conf index a2e81892..e3596ba5 100644 --- a/examples/rc_emacs.conf +++ b/examples/rc_emacs.conf @@ -208,7 +208,7 @@ set metadata_deep_search false # Warn at startup if RANGER_LEVEL env var is greater than 0, in other words # give a warning when you nest ranger in a subshell started by ranger. -# Special value "bad" makes the warning more visible. +# Special value "error" makes the warning more visible. set nested_ranger_warning true # =================================================================== diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 70701edf..00a20def 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -303,7 +303,7 @@ set size_in_bytes false # Warn at startup if RANGER_LEVEL env var is greater than 0, in other words # give a warning when you nest ranger in a subshell started by ranger. -# Special value "bad" makes the warning more visible. +# Special value "error" makes the warning more visible. set nested_ranger_warning true # =================================================================== diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 58e9df2e..0b098659 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -106,8 +106,7 @@ ALLOWED_VALUES = { 'confirm_on_delete': ['multiple', 'always', 'never'], 'draw_borders': ['none', 'both', 'outline', 'separators'], 'line_numbers': ['false', 'absolute', 'relative'], - 'nested_ranger_warning': ['true', 'false', 'yes', 'no', 'enabled', - 'disabled', 'bad'], + 'nested_ranger_warning': ['true', 'false', 'error'], 'one_indexed': [False, True], 'preview_images_method': ['w3m', 'iterm2', 'terminology', 'urxvt', 'urxvt-full', 'kitty', diff --git a/ranger/core/main.py b/ranger/core/main.py index bc0b742a..aefaacbc 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -183,10 +183,10 @@ def main( if int(os.environ[level]) > 1: warning = 'Warning:' nested_warning = "You're in a nested ranger instance!" - nrw = fm.settings.nested_ranger_warning.lower() - if nrw in ['true', 'yes', 'enabled']: + warn_when_nested = fm.settings.nested_ranger_warning.lower() + if warn_when_nested == 'true': fm.notify(' '.join((warning, nested_warning)), bad=False) - elif nrw == 'bad': + elif warn_when_nested == 'error': fm.notify(' '.join((warning.upper(), nested_warning + '!!')), bad=True) -- cgit 1.4.1-2-gfad0 From cb1fa307e7ea8c55d210f23097143fa1f9f6160c Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Tue, 1 Oct 2019 22:16:48 +0200 Subject: Add a configurable VCS max message length Previously it was hardcoded as 50, let's make it easy to change for the user. Improves upon #1705. Related to #1704. --- doc/ranger.1 | 5 ++++- doc/ranger.pod | 4 ++++ examples/rc_emacs.conf | 3 +++ ranger/config/rc.conf | 3 +++ ranger/container/settings.py | 1 + ranger/gui/widgets/statusbar.py | 6 +++++- 6 files changed, 20 insertions(+), 2 deletions(-) (limited to 'examples/rc_emacs.conf') diff --git a/doc/ranger.1 b/doc/ranger.1 index ee4c84e7..7bbea1cd 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.2" "2019-09-24" "ranger manual" +.TH RANGER 1 "ranger-1.9.2" "2019-10-01" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -1124,6 +1124,9 @@ Sets the state for the version control backend. The possible values are: \& local display only local state. \& enabled display both, local and remote state. May be slow for hg and bzr. .Ve +.IP "vcs_msg_length [int]" 4 +.IX Item "vcs_msg_length [int]" +Truncate the long commit messages to this length when shown in the statusbar. .IP "viewmode [string]" 4 .IX Item "viewmode [string]" Sets the view mode, which can be \fBmiller\fR to display the files in the diff --git a/doc/ranger.pod b/doc/ranger.pod index beb2fdb8..c01f611d 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -1170,6 +1170,10 @@ Sets the state for the version control backend. The possible values are: local display only local state. enabled display both, local and remote state. May be slow for hg and bzr. +=item vcs_msg_length [int] + +Truncate the long commit messages to this length when shown in the statusbar. + =item viewmode [string] Sets the view mode, which can be B to display the files in the diff --git a/examples/rc_emacs.conf b/examples/rc_emacs.conf index e3596ba5..a69d68fe 100644 --- a/examples/rc_emacs.conf +++ b/examples/rc_emacs.conf @@ -59,6 +59,9 @@ set vcs_backend_git enabled set vcs_backend_hg disabled set vcs_backend_bzr disabled +# Truncate the long commit messages to this length when shown in the statusbar. +set vcs_msg_length 50 + # Use one of the supported image preview protocols set preview_images false diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 00a20def..b0bddd55 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -67,6 +67,9 @@ set vcs_backend_hg disabled set vcs_backend_bzr disabled set vcs_backend_svn disabled +# Truncate the long commit messages to this length when shown in the statusbar. +set vcs_msg_length 50 + # Use one of the supported image preview protocols set preview_images false diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 82901ac0..6fc2da5e 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -94,6 +94,7 @@ ALLOWED_SETTINGS = { 'vcs_backend_git': str, 'vcs_backend_hg': str, 'vcs_backend_svn': str, + 'vcs_msg_length': int, 'viewmode': str, 'w3m_delay': float, 'w3m_offset': int, diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py index 19113012..fd44613e 100644 --- a/ranger/gui/widgets/statusbar.py +++ b/ranger/gui/widgets/statusbar.py @@ -212,7 +212,11 @@ class StatusBar(Widget): # pylint: disable=too-many-instance-attributes left.add_space() left.add(directory.vcs.rootvcs.head['date'].strftime(self.timeformat), 'vcsdate') left.add_space() - left.add(directory.vcs.rootvcs.head['summary'][:50], 'vcscommit') + summary_length = self.settings.vcs_msg_length or 50 + left.add( + directory.vcs.rootvcs.head['summary'][:summary_length], + 'vcscommit' + ) def _get_owner(self, target): uid = target.stat.st_uid -- cgit 1.4.1-2-gfad0